Support » Plugin: WooCommerce » Target product in checkout page with a specific type

  • yamenshahin

    (@yamenshahin)


    With this code we can alter the price for all products in the cart.

    add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
    
    function add_custom_price( $cart_object ) {
        $custom_price = 10; // This will be your custome price
        foreach ( $cart_object->cart_contents as $key => $value ) {
            $value['data']->price = $custom_price;
        }
    }

    I need is to alter only products with Specific custom type called ‘auction’ and not change the rest of products.

    https://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    $value['data'] is your product object, so check the type there. e.g. $value['data']->is_type( 'simple' )

Viewing 1 replies (of 1 total)
  • The topic ‘Target product in checkout page with a specific type’ is closed to new replies.