Page 1 of 1

Loop Through Basket in Scriptlet

Posted: Fri Oct 29, 2010 2:52 pm
by dale.jones
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

Re: Loop Through Basket in Scriptlet

Posted: Mon Nov 01, 2010 8:18 am
by plugables
I would suggest not to do this in scriptlets. Its going to be a performance killer. Scriptlets should not be used for the purpose of handling programming logic. You can easily write a custom conlib control for this purpose. Scriptlets are mainly suitable layout control of the page. If you embed a lot of programing logic in them they are going to slow down your web-pages.