[wcj_order_items_total_weight]

Display total order items weight

Description

[wcj_order_items_total_weight] shortcode displays total items weight for WooCommerce order. If order_id parameter is not set – total order items weight is calculated and displayed for current order. Shortcode is intended to use with PDF Invoices module (e.g. in packing slips template), however actually can be used anywhere, including e.g. emails.

Args

before
(optional) Text to place before the content. If content is empty this argument is ignored.

Default: None
after
(optional) Text to place after the content. If content is empty this argument is ignored.

Default: None
visibility
(optional) Make shortcode results visible to everyone (all), or to admin only (admin).

Default: all
order_id
(optional) The integer ID for an order.

Default: The current order ID, if exists
hide_if_zero
(optional) If set to yes will return empty string instead of numeric zero “0”. Can be used in conjunction with before and after args, so in case the result is zero, the whole content will be hidden.

Default: no

Example #1

Simplest form. This will output Total weight: 0 kg, if order total items weight equals to zero (or all products have no weight set).

[wcj_order_items_total_weight before="Total weight: " after=" kg"]

Example #2

This will hide the whole result, if order’s items total weight equals to zero.

[wcj_order_items_total_weight before="Total weight: " after=" kg" hide_if_zero="yes"]
Accessible through:
  • [wcj_order_items_total_weight]
Tested on WooCommerce 3.5.7 and WordPress 5.1.1
Plugin can be downloaded here. If there are any locked fields in the module, you will need to get Booster Plus to unlock them.

Leave a Reply

Comments

3 Comments

  1. KoolPal March 10, 2019 at 1:11 pm #

    What could cause this?

    A non-numeric value encountered in path\booster-plus-for-woocommerce\includes\shortcodes\class-wcj-shortcodes-orders.php on line 684

    Reply to thread

    Avatar
    • KoolPal March 10, 2019 at 1:19 pm #

      I realized that booster expects product weight to be entered as 0.00 so if I have not added weight for any particular product, I get the above error!

      Can you not handle this in your code?

      Avatar
    • RokasJ March 11, 2019 at 1:14 pm #

      Hi,

      Thank you for letting us know about the issue.

      Best regards,
      Rokas – Support Team

      Avatar