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

Product options / Add to Cart/ products.tpl vs product.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-01-2003, 04:22 PM
 
5circles 5circles is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Kirkland, Washington, USA
Posts: 34
 

Default Product options / Add to Cart/ products.tpl vs product.tpl

I've been trying to make Add to Cart work properly with product options and having lots of trouble. I thought that I could take some of the code from product.tpl (which is used to display all the information from a single product) and simply add it to products.tpl (which displays multiple products) but this doesn't work. The underlying problem seems to be that I don't have access to the $product_options array in products.tpl, and I can't figure out how to get it there - so that the include of customer_options.tpl will work as it should. I think it comes down to my lack of knowledge about using mySQL data in the Smarty templates, and also my limited understanding of the relationship between the PHP and TPL files. My last (failed) AHA was to look at products.php and product.tpl to see if I could move a few things over. No luck.

I'm running 3.3.6, and reluctant to try to move to a later version until I can get this one live.

Thanks
Mike
Reply With Quote
  #2  
Old 09-11-2003, 10:58 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

This is a very difficult mod to make (especially to a new xcarter).

An easier option might be to copy the code from the new version of xcart, in particular skin1/customer/main/buy_now.tpl which basically skips around the issue.

If you really want product options in the listing give me a shout for the mod.
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 09-12-2003, 12:07 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default

Funkydunk - I would like this option too. I am running version 3.44 and I need to make the product options from the main product page (product.tpl?) display on the products page with the small thumbnails (products.tpl?).

If you could post the code for me then I would be very grateful

I will email you if that's ok.

Thanks in advance Dan
Reply With Quote
  #4  
Old 09-12-2003, 12:35 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

http://www.funkydunk.net/xcart.php
__________________
ex x-cart guru
Reply With Quote
  #5  
Old 09-15-2003, 05:55 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default

funkydunk, I have emailed you. Could you please confirm if you recieved my email or not.

Thanks in advance

Dan Winchester
Reply With Quote
  #6  
Old 09-15-2003, 05:59 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

i have recieved your email
__________________
ex x-cart guru
Reply With Quote
  #7  
Old 09-15-2003, 06:05 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default

Can you do anything re: what I asked in the email?
Reply With Quote
  #8  
Old 10-11-2003, 11:02 AM
  kangus's Avatar 
kangus kangus is offline
 

Senior Member
  
Join Date: Feb 2003
Posts: 160
 

Default $product_options[?]

I need to make messages appear based on an option being selected;
Auto-Ship option Yes or No (1 or 0)
I can see the code that displays the selected options but how do I test:
$product_options[Auto-Ship][?] For 1 or 0 ?
Thanks
Reply With Quote
  #9  
Old 10-11-2003, 11:44 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Code:
{if $product_options[Auto-Ship] eq "1"} do this {elseif $product_options[Auto-Ship] eq "0"} do something else {else} dp something totally different {/if}
__________________
ex x-cart guru
Reply With Quote
  #10  
Old 10-12-2003, 04:57 PM
  kangus's Avatar 
kangus kangus is offline
 

Senior Member
  
Join Date: Feb 2003
Posts: 160
 

Default In /skin1/customer/main/cart.tpl

This
{if $product_options[AutoShip] eq "1"}
Never Return true
The below works if the first produt has the first option set to AutoShip
{if $cart.products.0.options.0.optclass eq 'AutoShip'}
{if $cart.products.0.options.0.optionindex eq 1}

Auto Shipping has been scheduled for this Product

{/if}
{/if}
(Thanks to the forum at http://www.phpinsider.com/smarty-forum for the smarty.php mod which allowed me to see all arrays in my cart.)

The Option AutoShip can be Yes or No (1/0)
The option array is:
$option=array(optclass=>"AutoShip",optionindex=>0) ;
$options is a array of:
$options = array();
$options[]=$option;
$option['optclass']='Cover';
$option['optionindex']='Hard';

print_r( $options);
Array ( [0] => Array ( [optclass] => AutoShip [optionindex] => 0 ) [1] => Array ( [optclass] => Cover [optionindex] => Hard ) )

So to find and count all products that have an AutoShip option set to yes get ugly...
(I used this instead of a generic parse the entire $cart function)

$AutoCnt=0;
foreach($products as $pkey=>$pvalue)
{
if(is_array($pvalue))
{
$opt=$products[$pkey]['options'];
foreach($opt as $okey=>$ovalue)
{
if(is_array($ovalue))
{
foreach($ovalue as $ekey=>$evalue)
{
if($evalue=='AutoShip')
{
extract($ovalue);
if($optionindex==1) $AutoCnt++;
}
}
}
}
}
}
print('
AutoCount-> '.$AutoCnt.'
');
//Add the count of Auto Shipping products to the cart - MOD
$products['autocnt']=$AutoCnt;
print_r($products);
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 08:16 PM.

   

 
X-Cart forums © 2001-2020