close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Free Shipping Coupon Codes with Multiple Shipping Rules

Thread began 8/17/2010 9:52 am by jgraber | Last modified 8/24/2010 8:01 am by jgraber | 2459 views | 10 replies |

jgraber

Free Shipping Coupon Codes with Multiple Shipping Rules

I have successfully implemented a coupon code form on the cart page that compares the entered code with the database. I have created a simple discount rule in the cart for a family discount which works fine. My dilemma now is that I would like to have a code in the database for free shipping. I have 4 separate flat rate shipping rules so when the cart subtotal is above a certain number the shipping rate changes. My thought was that I could create a discount rule for free shipping by having the session variable conditions met and have the discount be equal to the shipping amount variable.

Here is my code:

//eCart Rule
function WAEC_iembroider_FreeShipping() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['CouponCode'])) && ((isset($_SESSION['CouponCode'])?$_SESSION['CouponCode']:"") == "freeship523"))) {
$totalDiscount += $totalShipping;//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



This rule works properly when I have a flat rate discount or a percentage discount from the database, but I am unable to get the $totalShipping to work as the discount. Because there are multiple shipping rules I need the discount amount to change depending on the cart subtotal that is why I tried the $totalShipping.

Any thoughts would be appreciated. I know I could have four separate discount rules for free shipping, but that seems inefficient.

Sign in to reply to this post

Jason ByrnesWebAssist

in the eCart shipping rule, use a flat rate calculation and enter the following for the flat rate:
$this->GetShipping();

Sign in to reply to this post

jgraber

Do you mean enter it in the ecart discount rule? If so I tried that, but the order summary disappears.

Sign in to reply to this post

Jason ByrnesWebAssist

can you send a copy of your cart object page

Sign in to reply to this post

jgraber

Here is the file.

Attached Files
iembroider_PHP.zip
Sign in to reply to this post

Jason ByrnesWebAssist

the issue is that the shipping rules are all using the taxable total, and this is causing an endless loop to occur.

Set the shipping rules to use the cart subtotal instead of the taxable total

Sign in to reply to this post

jgraber

Thank you that worked. Do you have any tricks on being able to enter and use two coupon codes with the same cart? Let's say they know the free shipping code and a family discount code. Right now these overwrite each other when entered. Do we need to change the session variable.

Sign in to reply to this post

Jason ByrnesWebAssist

yes, you would need to set it up to use 2 separate session variables. you would also need a seperate discount for each session.

Sign in to reply to this post

jgraber

I tried to set up to session variables with this code:

<?php
if (!session_id()) session_start();
if((((isset($_POST["coupon"]))?$_POST["coupon"]:"") != "")) {
$_SESSION["CouponCode"] = "".((isset($_POST["coupon"]))?$_POST["coupon"]:"") ."";
$_SESSION["CouponCode2"] = "".((isset($_POST["coupon"]))?$_POST["coupon"]:"") ."";
}
?>
<?php
if (!session_id()) session_start();
if(!($totalRows_coupon == 0)) {
$_SESSION["CouponAmount"] = "".$row_coupon['Amount'] ."";
$_SESSION["CouponAmount2"] = "".$row_coupon['Amount'] ."";
}
?>



The discount rules are as follows:

//eCart Rule
function WAEC_iembroider_FamilyDiscount() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['CouponCode'])) && ((isset($_SESSION['CouponCode'])?$_SESSION['CouponCode']:"") != "freeship523") && (isset($_SESSION['CouponAmount'])))) {
$totalDiscount += ($this->TotalColumn("TotalPrice") * $_SESSION['CouponAmount']);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_iembroider_FreeShipping() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['CouponCode2'])) && ((isset($_SESSION['CouponCode2'])?$_SESSION['CouponCode2']:"") == "freeship523") && (isset($_SESSION['CouponAmount2'])))) {
$totalDiscount += $this->GetShipping();//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



The Family Discount is based on $_Session ['CouponCode'] and the Free Shipping Discount is based on $ Session ['CouponCode2'], but for some reason they still just overwrite each other in the cart. Any thoughts?

Sign in to reply to this post

Jason ByrnesWebAssist

sounds to me like the updated coupon rules are not being properly updated to the server



Try deleting the cart file from the server, then re uploading it.

the rules look like they should work, I dont see how they could overwrite each other.

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