Understanding the Functionality of the Cost Table

(This documentation is associated with the Custom Shipping Methods for WooCommerce plugin.)

In the previous post, we learned how to enable the custom shipping method for WooCommerce. Now, we will learn the functionality of the cost table and how you can use it for different use cases.

Our Custom Shipping Methods for WooCommerce plugin offers advanced cost calculation features that extend beyond the standard WooCommerce shortcodes such as [qty], [cost], and [fee]. With our plugin, you can harness the power of [weight] and [volume] shortcodes to fine-tune your shipping methods.

Exploring the [costs_table] Shortcodes:

The [costs_table] shortcode boasts two essential attributes: ‘prop’ and ‘table.’ The ‘prop’ attribute can be volume, weight, qty, cost, or distance. Meanwhile, the ‘table’ attribute allows you to configure costs based on the ‘prop’ attribute’s value, in the format of ‘min_prop-cost.’

Costs Table by Items Volume:

Items’ volume is calculated by multiplying each item’s width, height, and length. Here’s an example of how you can configure costs based on volume:

     [costs_table prop="volume" table="0-10|50-50|100-125.5"]

This configuration will establish shipping costs as follows:

Volume RangeShipping Cost
0 and below 50$10
50 and below 100$50
100 and above$125.5
This table provides a clear and organized representation of the shipping cost based on volume ranges.

Costs Table by Items Weight:

Items’ weight is fetched from the individual product page. Here’s an example of how you can configure costs based on weight:

[costs_table prop="weight" table="0-10|50-50|100-125.5"]

This example will set costs according to this table:

Weight RangeShipping Cost
0 and below 50$10
50 and below 100$50
100 and above$125.5
This table provides a clear and organized representation of the shipping cost based on weight ranges.

Costs Table by Items Quantity:

[costs_table prop="qty" table="0-20|10-10|20-0"]

This example will set costs according to this table:

Quantity RangeShipping Cost
0 and below 10$20
10 and below 20$10
20 and aboveFree
This table provides a clear and organized representation of the shipping cost based on quantity ranges.

Costs Table by Order Amount #

[costs_table prop="cost" table="0-20|10-10|20-0"]

This example will set costs according to this table:

Order Amount (i.e. Order Cost)Shipping Cost
from 0 and below 1020
from 10 and below 2010
from 20free
This table provides a clear and organized representation of the shipping cost based on total cost of the cart.

Costs Table by Distance #

Distance is calculated the same as in [distance] shortcode. Also, the same attributes (key, default_distance, units, src, debug) are applied.

[costs_table prop="distance" table="0-10|50-50|100-125.5" key="BIzbSyBNBNR9yi3vTgC33oXSpwQftScNSmO-fjc" default_distance="100" units="km"]

* Please note that the key from the example is not a valid key – you need to get your own key here.

This example will set costs according to this table:

DistanceShipping Cost
from 0 and below 50 km10
from 50 and below 100 km50
from 100 km125.5
This table provides a clear and organized representation of the shipping cost based on distance.

Distance-based Cost Calculation

[distance] shortcode has five possible attributes:

  • key – this is a required attribute. The plugin uses Google Distance Matrix API to calculate the distance, so you need to get your API key here. Please note that you need to check “Routes” when getting your key from Google.
  • default_distance – this is the default distance for shipping (in case if customer hasn’t entered his address yet or distance can’t be calculated). Default: 0.
  • units – units in which distance is calculated. Possible values: m for meters (default), km for kilometers, and mi for miles.
  • src – source point (origin). By default, it’s automatically retrieved from your shop’s settings from “WooCommerce > Settings > General > Store Address”. If you wish to set it manually – correct format is: address, city postcode, and country.
  • debug – if set to ‘Yes’, will output debug information in “WooCommerce > Status > Logs”. Default: NO.

[distance] Example #

1.5*[distance key="BIzbSyBNBNR9yi3vTgC33oXSpwQftScNSmO-fjc" default_distance="15" debug="yes" units="km"]

* Please note that the key from the example is not a valid key – you need to get your own key here.

Rounding #

If you need to round some values, you can use 

[round], shortcode, e.g.: #
[round][weight]/100[/round]

[round] shortcode attributes:

  • type – rounding type. Can be updown and normal. Default is normal.
  • precision – rounding precision. Used for normal rounding type only. Sets the number of decimal digits to round to. Default is 2. This is the same parameter as in PHP round() function:
    If the precision is positive, the rounding will occur after the decimal point. If the precision is negative, the rounding will occur before the decimal point. If the absolute value of the precision is greater than or equal to the number of digits, the result of the rounding is equal to 0.

    Empower your WooCommerce store with versatile cost customization using the features mentioned above and enhance the shopping experience for your customers. Don’t hesitate to contact our support team if you require any assistance.

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *