Discount_With_Calculated_Subtotal
Trait for calculating the subtotal of a cart or order.
Tags
Table of Contents
- get_cart_subtotal() : float
- Get the appropriate subtotal used to determine the dynamic discount amount generated by the fixed price.
- get_order_subtotal() : float
- Get the appropriate subtotal used to determine the dynamic discount amount generated by the fixed price.
Methods
get_cart_subtotal()
Get the appropriate subtotal used to determine the dynamic discount amount generated by the fixed price.
private
get_cart_subtotal(WC_Cart $cart) : float
- If the discount applies to all products, then the subtotal of the cart is used.
- If the discount applies to specific products, then the subtotal of those products combined is used.
- If the discount applies to specific categories, then the subtotal of the products in those categories combined is used.
The subtotal also needs to take into account whether prices include tax.
Parameters
- $cart : WC_Cart
-
The cart.
Return values
float —The subtotal.
get_order_subtotal()
Get the appropriate subtotal used to determine the dynamic discount amount generated by the fixed price.
private
get_order_subtotal(WC_Order $order) : float
- If the discount applies to all products, then the subtotal of the order is used.
- If the discount applies to specific products, then the subtotal of those products combined is used.
- If the discount applies to specific categories, then the subtotal of the products in those categories combined is used.
The subtotal also needs to take into account whether prices include tax.
Parameters
- $order : WC_Order
-
The order.
Return values
float —The subtotal.