Discount_With_Required_Qty

Provides a method to retrieve the minimum required quantity for the discount to apply.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

cart_meets_products_selection_and_quantity()  : bool
Check whether the cart meets the minimum required quantity for the discount to apply.
get_min_required_qty()  : int
Retrieve the minimum required quantity for the discount to apply.
order_meets_products_selection_and_quantity()  : bool
Check whether the order meets the minimum required quantity for the discount to apply.
cart_has_product_with_required_qty()  : bool
Check if the cart has a product with the required quantity.
order_has_product_with_required_qty()  : bool
Check if the order has a product with the required quantity.

Methods

cart_meets_products_selection_and_quantity()

Check whether the cart meets the minimum required quantity for the discount to apply.

public cart_meets_products_selection_and_quantity(WC_Cart $cart, Discount $discount) : bool
  • If the discount is applicable to all products, the cart must contain the minimum required quantity of any product.
  • If the discount is applicable to specific products, the cart must contain the minimum required quantity of any of the selected products.
  • If the discount is applicable to specific categories, the cart must contain the minimum required quantity of any product in the selected categories.
Parameters
$cart : WC_Cart
$discount : Discount
Return values
bool

get_min_required_qty()

Retrieve the minimum required quantity for the discount to apply.

public get_min_required_qty() : int
Return values
int

order_meets_products_selection_and_quantity()

Check whether the order meets the minimum required quantity for the discount to apply.

public order_meets_products_selection_and_quantity(WC_Order $order, Discount $discount) : bool
  • If the discount is applicable to all products, the order must contain the minimum required quantity of any product.
  • If the discount is applicable to specific products, the order must contain the minimum required quantity of any of the selected products.
  • If the discount is applicable to specific categories, the order must contain the minimum required quantity of any product in the selected categories.
Parameters
$order : WC_Order
$discount : Discount
Return values
bool

cart_has_product_with_required_qty()

Check if the cart has a product with the required quantity.

private cart_has_product_with_required_qty(array<string|int, mixed> $products[, bool|int $custom_additional_qty = false ][, bool $skip_additional_qty = false ]) : bool
Parameters
$products : array<string|int, mixed>

Array of products in the cart.

$custom_additional_qty : bool|int = false

Whether to use the custom additional quantity or not.

$skip_additional_qty : bool = false

Whether to skip the additional quantity or not.

Return values
bool

True if the cart has a product with the required quantity, false otherwise.

order_has_product_with_required_qty()

Check if the order has a product with the required quantity.

private order_has_product_with_required_qty(array<string|int, mixed> $products[, bool|int $custom_additional_qty = false ][, bool $skip_additional_qty = false ]) : bool
Parameters
$products : array<string|int, mixed>

Array of products in the order.

$custom_additional_qty : bool|int = false

Whether to use the custom additional quantity or not.

$skip_additional_qty : bool = false
Return values
bool

True if the order has a product with the required quantity, false otherwise.

Search results