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

IF statement for php file

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-30-2008, 10:14 AM
 
BodyBalance BodyBalance is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 44
 

Default 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.
__________________
Version 4.1.9
Reply With Quote
  #2  
Old 07-30-2008, 12:11 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default 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.
Reply With Quote
  #3  
Old 07-30-2008, 12:15 PM
 
BodyBalance BodyBalance is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 44
 

Default 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" } }
__________________
Version 4.1.9
Reply With Quote
  #4  
Old 07-30-2008, 12:46 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default 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.)
Reply With Quote
  #5  
Old 07-30-2008, 12:57 PM
 
BodyBalance BodyBalance is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 44
 

Default 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.
__________________
Version 4.1.9
Reply With Quote
  #6  
Old 07-31-2008, 05:59 AM
 
BodyBalance BodyBalance is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 44
 

Default Re: IF statement for php file

I have been messing with various files for hours now, but can't seem to figure this out.
__________________
Version 4.1.9
Reply With Quote
  #7  
Old 07-31-2008, 08:37 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default 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.
Reply With Quote
  #8  
Old 07-31-2008, 08:56 AM
 
BodyBalance BodyBalance is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 44
 

Default 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!
__________________
Version 4.1.9
Reply With Quote
  #9  
Old 07-31-2008, 11:34 AM
 
BodyBalance BodyBalance is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 44
 

Default Re: IF statement for php file

I finally figured it out! Thank you for that little snipit of code Jon. I really appreciate it.
__________________
Version 4.1.9
Reply With Quote
  #10  
Old 07-31-2008, 11:37 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: IF statement for php file

Glad to hear!
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 05:14 AM.

   

 
X-Cart forums © 2001-2020