close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

discount on shipping with coupon

Thread began 9/06/2016 1:24 pm by Christopher West | Last modified 9/11/2016 7:13 pm by Ray Borduin | 2460 views | 7 replies |

Christopher WestCommunity Expert

discount on shipping with coupon

hi using the ecart object I am trying to figure out how to create a coupon discount condition that would either give a flat rate or percentage discount to shipping (I have already set up other coupons that give discounts based on items in the cart. but the only options for shipping discounts are UPS, FedEx, US Postal Server, Australia Post and DHL....

I am not using any of these delivery services as I am using my own. And I have set up the delivery costs in ecart already.

Would I have to do this hand coded on my page or is there anyway to add in a coupon calculation for shipping discounts within the ecart object?

Chris

Sign in to reply to this post

Ray BorduinWebAssist

I'd probably do it manually by saving the coupon discount in the session after calculating it based on the total shipping amount and just use that session variable as the discount.

Sign in to reply to this post
Did this help? Tips are appreciated...

Christopher WestCommunity Expert

So are you saying, not to use ecart object, but instead use the ecart bindings that are on offer for the one that stores shipping amount and then use my coupon session to subtract that amount from the ecart shipping session? (and do all this on my php page rather than the ecart object?

Sign in to reply to this post

Ray BorduinWebAssist

I'm saying calculate the discount outside of eCart and save it in the session and then use the ecart rule to subtract the discount amount stored in the session.

Sign in to reply to this post
Did this help? Tips are appreciated...

Christopher WestCommunity Expert

Hi, would I still be able to show the discount as shipping? so on my basket page shipping will display (for example) £0.00 ?

Sign in to reply to this post

Ray BorduinWebAssist

If you want to do that then just add it as another shipping rule instead of a discount with the session variable value * -1

Sign in to reply to this post
Did this help? Tips are appreciated...

Christopher WestCommunity Expert

Hi Ray, with the last part that you wrote, I didn't quite understand the code : * -1 ?

Perhaps I am over-complicating. Looking at a fresh perspective, what do you think of this approach, this is a break down of what I need/done

(1) my discount system comprises of discounts (pounds/percentages for products, sale category or delivery) (done)
(2) the discount conditions for products or sale category would be placed in the discounts tab in the eCart Object. (done)
(3) in the shipping tab of the eCart object, I only have one rule (if session exists then flat rate on the session). (done)
(4) the basket page includes a form for customer to add a coupon code and pressing on the Apply button creates that session (done)
(5) if the coupon relates to either product or sale category then the discount shows on the basket page. (works)
(6) if the coupon relates to delivery then that session will be passed onto my delivery php file. (works)
(7) at checkout on the address page on submit it redirects to my delivery php file (before going to payment page) (works)
(8) on the delivery php file, I am looking up delivery cost in a filtered recordset (works)
(9) I have an IF statement if the customer chooses "store collection" then the delivery session = 0 (works)
(10) if the customer selected "standard delivery" on checkout then the session is based on the filtered recordset. (works)
(11) I need to write an if statement (based on the below conditions) if TRUE then then delivery session = the result on the IF statement (I need to write)


DELIVERY POUND DISCOUNT
If Session variable exists: CouponDiscount
If Session variable CouponType == 2
IF Session variable CouponGroup == 3
If today is after $_SESSION['CouponValidFrom']
If today is before $_SESSION['CouponValidTo']

{create the calculation for the current delivery cost - the coupon session value}

DELIVERY PERCENTAGE DISCOUNT

If Session variable exists: CouponDiscount
If Session variable CouponType == 1
IF Session variable CouponGroup == 3
If today is after $_SESSION['CouponValidFrom']
If today is before $_SESSION['CouponValidTo']
based on the cart subtotal

{create the caculation for the current delivery cost - the coupon session value as a percentage}




To me the above seems clear in my head as an approach as then I can add extra code to show the customer that delivery is discounted etc.

I just need to work out the calculations using the above conditions. I have coded this and wondered if it makes sense this way:



php:
<?php

// Percentage
if (((isset($_SESSION['CouponDiscount']))
&& ((isset(
$_SESSION['CouponType'])?$_SESSION['CouponType']:"") == "1")
&& ((isset(
$_SESSION['CouponGroup'])?$_SESSION['CouponGroup']:"") == "3")
&& (
time() >= strtotime("".$_SESSION['CouponValidFrom']  .""))
&& (
time() <= strtotime("".$_SESSION['CouponValidTo']  ."")))) {
    
$_SESSION["EstimatedDeliveryCost"] = $_SESSION["EstimatedDeliveryCost"] - (($_SESSION["EstimatedDeliveryCost"] * $_SESSION['CouponDiscount']));
    
}
?>



php:
<?php

// Flat Rate
if (((isset($_SESSION['CouponDiscount']))
&& ((isset(
$_SESSION['CouponType'])?$_SESSION['CouponType']:"") == "2")
&& ((isset(
$_SESSION['CouponGroup'])?$_SESSION['CouponGroup']:"") == "3")
&& (
time() >= strtotime("".$_SESSION['CouponValidFrom']  .""))
&& (
time() <= strtotime("".$_SESSION['CouponValidTo']  ."")))) {
    
$_SESSION["EstimatedDeliveryCost"] = ($_SESSION["EstimatedDeliveryCost"] - $_SESSION['CouponDiscount']);
    
}
?>
Sign in to reply to this post

Ray BorduinWebAssist

I don't see an issue with this approach. I could help you figure this out in a premier support ticket.

Sign in to reply to this post
Did this help? Tips are appreciated...

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