| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Product options / Add to Cart/ products.tpl vs product.tpl | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
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 |
|||||||
#2
|
|||||||
|
|||||||
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 |
|||||||
#3
|
|||||||
|
|||||||
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 |
|||||||
#4
|
|||||||
|
|||||||
__________________
ex x-cart guru |
|||||||
#5
|
|||||||
|
|||||||
funkydunk, I have emailed you. Could you please confirm if you recieved my email or not.
Thanks in advance Dan Winchester |
|||||||
#6
|
|||||||
|
|||||||
i have recieved your email
__________________
ex x-cart guru |
|||||||
#7
|
|||||||
|
|||||||
Can you do anything re: what I asked in the email?
|
|||||||
#8
|
|||||||||
|
|||||||||
$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 |
|||||||||
#9
|
|||||||
|
|||||||
Code:
__________________
ex x-cart guru |
|||||||
#10
|
|||||||||
|
|||||||||
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); |
|||||||||
|
|||
X-Cart forums © 2001-2020
|