Checkout template, checkout/checkout.liquid, is used for placing orders.
- Using a different template for checkout It is quite common that the checkout uses a minimal header and footer that differs from the rest of the site. This is done, for example, by creating a separate layout file and in the top of the
checkout.liquidspecifying the name of the layout file to be used,{% layout 'checkoutLayout' %}. - B2C and B2B Shop settings has toggles for both B2B and B2C which comes in handy if wanting to build a theme for both B2B and B2C. The shop object is reached with
{{ shop }} - Checkout form The system has a specific checkout form
{% form 'checkout' class:"checkout-form", nonce:nonce %}<content>{% endform %} - Objects There are mainly two template objects to interact with in the checkout: the cart,
{{ cart }}, and the checkout form,{{ form }}, if using the form object it needs to be inside the form tags or the form needs to be rendered before.
B2C and B2B settings
Shop settings has a toggle for B2C and B2B, shop.settings.b2b, that can be accessed when working with themes. For example in business to consumer, B2C, purchases are usually more legally protected and can need processes such as an easy order withdrawal. Whereas in B2B information about the company, such as legal name and VAT number needs to be collected.
{% if shop.settings.b2b %}
<h3 class="text-base font-bold mb-1">{{ 'Company information' | t }}</h3>
<label class="floating-label">
<span>{{ 'Company name' | t }}</span>
<input class="input input-md w-full" type="text" name="vatAddress[company]" value="{{form.vatAddress.company}}"/>
</label>
<label class="floating-label mt-2">
<span>{{ 'VAT number' | t }}</span>
<input class="input input-md w-full" type="text" name="vatAddress[number]" value="{{form.vatAddress.number}}"/>
</label>
{% endif %}
Checkout form
{% form 'checkout' nonce:nonce %}{% endform %}
The checkout form object ,{{ form }}, includes billing and shipping addresses, shipping values along with discounts and total amounts for the cart.
Checkout form
{% form 'checkout' class:"checkout-form", nonce:nonce %}{% endform %}
| Property | Description |
|---|---|
| form.billingAddress | Billing address |
| form.country | Country code |
| form.currency | Checkout currency |
| form.discounts | Discounts |
| form.email | Customer email address |
| form.gatewayId | Payment gateway Id |
| form.providers | List of payment providers |
| form.shipping | Chosen shipping with properties |
| form.shippingAddress | Customer shipping address |
| form.shippingCost | Shipping cost |
| form.shippingId | Id on shipping |
| form.shippingTax | Tax amount on shipping |
| form.shippingTaxRate | Taxrate on shipping |
| form.shippings | List of possible shippings and their properties |
| form.subTotal | Total without tax |
| form.taxRate | Taxrate in presentage |
| form.totalAmount | Total amount |
| form.totalTax | Total amount of tax |
Inside the form you can print all the properties with
{{ form | print_r }}
Shipping cost fields
| Value | Description | Example |
|---|---|---|
| form.shipping.cost.total | delivery+handling + taxes | |
| shipping.cost.deliveryTax | tax amount on delivery fee | |
| shipping.cost.handlingTax | tax amount on handling fee | |
| shipping.cost.deliveryTaxRate | tax rates in percent on delivery fee | |
| shipping.cost.handlingTaxRate | tax rates in percent on handling fee |
Checkout component
The checkout component can be used in the checkout template to listen on change events originating from the country selector, shipping address or payment gateway and reloads the checkout template. You must include the cart.id either in a form attribute or as a hidden input value.