close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

discount on shipping with coupon

Thread began 9/06/2016 4:24 pm by Christopher West | Last modified 9/11/2016 10:13 pm by Christopher West | 1250 views | 7 replies

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']);
    
}
?>

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