woocommerce_add_to_cart_product_id

woocommerce_add_to_cart_product_id

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

See hook in core

Displaying hooks found in version: woocommerce.9.3.3

apply_filters('woocommerce_add_to_cart_product_id') is found 3 times:

  • /includes/class-wc-ajax.php line 462
    		if ( ! isset( $_POST['product_id'] ) ) {
    			return;
    		}
    
    		$product_id        = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_POST['product_id'] ) );
    		$product           = wc_get_product( $product_id );
    		$quantity          = empty( $_POST['quantity'] ) ? 1 : wc_stock_amount( wp_unslash( $_POST['quantity'] ) );
    		$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
    		$product_status    = get_post_status( $product_id );
    		$variation_id      = 0;
    		$variation         = array();
    
  • /includes/class-wc-cart-session.php line 455
    		$inital_cart_size = count( $cart );
    		$order_items      = $order->get_items();
    
    		foreach ( $order_items as $item ) {
    			$product_id     = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $item->get_product_id() );
    			$quantity       = $item->get_quantity();
    			$variation_id   = (int) $item->get_variation_id();
    			$variations     = array();
    			$cart_item_data = apply_filters( 'woocommerce_order_again_cart_item_data', array(), $item, $order );
    			$product        = $item->get_product();
    
    
  • /includes/class-wc-form-handler.php line 797
    		}
    
    		wc_nocache_headers();
    
    		$product_id        = apply_filters( 'woocommerce_add_to_cart_product_id', absint( wp_unslash( $_REQUEST['add-to-cart'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    		$was_added_to_cart = false;
    		$adding_to_cart    = wc_get_product( $product_id );
    
    		if ( ! $adding_to_cart ) {
    			return;
    		}