X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Coupon box on final page of Checkout (https://forum.x-cart.com/showthread.php?t=37548)

balinor 02-13-2008 10:41 AM

Coupon box on final page of Checkout
 
One of the things I have always hated about the discount coupon in X-Cart is that it is on the cart page. This causes a ton of problems when you are trying to give free shipping or 'per customer' discounts, as the customer needs to be logged in to use these. So today I simply tried adding the discount coupon code to the checkout page, and low and behold, it almost works! A few tweaks to the code and you can have it working this way too.

NOTE: I have not fully tested this, as we are using a custom checkout so I can't verify if this works on a stock install. Make backups first and test it out for yourselves. THIS WILL NOT WORK WITH FAST LANE CHECOKUT

1. First, you'll need to move the discount code from cart.tpl to checkout.tpl. Open up customer/main/cart.tpl and comment out this, and then copy it to your clipboard:

Code:

{if $cart.coupon_discount eq 0 and $products ne ""}
<p />
{if $active_modules.Discount_Coupons ne ""}
{include file="modules/Discount_Coupons/add_coupon.tpl}
{/if}
{/if}


Then open up customer/main/checkout.tpl and paste the code in where you want it to appear. It is important that you put this outside of any other forms on that page, as you can't have a form inside a form.

2. Next you'll need to edit modules/Discount_Coupons/discount_coupons.php and change the redirect. So find two instances of this on line 83 and 88:

func_header_location("cart.php");

and replace with this:

func_header_location("cart.php?mode=checkout");

Again, I have not fully tested this, but this was done on a 4.1.8 version, so test it out for yourselves and report back here with your findings. The templates for Fast Lane Checkout will be different, and as I don't work with that module I can't tell you what they are. Perhaps some other kind soul will get this working for that module as well.

cflsystems 02-13-2008 04:06 PM

Re: Coupon box on final page of Checkout
 
Hey balinor,

That was bodering me too. Very nice and clean solution. Thanks for posting it. I did try it on my test site and it seems to work fine. I put the code between the cart and payment method selector. The coupon was applied with the correct amount and everything. Even when I went back to "View Cart" after applying the coupon, the cart was showing the amouth as discounted as I think it should. I also tested it with adding more products, changing the quantity in the cart, removing items from the cart... it was changing the discount number accordingly. The test checkout went fine and order was placed with the discount. So I thing it works the way you have it. At least for what I've checked.
One thing though - I just saw that after a coupon is applied the cart table listing the products also lists the coupon discount for each product but the title on the table, the label "discount" under subtotal, and on the invoice doesnt show how much is the discount. Not the amount taken off but the coupon itself - 5%, or $5, ... Is there any way to show this? Now customers will only see that there is a discount applied but they will have no idea what kind of discount.

balinor 02-13-2008 04:14 PM

Re: Coupon box on final page of Checkout
 
Hmmm...that shouldn't have anything to do with this mod, I'm guessing that is default X-Cart behavior. Let me see if I can find a fix, as it should work just like the cart summary.

cflsystems 02-13-2008 04:21 PM

Re: Coupon box on final page of Checkout
 
Maybe my question was confusing the way I put it here. Here is what I meant (from my test order):

Subtotal: $1,013.96
Coupon saving (aaa): $50.70
Discounted subtotal: $963.26
Shipping and handling: $19.80
Sales Tax 7.00%: $68.81
Total: $1,051.87

Is there any way to have "Coupon saving (aaa): $50.70" to show like this
Coupon saving (5%): $50.70 or Coupon saving (aaa-5%): $50.70

Right now is showing only the coupon name as setup by the admin. I hope this now is more clear.
Oh and yes this has nothing to do with your mod. Just something I saw now.

balinor 02-13-2008 04:26 PM

Re: Coupon box on final page of Checkout
 
Ah, I'm sure there is a way to do that, just don't have time to figure it out at the moment :)

cflsystems 02-13-2008 04:34 PM

Re: Coupon box on final page of Checkout
 
That's perfectly fine. Whenever you get a minute or so :) Thanks

wardworth 02-22-2008 05:07 AM

Re: Coupon box on final page of Checkout
 
Hi,

Has anyone got this working with fast lane checkout yet? I've modified all the relevant files and changed the redirect, but when I click on 'submit' on the redeem coupon (i've placed it after payment method) it does nothing. Clicking on the continue button below this takes me back to cart contents for some reason.

Any ideas?

balinor 02-22-2008 07:53 AM

Re: Coupon box on final page of Checkout
 
You'd need to change the redirect to whatever the page the coupon is on. I don't use Fast Lane so I don't know what that is.

wardworth 02-29-2008 01:20 AM

Re: Coupon box on final page of Checkout
 
I don't quite understand what you mean in regards to the redirect. I'm moving the discount coupon to the checkout_2_method.tpl in fast lane checkout, but this is still cart.php?mode=checkout in the url. Is that right?

wardworth 02-29-2008 01:29 AM

Re: Coupon box on final page of Checkout
 
I've just tried changing it to cart.php?mode=checkout and the coupon submit button still doesn't work (javascript problem?), and the continue button just bounces me back to the shopping cart items page.

Can anyone help please?


All times are GMT -8. The time now is 03:12 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.