X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Pulling my hair out ... Following Coupon Code (https://forum.x-cart.com/showthread.php?t=50699)

ZFalcon 11-12-2009 08:05 PM

Pulling my hair out ... Following Coupon Code
 
Hi All,

Going totally nuts here trying to customize my coupon to be on a different page. I have searched these forums and read every post that even has the word coupon in it, and while many mention this issue I'm having, not one has a solution. I am a relative novice at this and am doing my best to learn.

Where I am at in following the code and my question...

I have been able to move the location where it asks for a coupon code to just below the final pricing on the checkout page. This works flawlessly in calculating the coupon, but the problem is when a coupon is entered here it redirects to the incorrect page. This would seem pretty simple to fix, but for some reason it isn't in X-Cart.

When I try to "follow the code" I am able to see that {$paymentid} is set when the customer gets to the final checkout page with Fast Lane Checkout (the page labeled "Place Order" where it shows all the items, subtotal, shipping costs, billing address, shipping address, and requests the credit card info.)

Now when someone enters a coupon on that page and clicks submit, if it is a valid coupon it redirects them back one page to the "shipping and payment" page. If they leave the coupon blank entirely and submit, it takes them back to the very first page of "Your Shopping Cart". To clarify, I am referring to the submit with the coupon module (shop/skin1/modules/Discount_Coupons/add_coupon.tpl) not anything from any other element on the page.

I did add something to both the skin1/modules/Fast_Lane_Checkout for both checkout_2_method.tpl and checkout_3_place.tpl to show me the value of {$paymentid}. When someone first goes to the Shipping & Payment page that value is null. After selecting Delivery method and Payment method then clicking on continue, it goes to the checkout_3 page and shows the value of {$paymentid} as 1, which is correct based on my selection. It also shows the variable {$payment_data.paymentid} as the value of 1 at this point.

Here is where it gets even stranger. When a coupon is submitted, it "seems" to set both these values back to null and takes you back to the Shipping and
Payment page. That page shows these fields as null. If prior to entering the coupon I make a duplicate tab of the final page, then enter the coupon code, and go to the duplicate tab and refresh, it still shows {$paymentid} as 1 AND shows the coupon properly applied to the invoice.

If I were able to just get this thing to redirect to the place order page after a coupon is entered it would apparently fix the issue. I feel like a complete idiot that I can't follow the code enough to see where to put some kind of statement to have it go to the final Place Orders page after a coupon is entered.

One other thing that I tried is entering manually the url that the software appears to use to go to the place order page in the first place (see cart.php in the shop/modules/Fast_Lane_Checkout/ folder --- which is the file it uses to determine which page to go to at any time) www.mysite.com/shop/cart.php?paymentid=$paymentid&mode=checkout
this replies by taking me to the Shipping & Payment page with the URL of :
http://www.mysite.com/shop/cart.php?mode=checkout&err=paymentid

This specifically says that paymentid is the error.

What I then did was just replace the $paymentid with the number 1. This worked, but I have no clue where to even place this to force it to go back (and what variable to use instead of $paymentid since that seems to be the issue, that this is somehow, for some reason, set back to null somewhere in this whole process.) The link that works perfectly is : www.mysite.com/shop/cart.php?paymentid=1&mode=checkout

I tried changing the form action="cart.php" to form action="cart.php?paymentid=$paymentid&mode=checkou t" and no luck. I also tried the working line with the paymentid=1 in place of the variable and it still doesn't work.

Anyone - PLEASE help - I have spent over 9 hours total now fighting with something that really should be simple. How do I make the coupon on the last checkout page link back to the same page where the form was submitted?

*note: I did have to refresh the data from the server every time when I go to the place orders screen, so this doesn't appear to be a cache problem on my system.

Thanks in advance for any reply!
~David

P.S. I am on version 4.1

ZFalcon 11-12-2009 11:47 PM

Re: Pulling my hair out ... Following Coupon Code
 
Hi All,

I guess I may end up with some hair left on my head afterall ... because I found the correct place to make the edits, but still can't seem to pass through the $payment variable (I hardcoded in the number 1 since right now we only accept credit cards, and that works as a temporary solution.)

The thread of files to get to this point is :

shop/skin1/modules/Fast_Lane_Checkout/checkout_3_place.tpl
Added the following file, which allows coupon entry (at this point, the variable $paymentid does equal what was selected by the customer in checkout step 2.)

shop/skin1/modules/Discount_Coupons/add_coupon
Posts to cart.php

shop/cart.php
Leads to the next step

shop/modules/Discount_Coupons/discount_coupons.php
File I edited, where I ended up hardcoding in the paymentid=1 but would like to be able to add more payment methods in the future, so still need help!

cart.php?paymentid=1&mode=checkout
What I replaced "cart.php?mode=checkout" with in the discount_coupons.php file so it goes back to the correct page.

The only remaining question! :
Anyone have any idea how to dynamically get the paymentid at this point so it doesn't have to be hard coded as the value of 1? Trying paymentid=$paymentid just leaves the value blank, so for some reason between the top step listed here, where $paymentid does equal whatever the customer selects, and this bottom step, it seems to completely lose any value of $paymentid and makes it null.

Does it need to be passed through from step to step somehow, and if so, how would I do that, or is it stored somewhere as another variable so I can just use that in the URL string? Any help on how to do this would be appreciated!

Thanks!
~David

cflsystems 11-13-2009 04:11 AM

Re: Pulling my hair out ... Following Coupon Code
 
I did try this ones for the FLC without success. Not sure why QT put the coupon box in cart page in the first place. Can you post what you did?

ZFalcon 11-15-2009 11:56 PM

Re: Pulling my hair out ... Following Coupon Code
 
Hi Steve,

There were a couple files I modified.

1) I edited shop/skin1/modules/Fast_Lane_Checkout/checkout_3_place.tpl to include the following (my edits in red) :


