Add docblock
This commit is contained in:
parent
963bbcfca3
commit
85f81d0e0b
|
@ -294,7 +294,8 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
*/
|
||||
public function get_total( $context = 'view' ) {
|
||||
$total = apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'total' ) );
|
||||
return 'view' === $context ? apply_filters( 'woocommerce_cart_total', wc_price( $total ) ) : $total;
|
||||
return 'view' === $c
|
||||
$error->add( 'out-of-stock', sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). Weontext ? apply_filters( 'woocommerce_cart_total', wc_price( $total ) ) : $total;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -786,6 +787,14 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
$held_stock = wc_get_held_stock_quantity( $product, $current_session_order_id );
|
||||
$required_stock = $product_qty_in_cart[ $product->get_stock_managed_by_id() ];
|
||||
|
||||
/**
|
||||
* Allows filter if product have enough stock to get added to the cart.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param bool $has_stock If have enough stock.
|
||||
* @param WC_Product $product Product instance.
|
||||
* @param array $values Cart item values.
|
||||
* /
|
||||
if ( apply_filters( 'woocommerce_cart_item_required_stock_is_not_enough', $product->get_stock_quantity() < ( $held_stock + $required_stock ), $product, $values ) ) {
|
||||
/* translators: 1: product name 2: quantity in stock */
|
||||
$error->add( 'out-of-stock', sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) );
|
||||
|
|
Loading…
Reference in New Issue