wordpress - Update custom price woocommerce -
i developing plugin works woocommerce , need update custom price after submit order in checkout page.
question: possible?
i have tried with:
header('location: http://myweb.com/?add-to-cart=477'); // define woocommerce_review_order_after_submit callback function action_woocommerce_review_order_after_submit( ) { $custom_price = 10; // custome price $target_product_id = 477; foreach ( $cart_object->cart_contents $value ) { if ( $value['product_id'] == $target_product_id ) { $value['data']->price = $custom_price; } } } // add action add_action( 'woocommerce_review_order_after_submit', 'action_woocommerce_review_order_after_submit');
thanks.
you have in hook, 1 overridden after calculating totals, have in woocommerce_before_calculate_totals
hook, change add_action
call to:
add_action( 'woocommerce_before_calculate_totals', 'action_woocommerce_review_order_after_submit' );
Comments
Post a Comment