Add get_min_purchase_quantity and max helper

This commit is contained in:
Mike Jolley 2017-02-17 15:52:39 +00:00
parent 846e1ca25c
commit 6201c7e22b
1 changed files with 20 additions and 0 deletions

View File

@ -1680,6 +1680,26 @@ class WC_Product extends WC_Abstract_Legacy_Product {
return sprintf( '%2$s (%1$s)', $identifier, $this->get_name() );
}
/**
* Get min quantity which can be purchased at once.
*
* @since 2.7.0
* @return int
*/
public function get_min_purchase_quantity() {
return 1;
}
/**
* Get max quantity which can be purchased at once.
*
* @since 2.7.0
* @return int Quantity or -1 if unlimited.
*/
public function get_max_purchase_quantity() {
return $this->is_sold_individually() ? 1 : ( $this->backorders_allowed() || ! $this->get_manage_stock() ? -1 : $this->get_stock_quantity() );
}
/**
* Get the add to url used mainly in loops.
*