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

apply_filters('woocommerce_add_to_cart_product_id') is found 3 times:

  • /includes/class-wc-ajax.php line 466
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    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 486
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    $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 826
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    }
     
    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;
    }