auto_order.vm
The auto order template is a conditional template that fires at the end of the data collection process if the customer has purchased one or more items that are customer selectable auto orders.
info
Transcluded from Screen Interface Intro.
Form Legend
:tick: → form field
:green-star: → submit button
$form variables for template auto_order.vm
| Name | Type | Formal Syntax | Form Data? | Required on Post? | Comments/Sample Usage |
|---|---|---|---|---|---|
company | string | $form.company | |||
errors | [Array](../storefront-object-model/array-sfo.md) of [Errors](../storefront-object-model/error-sfo.md) | $form.errors | see Error, see errors.vm | ||
infoMessages | [Array](../storefront-object-model/array-sfo.md) of string | $form.infoMessages | see Message, see info_messages.vm | ||
items | [Array](../storefront-object-model/array-sfo.md) of [Value Object](../storefront-object-model/valueobject-sfo.md) Fields in this object:string autoOrderId string schedule string itemId string quantity string description string amount [Array](../storefront-object-model/array-sfo.md) of [Value Object](../storefront-object-model/valueobject-sfo.md) optionsFields in options object: string namestring value [Array](../storefront-object-model/array-sfo.md) of strings schedules | $form.items | :tick: | Loop through the array, and display a label and select box for each item. The select box options are the schedules. The form field is schedule. See form collections for help. #foreach($item in $form.items)$item.autoOrderId$item.quantity#foreach($schedule in $item.schedules)<option>$!schedule</option>#end#endThis collection is a collection of all the customer selectable items purchased by the customer. The schedule is the desired frequency. This will be "Monthly" or "Weekly", etc. The options field is a collection of Item Options associated with this item. If $form.showOptions is true, just display the options to help the customer understand what each item is. | |
showOptions | boolean | $form.showOptions | If any of the items have options, this will be true, notifying you to display the options so the customer has a clear understanding of what each item is. Imagine a customer buying 3 shirts, all of which have an option for color. Displaying that color option will help the customer select the proper schedule for each shirt instead of having to guess which of the 3 items he/she has purchased is the "red shirt". |
<form action="/checkout/autoOrderSave.do" method='post'>
#foreach($item in $form.items)
#set($itemIndex = $foreach.index)
<!-- set up hidden fields so the items object can be recreated on the server side. -->
<input type='hidden' name="items[$itemIndex].itemId" value="$i18n.escape($!item.itemId)" />
<input type='hidden' name="items[$itemIndex].quantity" value="$i18n.escape($!item.quantity)" />
<input type='hidden' name="items[$itemIndex].description" value="$i18n.escape($!item.description)" />
<input type='hidden' name="items[$itemIndex].amount" value="$i18n.escape($!item.amount)" />
<input type='hidden' name="items[$foreach.index].autoOrderId" value="$item.autoOrderId" />
<!-- Obviously you'll want to format this. This example is devoid of style to make comprehension easier -->
<!-- For this example, we're just dumping Name: Value in a pre tag. -->
<pre>
$i18n.write("checkout.autoOrder.itemIdHeader","Item") : $i18n.escape($!item.itemId)
$i18n.write("checkout.autoOrder.quantityHeader","Qty") : $i18n.escape($!item.quantity)
$i18n.write("checkout.autoOrder.descriptionHeader","Description"): $!item.description
#if($form.showOptions)
#if($item.options.size() > 0)
$i18n.write("checkout.autoOrder.optionsHeader","Options"):
#foreach($option in $item.options)
<input type='hidden' name="items[$itemIndex].options[$foreach.index].name" value="$option.name" />
<input type='hidden' name="items[$itemIndex].options[$foreach.index].value" value="$option.value" />
$i18n.escape($option.name) : $i18n.escape($option.value)
#end ##foreach- item options
#end ## if-item has options
#end ##if-showOptions
$i18n.write("checkout.autoOrder.amountHeader","Amount") : $${i18n.escape($!item.amount)}
$i18n.write("checkout.autoOrder.scheduleHeader","Schedule") : <select name="items[$itemIndex].schedule" class="ucFormField">
#foreach($schedule in $item.schedules)
<option #if($schedule == $item.schedule)selected='selected'#{end} >$schedule</option>
#end </select>
</pre>
#end ##foreach-item
</form>
Flow

Was this page helpful?