close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Spending over X and getting Y product free

Thread began 9/18/2009 2:11 am by Suggs | Last modified 9/24/2009 8:56 am by Jason Byrnes | 2930 views | 7 replies |

Suggs

Spending over X and getting Y product free

Hi Folks,
Im trying to work out how to do the following and am not having much luck.

if a customer buys any product that subtotal => £1000,00 they get a free product.
The free product is also a sellable product that can be purchased on its own and is listed in the product database.
The free product will always be the same product and not vary.
The free product needs to be automatically added at basket when the subtotal hits £1000,00 or above and be marked as free product.

Any pointers will be great

Thanks

Paul

Sign in to reply to this post

Jason ByrnesWebAssist

This will need hand coding to accomplish.


Probably the best way to accomplish it will be to to add a notice to the cart page that orders over £1000 get the free item. then only add it to the cart after they click the Confirm order button on the confirm page.

in other words only add to the cart once they checkout out.

The reason for this is that it will be difficult to remove the item form the cart if they get up to £1000 then remove items to get the cart below £1000.

To do this, on the confirm page, add an add to cart server behavior, set the price of the item to 0 and the name to Free - <name of the Item>. Set the trigger to Button Confirm Order Pressed.


The add to cart code will be added to the page with the following if statement:

php:
<?php

if (isset($_POST["Submit_order"]))  {
<
add to cart code>
}
?>



You will need to add another if statement around that to check the cart subtotal:

php:
<?php if($WA_Store_Cart->GetTaxableTotal() => "1000") { ?>

<?php
if (isset($_POST["Submit_order"]))  {
<
add to cart code>
}
?>
<?php 
?>



so that the item will only be added if they place the order and the order is equal to or greater than £1000

Sign in to reply to this post

Suggs

Hi Jason,

Thanks for this.
I followed these guides you have given and had to create a recordset on the confirm page as there wasnt one there already..is this correct?? Also, this item is now only going to be an exclusive web offer that wont be sold on the site so is there a way i can create it as a static record for the giveaway and not use a database?
I followed your code and had to swap=> to >= as it bombed out, however now its bombing out with the following error
Parse error: syntax error, unexpected '{' in /home/barkerde/public_html/protx-confirm.php on line 331
This line of code looks like this:
<?php if ($stonehouse->GetTaxableTotal() >= "1000" { ?>

Also, when adding the ecart add to cart behaviour, im right in adding the get Contents From Recordset arent I?

Heres the relevant code the server behaviour generated. It also didnt give me a Button Confirm Order option in the trigger but a trigger option of Button: WADbSearch1 pressed which is the name of the button for the search box in the top of the page.

There is an option for current page submit...?????

Heres the code generated, along with the additional code you said to include:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
mysql_select_db($database_barkeran, $barkeran);
$query_Recordset1 = "SELECT * FROM productimport";
$Recordset1 = mysql_query($query_Recordset1, $barkeran) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php if ($stonehouse->GetTaxableTotal() >= "1000" { ?>
<?php
// WA eCart Get Info From RS
if (isset($_POST["Submit_order"])) {
$Redirect_redirStr="";
do {
$stonehouse_itemID = floatval("0");
$stonehouse_itemName = "Free - Union Jack Cushion";
$stonehouse_itemDescription = "";
$stonehouse_itemWeight = floatval("0");
$stonehouse_itemQuantity = floatval("0");
$stonehouse_itemPrice = floatval("0");
$stonehouse_itemThumbnail = "";
$stonehouse_itemShippingStatus = "";
$stonehouse_itemColour = "";
$stonehouse_itemSKU = "";

$stonehouse->AddToCart(1, "", $stonehouse_itemID, $stonehouse_itemName, $stonehouse_itemDescription, $stonehouse_itemWeight, $stonehouse_itemQuantity, $stonehouse_itemPrice, $stonehouse_itemThumbnail, $stonehouse_itemShippingStatus, $stonehouse_itemColour, $stonehouse_itemSKU);
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
if ($Redirect_redirStr != "") {
$stonehouse->redirStr = $Redirect_redirStr;
}
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
<?php } ?>

Thanks

Paul

Sign in to reply to this post

Jason ByrnesWebAssist

Since the Item is going to be the same all the time, you really dont need to use a recordset to look it up, you could just enter the information in the bindings panel. Actually using a recordset will just add unneeded overhead.



The error you are getting is because you are missing a closing parenthesis in the if statement:
<?php if ($stonehouse->GetTaxableTotal() >= "1000" { ?>

should be:
<?php if ($stonehouse->GetTaxableTotal() >= "1000") { ?>

Sign in to reply to this post

Suggs

Hi Jason,
Thanks for this.
Sorted the closing parenthesis.
When you say i can enter the information in the bindings panel, how is the best way to go about this?
Ive looked in the bindings panel of Dreamweaver and am not sure about how to apply what you have mentioned.

Any pointers to get this up and running will be greatly appreciated

Sign in to reply to this post

Jason ByrnesWebAssist

I meant on the Bindings tab of the Add to Cart button.

In the add to cart button behavior, instead of using a recordset, you should enter the information for the item manually. There is no need to use a recordset for this if the item will never change.

Sign in to reply to this post

Suggs

Hi Jason,

Would this not interfere with the general checkout process as the buy now button carries info over that is populated from the database. The site has over 3000 products that are database driven and the only item that is being set up as a static item is the free item we are giving away with purchases over £1000.
The static item is the item that I need to have populated in the confirm page or the cart page to show the customer they qualify for the free item, and from an admin point, i need to have this item recorded in the database when a qualifying order is received so we know to send it out and for it to appear on the customers email and our order screen...effectively as if it were another product the customer bought. but at a zero cost because their other items subtotal £1000 or more.

if this item has to be driven from the database as well instead of being static to make it work then thats no problem..id just need to know how to work it out.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

It should not be recordset driven. Only static.

The suggestion i am making is to add an add to cart button to the conform page, and modify the trigger so that it is only added when the customer 1) Clicks the Confirm order button and 2) when the total of the cart is over 1000.


The item will be added before the transaction is processed with the gateway, and before the order information is stored in the database. Since the item is added to the cart before these things happen, it will become a part of the order receipt, and will be stored in the database.

Sign in to reply to this post

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