close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Incremental pricing not updating price...

Thread begun 4/07/2014 11:37 am by Nathon Jones Web Design | Last modified 4/14/2014 9:42 am by Jason Byrnes | 3439 views | 18 replies |

Nathon Jones Web Design

Incremental pricing not updating price...

http://www.ledwarehouseuk.com/LED-Lights-Bulbs.php?lbid=428

Select "Dimmable" from the drop-down menu.

£0.70 should be being added to the price, but it isn't. Have followed the tutorial on adding incremental pricing but I must have missed something...here is my Add to Cart code:

<?php
// WA eCart AddToCart
if (isset($_POST["LEDCart_1_ATC"]) || isset($_POST["LEDCart_1_ATC_x"])) {
$ATC_itemID = $_POST["LEDCart_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "shopping-basket.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_rsPROD) && $totalRows_rsPROD > 0) {
$row_rsPROD = WAEC_findRecordMySQL($rsPROD, "LEDid", $ATC_itemID);
if ($row_rsPROD) {
$ATC_itemName = "".$row_rsPROD['LEDproductcode'] ."";// column binding
$ATC_itemDescription = "".$row_rsPROD['LEDtitle'] ."";// column binding
$ATC_itemThumbnail = "".$row_rsPROD['LEDimg'] ."";// column binding
$ATC_itemWeight = floatval("".$row_rsPROD['LEDnetweight'] ."");// column binding
$ATC_itemQuantity = "".$_POST["LEDCart_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rsPROD['LEDprice'] ."");// column binding
$ATC_itemColour = "".$_POST["LEDCart_1_Colour_Add"] ."";// column binding
$ATC_itemDimmable = "".$_POST["LEDCart_1_Dimmable_Add"] ."";// column binding
$ATC_itemDimmPriceInc = floatval("".$row_rsDIMMLOOKUP['LEDprodoptionincr'] ."");// column binding
$ATC_itemSensor = "".$_POST["LEDCart_1_Sensor_Add"] ."";// column binding
mysql_data_seek($rsPROD, 0);
$row_rsPROD = mysql_fetch_assoc($rsPROD);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$LEDCart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemColour, $ATC_itemDimmable, $ATC_itemDimmPriceInc, $ATC_itemSensor);
if ($ATC_RedirectAfter != "" && $LEDCart->redirStr == "") {
$LEDCart->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'];
}
}
}
?>

Thank you.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of the page please so i can the code in context.

Sign in to reply to this post

Nathon Jones Web Design

Attached. Thank you.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

the select list is passing text values:

<select name="LEDCart_1_Dimmable_Add" id="LEDCart_1_Dimmable_Add">
<option value="Non-Dimmable">Non-Dimmable + £0.00&nbsp;&nbsp;</option>
<option value="Dimmable">Dimmable + £0.70&nbsp;&nbsp;</option>
</select>

it should be passig the option ID to be used i nthe lookup recordset.


the lookup recordset is set to filter the LEDprodoptions.LEDprodoptionsID column on the value passed by the LEDCart_1_Dimmable_Add select list.

since you are passing text values, the lookup on a numeric column is failing.

Sign in to reply to this post

Nathon Jones Web Design

I've changed the value of the select list to:

<option value="<?php echo $row_rsDIMM['LEDprodoptionsID']; ?>"><?php echo $row_rsDIMM['LEDvarname']?> + £<?php echo $row_rsDIMM['LEDprodoptionincr']; ?>&nbsp;&nbsp;</option>

However, now that this seems to work it's passing the numeric value to our cart page so, in the list of variables in the customers cart, they're seeing "50" instead of "Dimable".

We also want to store the word "Dimmable" in the order detail table so that we can easily identify it.

How do we achieve that?
Thank you.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

in the add to cart button, you have the dimable column bound to the select list form element:


$ATC_itemDimmable = "".$_POST["LEDCart_1_Dimmable_Add"] ."";// column binding

instead, bind it to the option name column from the rsDIMMLOOKUP recordset, i believe that is the LEDprodvarname column:

$ATC_itemDimmable = "".$row_rsDIMMLOOKUP['LEDprodvarname'] ."";// column binding

Sign in to reply to this post

Nathon Jones Web Design

Thank you Jason, that has resolved it or, rather, we are seeing the words either "Dimmable" or "Non-dimmable" instead of the numeric value now so I assume that's what, once we get it working, will be saved to database.

NJ

Sign in to reply to this post

Nathon Jones Web Design

