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)
-   -   The universal solution "Continue Shopping Button" (https://forum.x-cart.com/showthread.php?t=39603)

xsurf 05-26-2008 10:23 PM

Re: The universal solution "Continue Shopping Button"
 
Well, I finally got around to trying this, and it doesn't work for me, despite having 4.1.9 .
Admittedly, x-cart is installed only as my shopping cart (so the actual "add to cart" button is clicked on from a page outside x-cart, and only then x-cart is entered, directly into the shopping cart) but still I would have thought HTTP_REFERER would contain the correct value?
Yet back_url always ends up being https://www.mysite.com/xcart/cart.php?keep_https=yes

The code I used was
PHP Code:

x_session_register("back_url");
if (
$mode == "add" && strpos($_SERVER['HTTP_REFERER'], "cart.php")>)
{
    
$back_url $_SERVER['HTTP_REFERER'];
}
$smarty->assign("back_url"$back_url); 


And
PHP Code:

<a href="{$back_url}"><img src="{$ImagesDir}/ContinueShopping.gif" border="0" align="absmiddle" alt="Continue Shopping"></img></a


xsurf 05-26-2008 10:33 PM

Re: The universal solution "Continue Shopping Button"
 
Ah, never mind, fixed it! Looks like it's working for me now - I changed
PHP Code:

if ($mode == "add" && strpos($_SERVER['HTTP_REFERER'], "cart.php")>


to

PHP Code:

if ($mode == "add" && (strpos($_SERVER['HTTP_REFERER'], "cart.php") == false)) 


Yurij 05-27-2008 12:34 AM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by xsurf
Ah, never mind, fixed it! Looks like it's working for me now - I changed
PHP Code:

if ($mode == "add" && strpos($_SERVER['HTTP_REFERER'], "cart.php")>


to

PHP Code:

if ($mode == "add" && (strpos($_SERVER['HTTP_REFERER'], "cart.php") == false)) 




PHP Code:

if ($mode == "add" && (strpos($_SERVER['HTTP_REFERER'], "cart.php") == false)) 



similarly

PHP Code:

if ($mode == "add" && (strpos($_SERVER['HTTP_REFERER'], "cart.php") == 0)) 



Because if you want to add conditions when the line does not contain some substring, you should write to verify "strpos($_SERVER['HTTP_REFERER'], "cart.php") === false" result for this function.

xsurf 05-27-2008 12:59 AM

Re: The universal solution "Continue Shopping Button"
 
Hi Yurij, I am not exactly sure what you refer to in your last post (?)
The reason I used "== false" instead of "== 0" is because according to its documentation, strpos returns '0' if the substring was at the start of the string, and what I wanted to achieve is that back_url gets an HTTP_REFERER value only when the referrer is not any of the cart.php pages.

For my purposes, I am actually even debating removing the $mode == "add" condition... With the "mode==add" condition, clicking on "Continue Shopping" leads to the last non xcart page on my site from which the visitor added an item to the cart. Removing that condition, clicking on "Continue Shopping" will (I believe) lead to the last non xcart page on my site which the visitor saw (whether they bought something there or not) before the cart.

EN4U 06-19-2008 11:12 PM

Re: The universal solution "Continue Shopping Button"
 
So has anyone had success with this in newest version. This is a major flaw in xcart design imo. My other sites, different platform than this one, that once a mod was purchased to achieve it, brought up sales allot.....So its a major issue with me that i implement it in my store here.

"Continue Shopping" -- Brings the person back to the area when they added the product.

I have Bill's one page checkout and have asked him on this, he said he has no idea how to make it happen.

Any ideas.....

xsurf 06-20-2008 03:32 AM

Re: The universal solution "Continue Shopping Button"
 
I dont know about 4.1.10 , but it worked for me just fine with 4.1.9 with the code I described

EN4U 06-20-2008 04:08 AM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by xsurf
I dont know about 4.1.10 , but it worked for me just fine with 4.1.9 with the code I described


Awesome... Anyway I can get the completed .tpl for that.

Thanks

Stizerg 06-26-2008 03:51 PM

Re: The universal solution "Continue Shopping Button"
 
Thanks guys! Works on 4.1.10

in Fast_Lane_Checkout/home_main.tpl
HTML Code:

<td><a href="{$back_url}"><img src="{$ImagesDir}/img/continueshopping.png" alt="continue shpopping" /></a>

and in cart.php
PHP Code:

#back URL when cont. shoping:
x_session_register("back_url");
if (
strpos($_SERVER['HTTP_REFERER'], "cart.php") == false)
{
    
$back_url $_SERVER['HTTP_REFERER'];
}
$smarty->assign("back_url"$back_url); 


Well done!

EN4U 06-26-2008 07:10 PM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by Stizerg
Thanks guys! Works on 4.1.10

in Fast_Lane_Checkout/home_main.tpl
HTML Code:

<td><a href="{$back_url}"><img src="{$ImagesDir}/img/continueshopping.png" alt="continue shpopping" /></a>

and in cart.php
PHP Code:

#back URL when cont. shoping:
x_session_register("back_url");
if (
strpos($_SERVER['HTTP_REFERER'], "cart.php") == false)
{
    
$back_url $_SERVER['HTTP_REFERER'];
}
$smarty->assign("back_url"$back_url); 


Well done!



Nice... Only thing that may confuse some is that you will need to make your own "continue shopping" button.... and with the reference above, you'd have to upload it in a folder in "images" called /img/continueshopping.png or what ever name you would want. or as I did, just upload the new button to images and that's it. Then the call would be <img src="{$ImagesDir}/continueshopping.png" alt="continue shopping" /></a>[/html]

The "home_main.tpl" to adjust is in /skin1/modules/Fast_Lane_Checkout (not the other modules folder in root)
The cart.php to add the above code is in your root folder by itself

Be sure to respell shopping(alt) also.....

Works great.. Thanks...

Yurij 06-27-2008 08:07 AM

Re: The universal solution "Continue Shopping Button"
 
It was written in 30 minutes.

Test on the original X-Cart (4.1.9) without any modifications.


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

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