close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Discount on Quantity of an Item

Thread began 1/25/2011 9:43 am by bjgarner241692 | Last modified 1/25/2011 2:03 pm by bjgarner241692 | 2926 views | 13 replies |

bjgarner241692

Discount on Quantity of an Item

php:
//eCart Rule

function WAEC_eCart1_cards()  {
  $totalDiscount = 0;
  if (true && ((floatval($this->GetInfo("19", "Quantity")) >= 2))) {
    $totalDiscount += (floatval($this->GetInfo("19", "Quantity")) * 1);//Result
  }
  return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



I cannot figure out why this discount does not work. Code was created by the Discount wizard in the eCart UI.

Sign in to reply to this post

bjgarner241692

php:
//eCart Rule

function WAEC_eCart1_Shipping()  {
  $totalShipping = 0;
  if (true && (($this->GetTaxableTotal() <= 15.00))) {
    $totalShipping += 6.50;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



This rule does not work either. It results in truncating the Cart display after the quantity field of the first row of items.

Sign in to reply to this post

bjgarner241692

php:
//eCart Rule

function WAEC_eCart1_GraduatedShipping()  {
  $totalShipping = 0;
  if (true && ((sizeof($this->Items) == 1))) {
    $totalShipping += 8.5;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



I substituted the shipping rule with the above and this rule works fine.

Both issues seem to be related to the presence of a < or >.

So do I have a syntax issue in these first two rules or is there some code missing?

Sign in to reply to this post

bjgarner241692

Nope - it is not the < or > symbols affecting my Discount because this rule does not work either. It is just ignored.

php:
//eCart Rule

function WAEC_eCart1_Cards()  {
  $totalDiscount = 0;
  if (true && (($this->InCart("19") == true))) {
    $totalDiscount += 10;//Result
  }
  return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



So, do we have another example of code not being placed by the eCart behaviour?

I'm simply filling out forms here and these are not complicated rules so there is not much that I can do wrong.

Sign in to reply to this post

Jason ByrnesWebAssist

the issue with the second rule is most likely that you have selected the option to include shipping in the tax.

If you include shipping in the tax, you cannot use taxable total in the shipping rule, this creates an endless loop where the tax is recalculated because shipping has changed, then the shipping has to be recalculated, because the tax has changed etc....

the one constant with the other rules is that you are testing for an item with an ID of 19

Create a new php page and add a new cart display manager to it. On the second page of the display manager wizard, you can select columns to include in the cart display, add the ID column. this way you can see what ID value is stored in the cart.

Send me a link to your store including this new cart page so i can test it.

Sign in to reply to this post

bjgarner241692

My Apologies Jason,
The issue is not with WA.
This is very bizarre but when I add the item with ID 19, it is identified in the cart as ID 23
5 is 9

13 is 17

I have no idea how that is happening but I'm looking at PHPMyAdmin and the ID of the product is 19. When I view the product detail it is 19, but when I added the ID column to the the card display it says ID #23.

Truly bizarre.

As a point of interest if anyone knows how this could happen, I'm all ears ....

Sign in to reply to this post

Jason ByrnesWebAssist

sounds like the add to cart button is set to use a different column than the primary key column for the eCart ID column.

Sign in to reply to this post

bjgarner241692

you would think so but:

php:
<input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_product["ID"]; ?>" />



column names:

id
name
description
picture
price
category

Only ID and Price are numbers. Everything else is a text field.

No worries, it works now and there is only one item where I need to utilize the ID# so it will be fine.

Sign in to reply to this post

Jason ByrnesWebAssist

that's only showing a small part of the puzzle. I would need to see the add to cart code as well to be able to see the full picture.

Sign in to reply to this post

bjgarner241692

If you insist:

php:
<?php

$param_product 
"-1";
if (isset(
$_GET["ID"])) {
  
$param_product = (get_magic_quotes_gpc()) ? $_GET["ID"] : addslashes($_GET["ID"]);
}
mysql_select_db($database_constring$constring);
$query_product sprintf("SELECT Name,Description,Picture,Extra,prod_pricing.pricelevel,prod_pricing.price, prod_pricing.ID FROM life_prods INNER JOIN prod_pricing ON life_prods.Name = prod_pricing.ProdName WHERE %s = life_prods.ID ORDER BY prod_pricing.Price"GetSQLValueString($param_product"int"));
$product mysql_query($query_product$constring) or die(mysql_error());
$row_product mysql_fetch_assoc($product);
$totalRows_product mysql_num_rows($product);
?>
<?php
// WA eCart AddToCart
if (isset($_POST["eCart1_1_ATC"]) || isset($_POST["eCart1_1_ATC_x"]))     {
  
$ATC_itemID $_POST["eCart1_1_ID_Add"];
  
$ATC_AddIfIn 0;
  
$ATC_RedirectAfter "cart.php";
  
$ATC_RedirectIfIn  "cart.php";
  if (isset(
$totalRows_product) && $totalRows_product 0)     {
    
$row_product WAEC_findRecordMySQL($product"ID"$ATC_itemID);
    if (
$row_product)     {
      
$ATC_itemName "".$row_product['Name']  ."";// column binding
      
$ATC_itemDescription "".$row_product['pricelevel']  ."";// column binding
      
$ATC_itemWeight floatval("0");// column binding
      
$ATC_itemQuantity "".$_POST["eCart1_1_Quantity_Add"]  ."";// column binding
      
$ATC_itemPrice floatval("".$row_product['price']  ."");// column binding
      
mysql_data_seek($product0);
      
$row_product mysql_fetch_assoc($product);
    }
  }
  
$ATC_itemQuantity floatval($ATC_itemQuantity);
  if (
is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0)     {
    
$eCart1->AddToCart($ATC_AddIfIn$ATC_RedirectIfIn$ATC_itemID$ATC_itemName$ATC_itemDescription$ATC_itemWeight$ATC_itemQuantity$ATC_itemPrice);
    if (
$ATC_RedirectAfter != "" && $eCart1->redirStr == "")     {
      
$eCart1->redirStr $ATC_RedirectAfter;
    }
    if (isset(
$_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "")  {
      
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
    }
    else  {
      
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
    }
  }
}
?>



php:
<form name="eCart1_1_ATC_<?php echo $row_product["ID"]; ?>" method="POST"  action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""?>">

                        <input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_product["ID"]; ?>" />
                        <input type="text" name="eCart1_1_Quantity_Add" value="1" size="4" >
                        <input type="submit" class="eC_FormButton" value="Add to Cart" name="eCart1_1_ATC">
                        </form>
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...