Postage amount for cart

The postage Smarty block retrieves the postage amount of the current cart if it exists.

Thelia uses the following rules to select the country :

  • the country of the delivery address of the customer related to the cart if it exists
  • the country saved in cookie if customer have changed the default country
  • the default country for the shop if it exists

The loop selects the cheapest delivery for this country.


Inside the postage block this variables are defined :

  • $country_id: the country id or null
  • $delivery_id: the delivery id or null
  • $postage: the postage amount or 0.0
  • $is_customizable: indicate if the postage can be customized. False When customer is signed and have a valid delivery address

An implementation for the default front office template


    {assign var="postageAmount" value=$postage }
        <td class="product" colspan="2">
            <form action="{url path="/cart/country"}" class="form-inline" method="post">
                    {intl l="Estimated shipping "}
                    {if $is_customizable == false}
                        {loop type="country" name="countryLoop" id="$country_id"}
                        {intl l="for"} {$TITLE}
                {if $is_customizable}
                    <label for="cart-country">{intl l="Select your country:"}</label>
                    <select id="cart-country" name="country">
                    {loop type="country" name="countryLoop" with_area="true"}
                        <option value="{$ID}" {if $ID == $country_id }selected="selected" {/if}>{$TITLE}</option>
                    <a class="btn btn-change-country" href="#"><i class="icon-refresh"></i> {intl l="update"}</a>
                {if $delivery_id != 0 }
                    {intl l="with:"} {loop type="delivery" name="deliveryLoop" id=$delivery_id}{$TITLE} {/loop}
                <div class="alert alert-danger">
                    {intl l="No deliveries available for this cart and this country"}
        <td class="unitprice">{$postage} {currency attr="symbol"}</td>
        <td class="qty">-</td>
        <td class="subprice">{$postage} {currency attr="symbol"}</td>
        <td colspan="3" class="empty">&nbsp;</td>
        <th class="total">{intl l="Total"}</th>
        <td class="total">
            <div class="total-price">
                {assign var="totalAmount" value={cart attr='total_taxed_price_without_discount'} + $postageAmount }
                <span class="price">{$totalAmount} {currency attr="symbol"}</span>


And the associated javascript to trigger the form submission. It allows the customer to change the default country. His choice is saved in a cookie by the Front\Controller\FrontCrontroller::changeCountry method.

            var $form = $(this).parents('form');