woocommerce_stock_amount_cart_item

The WooCommerce woocommerce stock amount cart item hook.

Description

apply_filters( 'woocommerce_stock_amount_cart_item', (number) $wc_stock_amount, (unknown) $cart_item_key ); 

Parameters (2)

0. $wc_stock_amount (number) => wc_stock_amount( preg_replace( "/[^0-9\.]/", '', $cart_totals[ $cart_item_key ]['qty'] ) )
The wc stock amount.
1. $cart_item_key (unknown)
The cart item key.

Usage

To run the hook, copy the example below.
  1. $wc_stock_amount = apply_filters( 'woocommerce_stock_amount_cart_item', $wc_stock_amount, $cart_item_key ); 
  2.  
  3. if ( !empty( $wc_stock_amount ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_stock_amount_cart_item callback 
  2. function filter_woocommerce_stock_amount_cart_item( $wc_stock_amount, $cart_item_key ) { 
  3. // make filter magic happen here... 
  4. return $wc_stock_amount
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_stock_amount_cart_item', 'filter_woocommerce_stock_amount_cart_item', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_stock_amount_cart_item', 'filter_woocommerce_stock_amount_cart_item', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/class-wc-form-handler.php  
  1. $quantity = apply_filters( 'woocommerce_stock_amount_cart_item', wc_stock_amount( preg_replace( "/[^0-9\.]/", '', $cart_totals[ $cart_item_key ]['qty'] ) ), $cart_item_key );