Loop Through Basket in Scriptlet
Posted: Fri Oct 29, 2010 2:52 pm
In my store some items (general) can be purchased by anyone, such as a printed user guide, while other items (special) need to generate a permit code with our software product’s serial number.
I want to be able to interrogate the basket on checkout and if there are only general items, go to the one page checkout template; but if there are any special items then force the customer to login.
I tried the following code in a new Scriptlet by using the code from Checkout Page.htm and Checkout Page with Login.htm using a custom checkbox but it did not work. Any ideas?
#foreach($p in $Basket.Product)
#foreach($pcf in $p.CustomFields)
#if($pcf.FieldName == "permitCode")
#if($pcf.FieldValue == "True")
<div class="checkoutPageHeader">
<h1>Checkout</h1>
<div class="content">
We make online shopping convenient and secure! If you need any assistance with the online checkout process, or would rather place your order by phone, please give us a call during regular business hours.
</div>
</div>
<table cellpadding="0" cellspacing="5" width="100%">
<tr>
<td valign="top" width="50%">
[[ConLib:CheckoutLoginDialog]]
</td>
<td valign="top" width="50%">
[[ConLib:CheckoutRegisterButtonDialog]]
</td>
</tr>
</table>
#else
[[ConLib:OnePageCheckout]]
#end
#end
#end
#end
Thanks in advance
I want to be able to interrogate the basket on checkout and if there are only general items, go to the one page checkout template; but if there are any special items then force the customer to login.
I tried the following code in a new Scriptlet by using the code from Checkout Page.htm and Checkout Page with Login.htm using a custom checkbox but it did not work. Any ideas?
#foreach($p in $Basket.Product)
#foreach($pcf in $p.CustomFields)
#if($pcf.FieldName == "permitCode")
#if($pcf.FieldValue == "True")
<div class="checkoutPageHeader">
<h1>Checkout</h1>
<div class="content">
We make online shopping convenient and secure! If you need any assistance with the online checkout process, or would rather place your order by phone, please give us a call during regular business hours.
</div>
</div>
<table cellpadding="0" cellspacing="5" width="100%">
<tr>
<td valign="top" width="50%">
[[ConLib:CheckoutLoginDialog]]
</td>
<td valign="top" width="50%">
[[ConLib:CheckoutRegisterButtonDialog]]
</td>
</tr>
</table>
#else
[[ConLib:OnePageCheckout]]
#end
#end
#end
#end
Thanks in advance