When we get to the cart page, is it possible to display the unit price for an item PLUS it's incremental price in the price column? At the moment it's just listing the original unit price in the price column, however the total for the unit is correct (in that it is the unit price plus any incremental charges)

https://www.ledwarehouseuk.com/LED-Lights-Bulbs.php?lbid=333 > Select Dimmable from drop down > Add to Basket
It will show as £5.50 in the price column, but £6.20 in the total.

Also, next to the incremental description, is it possible to list the incremental price but only where it exists?

Thank you.
NJ

EDIT:

Am running into an additional problem in that I have two different drop down menu's for two different product variables, both of which add to the price of a product....Dimmable, which is working, and Sensor which isn't.

The sensor option is adding the incremental value to the "Total" field, so it has a similar problem as the one I've described above for Dimmable, but regardless of whether you choose Sensor or No Sensor, it only passes the value "Sensor" to the basket page.

Hope you can help
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

when working with options that effect price, you need to have a column in the cart object for the price increment and the option name, so where you have 2 options effecting the price, you will need to have 2 price increment columns:

Dimmable
DimmablePriceInc
Sensor
SensorPriceInc

the select lists for those options should pass the option ID to a Lookup recordset that looks up the option name and the Price Increment value

to add the price increment, you need create a calculation:

TruePrice:
[Price] + [DimmablePriceInc] + [SensorPriceInc]

to show the actual price in the cart display, Substitute the Price cart binding for the truePrice cart binding from the bindings panel.


you can show the incremental price also by using the DimmablePriceInc and SensorPriceInc bindings in the cart display.

If the wrong option name is being added to the cart, there is either a problem with the recordset that looks up the option name, or the biding in the add to cart button code.

Sign in to reply to this post

Nathon Jones Web Design

I have:

Dimmable
DimmPriceInc
Sensor
SensorPriceInc

...in the cart object. Here are the select lists for those options on the add to cart page...

<?php if ($totalRows_rsDIMM > 0) { // Show if recordset not empty ?>
<label for"LEDCart_1_Dimmable_Add">Dimmable:</label>
<select name="LEDCart_1_Dimmable_Add" id="LEDCart_1_Dimmable_Add">
<?php
do {
?>
<option value="<?php echo $row_rsDIMM['LEDprodoptionsID']; ?>"><?php echo $row_rsDIMM['LEDvarname']?> +£<?php echo $row_rsDIMM['LEDprodoptionincr']; ?>&nbsp;&nbsp;</option>
<?php
} while ($row_rsDIMM = mysql_fetch_assoc($rsDIMM));
$rows = mysql_num_rows($rsDIMM);
if($rows > 0) {
mysql_data_seek($rsDIMM, 0);
$row_rsDIMM = mysql_fetch_assoc($rsDIMM);
}
?>
</select><br><br>
<?php } // Show if recordset not empty ?>


<!-- #Hidden dimmable field if no dimmable option available -->
<?php if ($totalRows_rsDIMM == 0) { // Show if recordset empty ?>
<input type="hidden" name="LEDCart_1_Dimmable_Add" id="LEDCart_1_Dimmable_Add" value="Non-Dimmable" >
<?php } // Show if recordset empty ?>
<!-- #Hidden dimmable field if no dimmable option available -->


<?php if ($totalRows_rsSENSOR > 0) { // Show if recordset not empty ?>
<label for"LEDCart_1_Sensor_Add">Sensor:</label>
<select name="LEDCart_1_Sensor_Add" id="LEDCart_1_Sensor_Add">
<?php
do {
?>
<option value="<?php echo $row_rsSENSOR['LEDprodoptionsID']; ?>"><?php echo $row_rsSENSOR['LEDvarname']?> +£<?php echo $row_rsSENSOR['LEDprodoptionincr']; ?>&nbsp;&nbsp;</option>
<?php
} while ($row_rsSENSOR = mysql_fetch_assoc($rsSENSOR));
$rows = mysql_num_rows($rsSENSOR);
if($rows > 0) {
mysql_data_seek($rsSENSOR, 0);
$row_rsSENSOR = mysql_fetch_assoc($rsSENSOR);
}
?>
</select><br><br>
<?php } // Show if recordset not empty ?>

<!-- #Hidden sensor field if no sensor option available -->
<?php if ($totalRows_rsSENSOR == 0) { // Show if recordset empty ?>
<input type="hidden" name="LEDCart_1_Sensor_Add" id="LEDCart_1_Sensor_Add" value="" >
<?php } // Show if recordset empty ?>
<!-- #Hidden sensor field if no sensor option available -->

Here are the recordsets...

