Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Pulling my hair out ... Following Coupon Code

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-12-2009, 08:05 PM
 
ZFalcon ZFalcon is offline
 

Newbie
  
Join Date: Sep 2007
Posts: 8
 

Default 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
__________________
Version 4.0.16
Reply With Quote
  #2  
Old 11-12-2009, 11:47 PM
 
ZFalcon ZFalcon is offline
 

Newbie
  
Join Date: Sep 2007
Posts: 8
 

Default 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
__________________
Version 4.0.16
Reply With Quote
  #3  
Old 11-13-2009, 04:11 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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?
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #4  
Old 11-15-2009, 11:56 PM
 
ZFalcon ZFalcon is offline
 

Newbie
  
Join Date: Sep 2007
Posts: 8
 

Default 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
__________________
Version 4.0.16
Reply With Quote

The following user thanks ZFalcon for this useful post:
cflsystems (11-23-2009)
  #5  
Old 11-16-2009, 03:55 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

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

Thanks. I will have to give it a try again
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #6  
Old 11-16-2009, 06:18 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

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

Payment id is saved in the cart. Try $cart["paymentid"]
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote

The following user thanks geckoday for this useful post:
cflsystems (11-23-2009)
  #7  
Old 11-23-2009, 05:35 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 2 users thank cflsystems for this useful post:
01bodyjewellery (03-26-2010), economedical (01-07-2011)
  #8  
Old 02-07-2010, 05:37 PM
 
diviterra diviterra is offline
 

Member
  
Join Date: Nov 2009
Posts: 13
 

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

thanks dudeeeeeeeee!!!!!!!!!!!!!!!
__________________
4.2.3
Reply With Quote
  #9  
Old 03-26-2010, 07:05 AM
 
Freakmode Freakmode is offline
 

X-Adept
  
Join Date: Jun 2003
Location: UK
Posts: 696
 

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

Brilliant - can't believe that this is still missing even in 4.3.1

Thanks again
__________________
X-Cart 4.7.12 (Live)
Redux Template
CDSEO
Reply With Quote
  #10  
Old 12-29-2010, 06:12 AM
 
encorevisions encorevisions is offline
 

Newbie
  
Join Date: Oct 2008
Posts: 8
 

Default 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?
__________________
Version 4.1.10
Add-ons:
X-SpecialOffers
X-Magnifier
X-FancyCategories
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:39 AM.

   

 
X-Cart forums © 2001-2020