Order Contexts
An order context is a configuration which allows you to set up several shopping carts on the same website, e.g. if you want both a Daily and a Weekly cart.
To create and order context:
- Go to Settings > Ecommerce > Orders > Order contexts
- Click New order context in the toolbar
- Name it
- (Optionally) limit it to a specific shop
- Save
Once an order context has been created it can be selected on a shopping cart app, in effect making that cart the context cart. It will function as any other shopping cart, with the exception that you have to include an OrderContext parameter in the cart command used to add products to this cart:
<!-- Simple add to cart with an order context -->
<form method="post">
<input type="hidden" name="ProductId" value="MyProductId" />
<input type="hidden" name="VariantId" value="MyVariantId" />
<input type="hidden" name="OrderContext" value="MyOrderContext" />
<button class="btn btn-primary pull-right" type="submit" name="CartCmd" value="Add">Add</button>
</form>
<!-- With an order context selector -->
<form method="post">
<input type="hidden" name="ProductId" value="MyProductId" />
<input type="hidden" name="VariantId" value="MyVariantId" />
<select name="ordercontext">
<option value="">Default</option>
@foreach (var context in product.GetLoop("OrderContexts"))
{
var contextId = context.GetString("OrderContext.ID");
var contextName = context.GetString("OrderContext.Name");
var isCurrentContext = context.GetBoolean("OrderContext.IsCurrent");
<option value="@contextId" selected="@isCurrentContext">@contextName</option>
}
</select>
<button class="btn btn-primary pull-right" type="submit" name="CartCmd" value="Add">Add</button>
</form>