Quote:


{include file="customer/main/cart_totals.tpl" link_shipping="Y" no_form_fields=true}
<br /><br />
{* Testing coupon entry here *}
{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}
{* End Test *}
<form action="{$payment_data.payment_script_url}" method="post" name="checkout_form">
<input type="hidden" name="paymentid" value="{$payment_data.paymentid}" />



2) The second step was editing the file shop/modules/Discount_Coupons/discount_coupons.php in two places to reflect the correct func_header_location :



Quote:


if($my_coupon > 0) {
$cart["discount_coupon"] = "";
$cart["coupon_type"] = "";
$top_message['type'] = 'E';
}
func_header_location("cart.php?paymentid=1&mode=checkout");
}
elseif ($mode=="unset_coupons") {
$cart["discount_coupon"]="";
$cart["coupon_type"] = "";
func_header_location("cart.php?paymentid=1&mode=checkout");
}


This is actually where my issue still comes in... the only way I could get this to work was to hard code in paymentid=1 instead of paymentid=$paymentid.

I would prefer to use the value the customer entered for their payment id, but I just can't figure out where that variable is (or why it got reset to null after being entered by the customer) and how to put it in that link above to apply the correct method of payment if more than just one type exists.

Hope this helps, and if you have any ideas on the payment id portion please let me know!

Thanks,
~David

cflsystems 11-16-2009 03:55 AM

Re: Pulling my hair out ... Following Coupon Code
 
Thanks. I will have to give it a try again

geckoday 11-16-2009 06:18 AM

Re: Pulling my hair out ... Following Coupon Code
 
Payment id is saved in the cart. Try $cart["paymentid"]

cflsystems 11-23-2009 05:35 PM

Re: Pulling my hair out ... Following Coupon Code
 
Ok I took it a little bit further because I don't want to force customers to login, register or fillout checkout info just to see how much they can save with the coupon (I know they can do simple math but still...). So I wanted the coupon discount form on cart page and last checkout page.

Thanks to David and Ralph. Here is my customization