$paramItem_rsDIMM = "-1";
if (isset($row_rsPROD['LEDid'])) {
$paramItem_rsDIMM = $row_rsPROD['LEDid'];
}
mysql_select_db($database_connLED, $connLED);
$query_rsDIMM = sprintf("SELECT LEDprodoptions.LEDprodoptionincr, LEDprodoptions.LEDprodoptionsID, LEDvars.LEDvarname, LEDvars.LEDprodvarID, LEDprodvars.LEDprodvarname FROM LEDvars INNER JOIN LEDprodoptions ON LEDvars.LEDvarID = LEDprodoptions.LEDvarID INNER JOIN LEDprodvars ON LEDvars.LEDprodvarID = LEDprodvars.LEDprodvarID WHERE LEDprodvars.LEDprodvarname = 'Dimmable' AND LEDprodoptions.LEDid = %s", GetSQLValueString($paramItem_rsDIMM, "int"));
$rsDIMM = mysql_query($query_rsDIMM, $connLED) or die(mysql_error());
$row_rsDIMM = mysql_fetch_assoc($rsDIMM);
$totalRows_rsDIMM = mysql_num_rows($rsDIMM);

$paramOption_rsDIMMLOOKUP = "-1";
if (isset($_POST['LEDCart_1_Dimmable_Add'])) {
$paramOption_rsDIMMLOOKUP = $_POST['LEDCart_1_Dimmable_Add'];
}
$paramItem_rsDIMMLOOKUP = "-1";
if (isset($_POST['LEDCart_1_ID_Add'])) {
$paramItem_rsDIMMLOOKUP = $_POST['LEDCart_1_ID_Add'];
}
mysql_select_db($database_connLED, $connLED);
$query_rsDIMMLOOKUP = sprintf("SELECT LEDprodoptions.LEDprodoptionincr, LEDprodoptions.LEDprodoptionsID, LEDvars.LEDvarname, LEDvars.LEDprodvarID, LEDprodvars.LEDprodvarname FROM LEDvars INNER JOIN LEDprodoptions ON LEDvars.LEDvarID = LEDprodoptions.LEDvarID INNER JOIN LEDprodvars ON LEDvars.LEDprodvarID = LEDprodvars.LEDprodvarID WHERE LEDprodvars.LEDprodvarname = 'Dimmable' AND LEDprodoptions.LEDprodoptionsID = %s AND LEDprodoptions.LEDid = %s", GetSQLValueString($paramOption_rsDIMMLOOKUP, "int"),GetSQLValueString($paramItem_rsDIMMLOOKUP, "int"));
$rsDIMMLOOKUP = mysql_query($query_rsDIMMLOOKUP, $connLED) or die(mysql_error());
$row_rsDIMMLOOKUP = mysql_fetch_assoc($rsDIMMLOOKUP);
$totalRows_rsDIMMLOOKUP = mysql_num_rows($rsDIMMLOOKUP);

$paramItem_rsSENSOR = "-1";
if (isset($row_rsPROD['LEDid'])) {
$paramItem_rsSENSOR = $row_rsPROD['LEDid'];
}
mysql_select_db($database_connLED, $connLED);
$query_rsSENSOR = sprintf("SELECT LEDprodoptions.LEDprodoptionincr, LEDprodoptions.LEDprodoptionsID, LEDvars.LEDvarname, LEDvars.LEDprodvarID, LEDprodvars.LEDprodvarname FROM LEDvars INNER JOIN LEDprodoptions ON LEDvars.LEDvarID = LEDprodoptions.LEDvarID INNER JOIN LEDprodvars ON LEDvars.LEDprodvarID = LEDprodvars.LEDprodvarID WHERE LEDprodvars.LEDprodvarname = 'Sensor' AND LEDprodoptions.LEDid = %s", GetSQLValueString($paramItem_rsSENSOR, "int"));
$rsSENSOR = mysql_query($query_rsSENSOR, $connLED) or die(mysql_error());
$row_rsSENSOR = mysql_fetch_assoc($rsSENSOR);
$totalRows_rsSENSOR = mysql_num_rows($rsSENSOR);

