| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
IF statement for php file | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() 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:
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.
__________________
Version 4.1.9 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() 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. |
|||||||||
#3
|
|||||||
|
|||||||
![]() 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" } }
__________________
Version 4.1.9 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() 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.) |
|||||||||
#5
|
|||||||
|
|||||||
![]() Would I add this in to my add_all_to_cart.php file?
Sorry, I'm not extremely familiar with this.
__________________
Version 4.1.9 |
|||||||
#6
|
|||||||
|
|||||||
![]() I have been messing with various files for hours now, but can't seem to figure this out.
__________________
Version 4.1.9 |
|||||||
#7
|
|||||||||
|
|||||||||
![]() 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.
|
|||||||||
#8
|
|||||||
|
|||||||
![]() 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!
__________________
Version 4.1.9 |
|||||||
#9
|
|||||||
|
|||||||
![]() I finally figured it out! Thank you for that little snipit of code Jon. I really appreciate it.
__________________
Version 4.1.9 |
|||||||
#10
|
|||||||||
|
|||||||||
![]() Glad to hear!
|
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|