1. Open skin1/customer/main/cart.tpl, find
Code:

{include file="modules/Discount_Coupons/add_coupon.tpl"}
and change to
Code:

{include file="modules/Discount_Coupons/add_coupon.tpl" ch_step="0"}

2. Open skin1/modules/Fast_Lane_Checkout/checkout_step_3.tpl, insert the discount coupon code (you can take it from the file above) and change the line with include file to
Code:

{include file="modules/Discount_Coupons/add_coupon.tpl" ch_step="1"}

3. Open modules/Discount_Coupons/discount_coupons.php, find (in 2 places)
Code:

func_header_location("cart.php");
and change to
Code:

if ($ch_step == 1)
 func_header_location("cart.php?mode=checkout&paymentid=".$cart["paymentid"]."&keep_https=yes");
 else
 func_header_location("cart.php");


4. Open skin1/modules/Discount_Coupons/add_coupon.tpl, find
Code:

  <form action="cart.php" name="couponform">
    <input type="hidden" name="mode" value="add_coupon" />

and after it insert
Code:

    <input type="hidden" name="ch_step" value="{$ch_step}" />

5. Open skin1/customer/main/cart_total.tpl, find (in 2 places)
Code:

<a href="cart.php?mode=unset_coupons" alt="{$lng.lbl_unset_coupon|escape}"><img src="{$ImagesDir}/spacer.gif" alt="{$lng.lbl_unset_coupon|escape}" /></a>
and change to
Code:

<a href="cart.php?mode=unset_coupons&ch_step=1" alt="{$lng.lbl_unset_coupon|escape}"><img src="{$ImagesDir}/spacer.gif" alt="{$lng.lbl_unset_coupon|escape}" /></a>

6. Run cleanup.php

diviterra 02-07-2010 05:37 PM

Re: Pulling my hair out ... Following Coupon Code
 
thanks dudeeeeeeeee!!!!!!!!!!!!!!!

Freakmode 03-26-2010 07:05 AM

Re: Pulling my hair out ... Following Coupon Code
 
Brilliant - can't believe that this is still missing even in 4.3.1

Thanks again

encorevisions 12-29-2010 06:12 AM

Re: Pulling my hair out ... Following Coupon Code
 
I'm not sure what I'm missing. I've gone through the steps but I don't have this file modules/Discount_Coupons/discount_coupons.php in my modules?

economedical 01-07-2011 04:31 AM

Re: Pulling my hair out ... Following Coupon Code
 
Works with 4.3.2, couple of templates named slightly different i.e. Step 5. /cart_total(s).tpl plural for some reason.

kurv 02-01-2011 07:56 AM

Re: Pulling my hair out ... Following Coupon Code
 
This did not work on 4.4.2 and I dont know what to change to make it work :)

Thank you for the help

cflsystems 02-01-2011 07:54 PM

Re: Pulling my hair out ... Following Coupon Code
 
Well you have to adjust it for 4.4.x -there is no more ski1 directory and some files may have duplicats in the skin you are using, the code in the php files may be different...

jeremyScott 03-09-2011 01:05 PM

Re: Pulling my hair out ... Following Coupon Code
 
Quote:

Originally Posted by encorevisions
I'm not sure what I'm missing. I've gone through the steps but I don't have this file modules/Discount_Coupons/discount_coupons.php in my modules?


**Update.
Found the file. I was looking in the Skin 1 folder, when I needed to be looking in the root.

kurv 03-09-2011 01:19 PM

Re: Pulling my hair out ... Following Coupon Code
 
Jeremy,

I feel your pain on this one, I had to go to the one page checkout to solve it. It does what I needed and puts the box ON the checkout page.

Also, another bug I found was if you want a coupon to expire on the 9th at midnight, you have to say the 10th. Coupons expire on a DAY date and not a DAY and TIME code. So when the server says it is the 9th.... bam the coupon expires loosing that whole day. Easy enough to fix... but, a pain.

jeremyScott 03-09-2011 01:24 PM

