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)
-   -   IF statement for php file (https://forum.x-cart.com/showthread.php?t=41450)

BodyBalance 07-30-2008 10:14 AM

IF statement for php file
 
Hi everyone,

I am trying to get my cart to direct to a certain page depending on which category once the add to cart button is clicked.

For example:

If customer is in category 1 and they click add to cart, they will be redirected to category 3

If they are in category 4, they will be redirected to category 5.

This is add_all_to_cart.php (BCSE mod)

Currently I have

Code:

if ($categories[cat_num] == 1) {
    func_header_location("home.php?cat=3");}
else {
    func_header_location("cart.php");}


Regardless of what category, this will redirect to cart.php

I have tried all of the following:

if ($cat == "1")
if ($current_category == "1")

Plus several others. Anyone have any idea which refrence I should be using for this? It is driving me nuts.

Jon 07-30-2008 12:11 PM

Re: IF statement for php file
 
It's possible that BCSE's mod doesn't pass a category variable. You can try dumping the variables to the screen to see what's available:

FIND:

if ($categories[cat_num] == 1) {

BEFORE ADD:

var_dump($HTTP_POST_VARS); exit;

Then add to cart.

BodyBalance 07-30-2008 12:15 PM

Re: IF statement for php file
 
This directed me to cart.php and posted the following on a blank page:

array(3) { ["mode"]=> string(12) "add_multiple" ["productid"]=> string(0) "" ["amount"]=> array(5) { [1]=> string(1) "4" [5]=> string(1) "0" [4]=> string(1) "0" [3]=> string(1) "0" [2]=> string(1) "0" } }

Jon 07-30-2008 12:46 PM

Re: IF statement for php file
 
That indicates that BCSE's mod doesn't pass a category value. You'd have to update the form information to use something such as:

<input type="hidden" name="cat" value="{$current_category.categoryid}">
(presuming that the $current_category.categoryid exists.)

BodyBalance 07-30-2008 12:57 PM

Re: IF statement for php file
 
Would I add this in to my add_all_to_cart.php file?

Sorry, I'm not extremely familiar with this.

BodyBalance 07-31-2008 05:59 AM

Re: IF statement for php file
 
I have been messing with various files for hours now, but can't seem to figure this out.

Jon 07-31-2008 08:37 AM

Re: IF statement for php file
 
You would add the code to your .tpl file that contains the BCSE form post. If you post up the files I'll try to help you.

BodyBalance 07-31-2008 08:56 AM

Re: IF statement for php file
 
Here is the BCSE .tpl file

[edited by carpeperdiem to remove copyrighted code]

Let me know if those are the right files. Thanks for the help!

BodyBalance 07-31-2008 11:34 AM

Re: IF statement for php file
 
I finally figured it out! Thank you for that little snipit of code Jon. I really appreciate it.

Jon 07-31-2008 11:37 AM

Re: IF statement for php file
 
Glad to hear!


All times are GMT -8. The time now is 11:19 AM.

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