woocommerce_add_to_cart_sold_individually_quantity

woocommerce_add_to_cart_sold_individually_quantity

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.8.7.0

apply_filters('woocommerce_add_to_cart_sold_individually_quantity') is found 2 times:

  • /includes/class-wc-cart.php line 1155
    			$cart_item_key = $this->find_product_in_cart( $cart_id );
    
    			// Force quantity to 1 if sold individually and check for existing item in cart.
    			if ( $product_data->is_sold_individually() ) {
    				$quantity      = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $quantity, $product_id, $variation_id, $cart_item_data );
    				$found_in_cart = apply_filters( 'woocommerce_add_to_cart_sold_individually_found_in_cart', $cart_item_key && $this->cart_contents[ $cart_item_key ]['quantity'] > 0, $product_id, $variation_id, $cart_item_data, $cart_id );
    
    				if ( $found_in_cart ) {
    					/* translators: %s: product name */
    					$message = sprintf( __( 'You cannot add another "%s" to your cart.', 'woocommerce' ), $product_data->get_name() );
    
    
  • /src/StoreApi/Utilities/CartController.php line 1178
    			 * @param integer $variation_id Variation ID of the product added to the cart.
    			 * @param array $cart_item_data Array of other cart item data.
    			 * @return integer
    			 */
    			$request['quantity'] = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $request['quantity'], $product_id, $variation_id, $request['cart_item_data'] );
    		}
    
    		return $request;
    	}
    
    	/**