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.9.8.1

apply_filters('woocommerce_add_to_cart_sold_individually_quantity') is found 2 times:

  • /includes/class-wc-cart.php line 1170
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    $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 1243
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
             * @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;
    }
     
    /**