WooCommerce Code Reference

OrderTraits

OrderTraits class.

Table of Contents

get_item_coupon_amount()  : float
Calculates coupon amount for specified line item/product.
get_item_shipping_amount()  : float|int
Calculate shipping amount for line item/product as a total shipping amount ratio based on quantity.
get_item_shipping_tax_amount()  : float|int
Calculate shipping tax amount for line item/product as a total shipping tax amount ratio based on quantity.

Methods

get_item_coupon_amount()

Calculates coupon amount for specified line item/product.

public get_item_coupon_amount(WC_Order_Item $item) : float

Coupon calculation based on woocommerce code in includes/admin/meta-boxes/views/html-order-item.php.

Parameters
$item : WC_Order_Item

Line item from order.

Return values
float

get_item_shipping_amount()

Calculate shipping amount for line item/product as a total shipping amount ratio based on quantity.

public get_item_shipping_amount(WC_Order_Item $item) : float|int
Parameters
$item : WC_Order_Item

Line item from order.

Return values
float|int

get_item_shipping_tax_amount()

Calculate shipping tax amount for line item/product as a total shipping tax amount ratio based on quantity.

public get_item_shipping_tax_amount(WC_Order_Item $item) : float|int

Loosely based on code in includes/admin/meta-boxes/views/html-order-item(s).php.

Parameters
$item : WC_Order_Item

Line item from order.

Tags
todo

If WC is currently not tax enabled, but it was before (or vice versa), would this work correctly?

Return values
float|int