Skip to content
  1. Extras
  2. MiniShop3
  3. Snippets
  4. msOrderTotal

msOrderTotal

Snippet for cart and order totals. Used for mini-cart in the site header.

Caching

The snippet uses the user session and must be called uncached (!msOrderTotal).

Parameters

ParameterDefaultDescription
tpltpl.msOrderTotalLayout chunk
returntplFormat: data (array), tpl (chunk output)

Default chunk

Chunk tpl.msOrderTotal is not shipped with the component. Create your own or use return=data.

Examples

Get data

fenom
{set $total = '!msOrderTotal' | snippet: ['return' => 'data']}

{if $total.total_count > 0}
    In cart: {$total.total_count} items, {$total.cart_cost} total
{/if}

Header mini-cart

fenom
{set $cart = '!msOrderTotal' | snippet: ['return' => 'data']}

<a href="/cart/" class="header-cart">
    <span class="cart-icon">🛒</span>
    <span class="cart-count" data-ms-cart-count>{$cart.total_count}</span>
    <span class="cart-total" data-ms-cart-total>{$cart.cart_cost}</span>
</a>

With chunk

fenom
{'!msOrderTotal' | snippet: [
    'tpl' => 'tpl.myMiniCart'
]}

Data structure

The snippet returns an array with cart/order totals:

FieldDescription
costTotal to pay (products + delivery + payment fee)
cart_costProducts cost
delivery_costDelivery cost
payment_costPayment method fee
total_countTotal item count
total_costProducts cost (same as cart_cost)
total_weightTotal weight
total_discountDiscount amount
total_positionsNumber of lines (unique products)