Free Shipping Coupon

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
jessthib
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Tue Nov 03, 2009 10:26 am

Free Shipping Coupon

Post by jessthib » Wed Dec 09, 2009 10:26 am

Hello!

I'm having a bit of an issue with a free shipping coupon I set up. The coupon is set to give free ground shipping as long as the purchase is at least $40. The problem is arising when a customer buys several items totaling over $40 but is shipping them to separate addresses. The shopping cart tells the customer that each SHIPMENT must be at least $40 as opposed to the TOTAL PURCHASE. We would like the coupon to still be applied to multiple shipments totaling at least $40.

Please advise.

Thanks!

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Free Shipping Coupon

Post by mazhar » Thu Dec 10, 2009 5:38 am

The Min Purchase purchase option available for shipping coupon is actually represents the shipment total not the order total. So I think application is good. In order to work it out in your case you need to try some work around. Here is a small workaround. Edit your ConLib/PaymentPage.ascx.cs file and locate following code location

Code: Select all

if (CouponCalculator.IsCouponValid(Token.Instance.User.Basket, coupon, out couponValidityMessage))
and replace it with following code
EDIT MADE

Code: Select all

bool isValidCoupon = false;
                isValidCoupon = CouponCalculator.IsCouponValid(Token.Instance.User.Basket, coupon, out couponValidityMessage);
                if (Token.Instance.User.Basket.Shipments.Count > 1 && couponValidityMessage.StartsWith("The coupon code you've entered requires a minimum purchase of "))
                {
                    OrderItemType[] orderItemTypes = new OrderItemType[1]{OrderItemType.Product};
                    isValidCoupon = Token.Instance.User.Basket.Items.TotalPrice(orderItemTypes) > coupon.MinPurchase;
                }
                
                if (isValidCoupon)
In above modification I just updated the coupon validity check that even if coupon is invalid because each shipment doesn't total to minimum purchase but order total confirms the check then coupon is good.

jessthib
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Tue Nov 03, 2009 10:26 am

Re: Free Shipping Coupon

Post by jessthib » Thu Dec 10, 2009 10:29 am

Thank you so much for your reply. I switched out the code as you told to me to but upon testing the code the buyer still receives the "The coupon code you've entered requires a shipment with value of items to be $40.00 or more." message.

Any other thoughts?

Thanks!!!

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Free Shipping Coupon

Post by mazhar » Thu Dec 10, 2009 10:40 am

It should work. Make sure that basket doesn't contain any other discount items for example some volume discounts because when calculating basket total price this amount will be subtracted leaving us basket total less then the desired amount.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Free Shipping Coupon

Post by mazhar » Fri Dec 11, 2009 6:15 am

I made a small enhancement to above posted code you should better take this update. In fact I think when calculating basket total we shouldn't consider volume discounts and coupon etc, it should be total of all products being purchased and this what I changed in above code.

bigbangtech
Commander (CMDR)
Commander (CMDR)
Posts: 182
Joined: Mon Oct 10, 2005 6:27 pm

Re: Free Shipping Coupon

Post by bigbangtech » Thu Apr 18, 2013 2:01 pm

Talking about beating an old thread... I used the code you provided for my 7.06 setup because we wanted a free over $100 shipping coupon to work on orders with multiple shipments just like the OP. However, OP had multiple shipments from SAME warehouse to MULTIPLE ship-to's.

When our customers order, they are ordering from MULTIPLE warehouses shipping to one address OR multiple addresses. This code doesn't seem to change the behavior of the coupon.

I just tested with one warehouse shipping to multiple destinations, and it did not accept the coupon
+ I just tested with two warehouses shipping to one destination, and it did not accept the coupon

Without the code modification, the coupon takes $ off the first shipment, but not the second
mazhar wrote:The Min Purchase purchase option available for shipping coupon is actually represents the shipment total not the order total. So I think application is good. In order to work it out in your case you need to try some work around. Here is a small workaround. Edit your ConLib/PaymentPage.ascx.cs file and locate following code location

Code: Select all

if (CouponCalculator.IsCouponValid(Token.Instance.User.Basket, coupon, out couponValidityMessage))
and replace it with following code
EDIT MADE

Code: Select all

bool isValidCoupon = false;
                isValidCoupon = CouponCalculator.IsCouponValid(Token.Instance.User.Basket, coupon, out couponValidityMessage);
                if (Token.Instance.User.Basket.Shipments.Count > 1 && couponValidityMessage.StartsWith("The coupon code you've entered requires a minimum purchase of "))
                {
                    OrderItemType[] orderItemTypes = new OrderItemType[1]{OrderItemType.Product};
                    isValidCoupon = Token.Instance.User.Basket.Items.TotalPrice(orderItemTypes) > coupon.MinPurchase;
                }
                
                if (isValidCoupon)
In above modification I just updated the coupon validity check that even if coupon is invalid because each shipment doesn't total to minimum purchase but order total confirms the check then coupon is good.
AC7.3

Need A Bulb? - Light bulbs for the building maintenance and construction industries

Post Reply