Re: Pulling my hair out ... Following Coupon Code
 
^^realized the midnight issue today as well, took a bit of time to solve that one.
I might have to check out one page checkout, thanks for the heads up Wes.

kurv 04-02-2011 08:14 PM

Re: Pulling my hair out ... Following Coupon Code
 
I think it is COMPLETELY ridiculous that I should have to edit templates to get COUPONS to WORK in 4.4.2.

Qualiteam FIX THIS NOW!!!! This is completely unprofessional!

kurv 04-04-2011 08:27 AM

Re: Pulling my hair out ... Following Coupon Code
 
1 Attachment(s)
Okay, I have calmed down a bit after getting my support ticket replied to... all I will say here is, X-Cart staff, know your software, and spend a little time reading your customers support issues. Please don't send me an image of MY site where I HAVE altered code and tell me I am wrong see here, x-cart already does this. That is VERY frustrating for the customer.

Okay, please just add a coupon form box to the second page of the check out screens in fast lane check out.

If you need to know where I personally would put it? See the image below that you sent me. See the redirect link I added to the cart... put the coupon box right there. It will look nice, I promise!

:D

Fix the problem guys, please....

Jobananas 06-21-2011 02:07 AM

Re: Pulling my hair out ... Following Coupon Code
 
Did anyone fix this for 4.4.2

Seems crazy that the coupon is missed if you go directly to Checkout - the amount of emails we get after a mailshot asking where to enter the code is large.

cflsystems 06-21-2011 04:23 AM

Re: Pulling my hair out ... Following Coupon Code
 
Are you using FLC? Your signature says OPC but coupon form is there - all OPC mods

Freakmode 06-21-2011 04:29 AM

Re: Pulling my hair out ... Following Coupon Code
 
No we use FLC now - we have AC OPC installed but had to turn it off due to X-cart OPC giving away FREE shipping and not charging TAX.

cflsystems 06-21-2011 04:34 AM

Re: Pulling my hair out ... Following Coupon Code
 
Well then you can use the solution in this thread to get the coupon on checkout page, no other way around. It is for different version but it can be fit to 4.4.x for sure

Freakmode 06-23-2011 12:51 AM

Re: Pulling my hair out ... Following Coupon Code
 
Any ideas what file you edit in place of Fast_Lane_Checkout/checkout_step_3.tpl

Can't find this in 4.4

qualiteam 06-23-2011 02:38 AM

Re: Pulling my hair out ... Following Coupon Code
 
Have you checked this template -> "skin/common_files/modules/Fast_Lane_Checkout/checkout_3_place.tpl"?

cflsystems 06-23-2011 05:00 AM

Re: Pulling my hair out ... Following Coupon Code
 
Alex how hard it is for QT to take this free code and make it part of the stock XC distribution? This code has been here for the last 2 years. Why this was not implemented in 4.4.x, specially with stock XC OPC being so buggy, I don't understand. This is a huge hole in the FLC and you guys can't find 15 min to fix it.

JeanB 07-04-2011 02:40 AM

Re: Pulling my hair out ... Following Coupon Code
 
Thanks for this, Steve - Just implemented it on 4.2.3 and thanks to your code, it took 5 minutes to do - and will hopefully make a world of difference! :D

upupcreative 07-06-2011 04:23 PM

Re: Pulling my hair out ... Following Coupon Code
 
i had to switch to fast lane instead of OPC because of all the OPC bugs, and even i couldn't find the place to put the coupon code - it's buried at the bottom of the cart page and if the user goes right to checkout instead of checking in at the cart first, said customer never even sees it.

i've spent DAYS fixing OTHER bugs, problems, etc. - i feel like qualiteam owes me this one. COME ON. i really don't think i should have to go digging through multiple templates just to make a workaround.

julie

NWD 10-17-2011 08:45 AM

Re: Pulling my hair out ... Following Coupon Code
 
Great Post! This was very helpful.


All times are GMT -8. The time now is 05:42 AM.

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