View Single Post
  #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