How to use Twig-template for method's Explanatory Text?

How to use Twig-template for method's Explanatory Text?

Twig-template allows you to customize method's Explanatory Text depending on the presence of supported variable values such as:
  1. Estimated delivery dates:
    1. "from" - {delivery_from}
    2. "to" - {delivery_to}
  2. Estimated International duties & taxes - {tax_amount}
Allowed tags: if, for.
Filters: default, format_number, replace, round, trim, lower, upper, capitalize, title.
Learn more about Twig-templates.

Example 1:
If there are estimated delivery dates configured for the shipping method you may set Explanatory Text with variables:
Estimated delivery from {delivery_from} to {delivery_to}.

If there are no estimated delivery dates configured for the shipping method you may alter Explanatory Text to:
Delivery within 10 business days. 

The Twig-template will be the following:
  1. {% if delivery_from and  delivery_to %}
  2.     Estimated delivery from {{delivery_from}} to {delivery_to}.
  3. {% else %}
  4.     Delivery within 10 business days.
  5. {% endif %}
Example 2:
If there are estimated international duties & taxes configured for the shipping method you may set Explanatory Text with the variable:
Duties & taxes included - {tax_amount}.

If there are no estimated international duties & taxes got from the carrier for the shipping method you may alter Explanatory Text to:
No duties & taxes included.

The Twig-template will be the following:
  1. {% if tax_amount %}
  2.     Duties & taxes included - {tax_amount}.
  3. {% else %}
  4.     No duties & taxes included.
  5. {% endif %}
You may also combine those variables in a single Twig-template for Explanatory Text:
  1. {% if delivery_from and  delivery_to %}
  2.     Estimated delivery from {delivery_from} to {delivery_to}.
  3. {% else %}
  4.     Delivery within 10 business days.
  5. {% endif %}
  6. {% if tax_amount %}
  7.     Duties & taxes included - {tax_amount}.
  8. {% else %}
  9.     No duties & taxes included.
  10. {% endif %}




    • Related Articles

    • How to add or edit a Shipping Option

      Video: How to Set Up Shipping Options in Calcurates Shipping Options can be added and edited from Shipping Options grid. Shipping Options Grid To see Shipping Options grid you should follow Menu > Shipping Options. There are 10 columns in the ...
    • What is Shipping Option, Method and Service

      Shipping Option — a certain shipping service that the store offers to its customers which is appeared at the checkout with a certain price (rate). The rate of the Shipping Option is calculated according to a certain algorithm that is set up by ...
    • Carriers: display real-time carrier rates from certain carriers

      Overview With Calcurates you can display real-time shipping rates and estimated delivery dates from certain carriers we support by connecting your own carrier accounts (UPS, FedEx, USPS, DHL, Canada Post, Australia Post, Aramex / Fastway and more) ...
    • Table Rates: configure own condition-based methods and rates or emulate carrier’s rates

      Overview Table Rates (they also call it Matrix Rates) is the most flexible and powerful shipping option type. It helps you to build a table of multiple methods and rates using a variety of conditions and calculation algorithms. Table Rates consists ...
    • How to add Table Rates method

      To add a Table Rates method you should click on "+" icon right above the Shipping Methods grid. The "add method" popup will appear. There are 2 tabs in this popup: Method's general settings Method's algorithm settings General settings Shipping Method ...