WooCommerce Code Reference

OrderTraits

OrderTraits class.

Table of Contents

get_item_cart_tax_amount()  : float
Calculate cart tax amount for line item/product.
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_cart_tax_amount()

Calculate cart tax amount for line item/product.

public get_item_cart_tax_amount(WC_Order_Item $item) : float
Parameters
$item : WC_Order_Item

Line item from order.

Return values
float

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[, int $order_items_count = null ][, float $shipping_amount = null ]) : float|int
Parameters
$item : WC_Order_Item

Line item from order.

$order_items_count : int = null

(optional) The number of order items in an order. This could be the remaining items left to refund.

$shipping_amount : float = null

(optional) The shipping fee amount in an order. This could be the remaining shipping amount left to refund.

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[, int $order_items_count = null ][, float $shipping_tax_amount = null ]) : 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.

$order_items_count : int = null

(optional) The number of order items in an order. This could be the remaining items left to refund.

$shipping_tax_amount : float = null

(optional) The shipping tax amount in an order. This could be the remaining shipping tax amount left to refund.

Tags
todo

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

Return values
float|int