![]() |
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) { 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. |
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. |
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" } } |
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.) |
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. |
Re: IF statement for php file
I have been messing with various files for hours now, but can't seem to figure this out.
|
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.
|
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! |
Re: IF statement for php file
I finally figured it out! Thank you for that little snipit of code Jon. I really appreciate it.
|
Re: IF statement for php file
Glad to hear!
|
Re: IF statement for php file
Now that you've solved this, as there was copyrighted code posted here, I've deleted the code...
|
All times are GMT -8. The time now is 05:17 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.