$paramOption_rsSENSORLOOKUP = "-1";
if (isset($_POST['LEDCart_1_Sensor_Add'])) {
$paramOption_rsSENSORLOOKUP = $_POST['LEDCart_1_Sensor_Add'];
}
$paramItem_rsSENSORLOOKUP = "-1";
if (isset($_POST['LEDCart_1_ID_Add'])) {
$paramItem_rsSENSORLOOKUP = $_POST['LEDCart_1_ID_Add'];
}
mysql_select_db($database_connLED, $connLED);
$query_rsSENSORLOOKUP = sprintf("SELECT LEDprodoptions.LEDprodoptionincr, LEDprodoptions.LEDprodoptionsID, LEDvars.LEDvarname, LEDvars.LEDprodvarID, LEDprodvars.LEDprodvarname FROM LEDvars INNER JOIN LEDprodoptions ON LEDvars.LEDvarID = LEDprodoptions.LEDvarID INNER JOIN LEDprodvars ON LEDvars.LEDprodvarID = LEDprodvars.LEDprodvarID WHERE LEDprodvars.LEDprodvarname = 'Sensor' AND LEDprodoptions.LEDprodoptionsID = %s AND LEDprodoptions.LEDid = %s", GetSQLValueString($paramOption_rsSENSORLOOKUP, "int"),GetSQLValueString($paramItem_rsSENSORLOOKUP, "int"));
$rsSENSORLOOKUP = mysql_query($query_rsSENSORLOOKUP, $connLED) or die(mysql_error());
$row_rsSENSORLOOKUP = mysql_fetch_assoc($rsSENSORLOOKUP);
$totalRows_rsSENSORLOOKUP = mysql_num_rows($rsSENSORLOOKUP);

The calculation in my eCart Object is...

TotalPrice = ([Price] + [DimmPriceInc] + [SensorPriceInc]) * [Quantity]
TruePrice = [Price] + [DimmPriceInc] + [SensorPriceInc]

Can you see what it is I'm doing wrong? The SensorPriceInc is being added but it's not displaying the correct variable name on the cart page?
Here's the add to cart button code:

<?php
// WA eCart AddToCart
if (isset($_POST["LEDCart_1_ATC"]) || isset($_POST["LEDCart_1_ATC_x"])) {
$ATC_itemID = $_POST["LEDCart_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "shopping-basket.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_rsPROD) && $totalRows_rsPROD > 0) {
$row_rsPROD = WAEC_findRecordMySQL($rsPROD, "LEDid", $ATC_itemID);
if ($row_rsPROD) {
$ATC_itemName = "".$row_rsPROD['LEDproductcode'] ."";// column binding
$ATC_itemDescription = "".$row_rsPROD['LEDtitle'] ."";// column binding
$ATC_itemThumbnail = "".$row_rsPROD['LEDimg'] ."";// column binding
$ATC_itemWeight = floatval("".$row_rsPROD['LEDnetweight'] ."");// column binding
$ATC_itemQuantity = "".$_POST["LEDCart_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rsPROD['LEDprice'] ."");// column binding
$ATC_itemColour = "".$_POST["LEDCart_1_Colour_Add"] ."";// column binding
$ATC_itemDimmable = "".$row_rsDIMMLOOKUP['LEDprodvarname'] ."";// column binding
$ATC_itemDimmPriceInc = floatval("".$row_rsDIMMLOOKUP['LEDprodoptionincr'] ."");// column binding
$ATC_itemSensor = "".$row_rsSENSORLOOKUP['LEDprodvarname'] ."";// column binding
$ATC_itemSensorPriceInc = floatval("".$row_rsSENSORLOOKUP['LEDprodoptionincr'] ."");// column binding
mysql_data_seek($rsPROD, 0);
$row_rsPROD = mysql_fetch_assoc($rsPROD);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$LEDCart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemColour, $ATC_itemDimmable, $ATC_itemDimmPriceInc, $ATC_itemSensor, $ATC_itemSensorPriceInc);
if ($ATC_RedirectAfter != "" && $LEDCart->redirStr == "") {
$LEDCart->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'];
}
}
}
?>

I've changed the Price cart binding on our cart page to TruePrice, and that has worked correctly. Thank you.

On reflection, if I have the TruePrice shown above then I don't think it's as important to display the incremental price alongside the variable name, however when looking at all of that I notice the following code in the same column as my product title, variable list etc:

<p id="LEDCart_JSON_Display_Price_<?php echo $LEDCart->DisplayInfo("WAUID"); ?>" class="eC_ItemPrice max_tablet"><?php echo WA_eCart_DisplayMoney($LEDCart, $LEDCart->DisplayInfo("Price")); ?></p>
<p class="eC_ItemRemove_Link max_tablet"><a href="#" onclick="waec_update('Remove','LEDCart_Quantity_<?php echo $LEDCart->DisplayInfo("WAUID"); ?>',this);">Remove</a></p>

These things appear invisible on the cart page though? I don't see any "Remove" link, for a start. What are those references?

Much appreciated
NJ

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...