shipping_methods
Returns the available shipping methods (options) for an order
Note: The term Shipping Method has been replaced with Shipping Option in the control panel though the function is still called shipping_methods
.
Example
Uses of shipping_methods
function appear in Skeletal in the cart section (both in cart/includes/shipping_options.template.html
and cart/shopping_cart.template.html
), as well as in product page in products/includes/buying_options.template.html
for the shipping calculator.
The following example is used on the shopping cart page to generate a form input that will allow the customer to select the shipping option they want to use with regards to their order:
[%shipping_methods country:'[@ship_country@]' zip:'[@ship_zip@]'%]
[%param header%]
<form method="post" name="SHsummary" action="[%url page:'checkout'/%]">
[%/param%]
[%param *body%]
<div class="form-group">
<label class="d-block" for="[@id@]">
<input class="float-left" type="radio" onclick="document.SHsummary.submit()" name="ship" value="[@id@]" id="[@id@]" [%if [@id@] == [@shipping_method_id@]%]checked[%/if%]>
<h4> [@shipping_method@] - [%if [@shipping_quote@]%] P.O.A [%else%] [%if [@cost@] == 0%] [%if [@na@] == 0%] [%if [@config:free_shipping_label_for_webstore@]%] [@config:free_shipping_label_for_webstore@] [%else%] Free [%/if%] [%else%] Not Applicable [%/if%] [%else%] [%format type:'currency'%][@cost@][%/format%] [%/if%] [%/if%] </h4>
[%if [@delivery_time@] >= 1%]
<p>Estimated arrival of [%format type:'number' tl_unit:'day' tl_plural:'days'%][@delivery_time@][%/format%]</p>
[%/if%]
<p>[@shipping_description@]<p>
</label>
</div>
[%/param%]
[%param footer%]
</form></td>
</tr>
<tr>
<td>Shipping Cost To Post Code [@ship_zip@]</td>
<td class="text-right">[%format type:'currency'%][@shipping_total@][%/format%]</td>
</tr>
[%/param%]
[%param *ifempty%]
[%if [@ship_zip@]%]
<b class="text-danger">Shipping not available to [@ship_zip@] [@ship_country@], please try another location.</b>
[%else%]
Enter post code to calculate shipping
[%/if%]
</td>
</tr>
[%/param%]
[%/shipping_methods%]
This is the shipping_methods function on the buying_options template:
[%shipping_methods sortby:'delivery_time' sku:'[@sku@]' qty:'[@qty@]' zip:'[@ship_zip@]' country:'[@ship_country@]'%]
[%param *header%]
<br />
<div role="alert" aria-atomic="true" aria-label="Shipping results">
[%/param%]
[%param *body%]
<div role="group" aria-label="Shipping method option">
<hr aria-hidden="true"/>
<strong>[@shipping_method@]</strong> - [%if [@cost@] == 0%] [%if [@na@] == 0%] [%if [@config:free_shipping_label_for_webstore@]%] [@config:free_shipping_label_for_webstore@] [%else%] Free [%/if%] [%else%] Not Applicable [%/if%] [%else%] [%format type:'currency'%][@cost@][%/format%] [%/if%] [%IF [@delivery_time@]%](ETA: [@delivery_time@] days)[%/ IF%]<br />
<i class="text-muted">[@shipping_description@]</i>
</div>
[%/param%]
[%param *footer%]
</div>
[%/param%]
[%param *ifempty%]
[%if [@ship_zip@]%]<br /><p class="alert alert-danger alert-shipping-error" aria-label="alert" role="alert" aria-atomic="true">Shipping not available to [@ship_zip@] [@ship_country@], please try another location.</p>[%/if%]
[%/ param%]
[%/shipping_methods%]
Usage
The shipping_methods function can be used in a few different ways. As per the two examples above, it can be used to select the preferred shipping option for an order on the cart/checkout pages, or as a shipping calculator for an individual item on their product page.
Parameters
Name | Options | Description |
---|---|---|
ship_mode:'' |
b , s , m |
Refers to the checkout option, b for shipping to Billing, s for shipping to a different address and m for shipping to multiple addresses |
addr_id:'' |
Integer | ID of customer's saved shipping address. Can be used to break down that information with multiple sub-components |
country:'' |
String | Shipping country, if no country is specified, the site's default country code will be used. Use the two character country code |
limit:'' |
Integer | List limit for number of shipping options returned |
noduplicate:'' |
0 /1 |
If there are more than one Shipping Option with the same name, only one will be displayed. If the results are sorted by lowest to highest cost, the only the cheapest option will display |
ship_method:'' |
Integer | ID number of a selected Shipping Option. Only this Shipping Option will be returned |
showhidden:'' |
0 /1 |
If set to 1 , Shopping Options with Visible to Customer set to No will be returned |
showna:'' |
0 /1 |
If set to 1 only non-applicable shipping options will be returned |
zip:'' |
String | Shipping zip/postcode |
city:'' |
String | Shipping city |
state:'' |
String | Shipping state |
sku:'' |
String | SKU of product. Only used when quoting shipping on a single product |
qty:'' |
Integer | Quantity of product. Only used when quoting shipping on a single product |
ship_express:'' |
0 /1 |
When set to 1 , displays Shipping Options that have Method Type set to Expedited. Setting to 0 displays Shipping Options with both method types |
ship_priority:'' |
0 /1 |
Whether or not priority shipping is active. If set to 1 , only shipping options with Service Level set to Priority will be returned |
routing_sortby:'' , sortby:'' |
actual_cost , sortorder , delivery_time |
Selects the shipping option sort order |
*header |
HTML & b@se tags | Renders a single usable space above the body |
*body |
HTML & b@se tags | Runs an array for each option in the tag |
*footer |
HTML & b@se tags | Renders a single usable space below the body |
ifempty:'' , *ifempty |
HTML & b@se tags | If the shipping_methods returns no results, it'll load this block instead |
Data Tags (body)
Name | Shipping Option Field | Example | Options |
---|---|---|---|
[@actual_cost@] |
Shipping Cost | 10.00 | Price from the Shipping Option |
[@cost@] |
– | 7.00 | The calculated shipping cost after discounts and overrides |
[@count@] |
– | 0 | Count of the shipping options displayed - starting at 0 |
[@daily_close_time@] |
Delivery Cut Off Time | 17:00:00 | This is the cut off time to accept on order using this shipping option. This is normally used when offering same day delivery - 24 hour time (HH:MM:SS). If no time set, returns 00:00:00 |
[@delivery_date@] |
– | 2018-09-15 | The estimated delivery date based on the Shipping Option Delivery Availability settings on the Shipping Option and the Delivery Time on the rates table (YYYY-MM-DD) |
[@delivery_time@] |
– | 2 | Recommend delivery days after shipping. This value comes from the Delivery Time field on the rates table |
[@exc_vacation_group_id@] |
Delivery Not Available On | 2 | ID number if the Date Group that lists days that the delivery can't be made. For example, on public holidays |
[@expedited@] |
Method Type | n | Deprecated. n - Standard, y - Expedited |
[@id@] |
ID | 16 | Shipping Option ID number |
[@na@] |
– | 0 | Displays 1 if this shipping option is not applicable for this order. This field will only display 1 if showna:'1' is set in the parameters |
[@nosortorder@] |
– | 1 | If the [@sortorder@] field is 0 then this tag will return 1 . If the [@sortorder@] field has a value greater than 0 , then this will be 0 |
[@pickup@] |
Pickup/Delivery | 0 | Is this shipping option for pickup or delivery? 0 - Delivery Only, 1 - Pick Up Only |
[@priority_dispatch@] |
Service Level | n | Deprecated. n - Normal, y - Priority |
[@sh_group_routing@] |
Routing Group | 1 | Group Shipping Options together so the cheapest one is the default option |
[@shipping_cost@] |
– | 7.00 | Calculated shipping cost |
[@shipping_description@] |
Description | Air delivery Australia wide | Shipping option description |
[@shipping_method@] |
Name | Express Shipping | Shipping Option name |
[@sortorder@] |
Sort Order | 20 | The order shipping options are displayed, as set by the merchant in the control panel. Ascending (lowest first) |