Coupon Order Total (Ship + Tax)

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
sdlong02
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Mon Jan 19, 2009 2:33 pm

Coupon Order Total (Ship + Tax)

Post by sdlong02 » Tue Apr 27, 2010 2:02 pm

Is there a way to make a coupon calculate the minimum value including shipping + tax costs?

EDIT

If requirement for coupon is 25<

Order is 20, Shipping 4, tax 2, coupon valid.

Or any other random calculation in which the order doesn't meet the minimum requirement without the addition of shipping and tax, but does when S+T is added.

This solution from Mazhar sounded like it was what I was looking for, but I applied this and am still having an issue:

viewtopic.php?f=42&t=12878&start=0&hili ... x+shipping

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

Re: Coupon Order Total (Ship + Tax)

Post by mazhar » Tue Apr 27, 2010 3:01 pm

Can you explain the issue you are facing after applying the mod.

sdlong02
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Mon Jan 19, 2009 2:33 pm

Re: Coupon Order Total (Ship + Tax)

Post by sdlong02 » Tue Apr 27, 2010 4:33 pm

My coupon has a 25$ minimum

Right now my order total is $21.54, so obviously I can't use the coupon. However when I select a shipping method, my order summary naturally recalculates.

My order is now $21.54 + $7.89 = $29.43

However when I try to use the coupon, it still gives me the error: "The coupon code you've entered requires a minimum purchase of $25.00."

I didn't really see anything change once I applied the mod. Just still not functioning the way I was looking for.

sdlong02
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Mon Jan 19, 2009 2:33 pm

Re: Coupon Order Total (Ship + Tax)

Post by sdlong02 » Tue Apr 27, 2010 4:40 pm

Clarification on my last post, when I choose a shipping method, the price updates in the "Order Summary", but not in the actual Order Contents.

Could this be because the shipping method is not added to the basket line items until the order is complete? So even with the mod, the shipping isn't a part of the basket calculation?

Coupon is a fixed ORDER discount with a "Min Purchase" of 25.00. Valid for any product and All Groups.

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

Re: Coupon Order Total (Ship + Tax)

Post by mazhar » Wed Apr 28, 2010 4:32 am

Make a small change in the code of mod and locate

Code: Select all

OrderItemType[] orderItemTypes = new OrderItemType[1]{OrderItemType.Product};
and update it as below

Code: Select all

OrderItemType[] orderItemTypes = new OrderItemType[1]{OrderItemType.Product,OrderItemType.Shipping};
Now again test it and see if it cares for shipping charges as well or not.

sdlong02
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Mon Jan 19, 2009 2:33 pm

Re: Coupon Order Total (Ship + Tax)

Post by sdlong02 » Wed Apr 28, 2010 11:36 am

Here's the code I'm using now:

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, OrderItemType.Shipping };
                    isValidCoupon = Token.Instance.User.Basket.Items.TotalPrice(orderItemTypes) > coupon.MinPurchase;
                }

                if (isValidCoupon)
So far it's still not adding the shipping cost when calculating against the coupon.

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

Re: Coupon Order Total (Ship + Tax)

Post by mazhar » Wed Apr 28, 2010 12:37 pm

I guess you made this change in PaymentPage.ascx.cs file. Did you made same change in ConLIb/CouponDialog.ascx.cs file. If not give a try and update this file as well.

sdlong02
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Mon Jan 19, 2009 2:33 pm

Re: Coupon Order Total (Ship + Tax)

Post by sdlong02 » Fri Apr 30, 2010 6:46 pm

Not sure if I'm doing this right in CouponDialog.ascx.cs, I'm cookie cutting here with minimal understanding of the code so correct me if I'm wrong:

I changed

Code: Select all

if (CouponCalculator.IsCouponValid(Token.Instance.User.Basket, coupon, out couponValidityMessage))
to

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, OrderItemType.Shipping };
                    isValidCoupon = Token.Instance.User.Basket.Items.TotalPrice(orderItemTypes) > coupon.MinPurchase;
                }

                if (isValidCoupon)
And I'm getting this error:

error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Post Reply