WordPress.org

Support

Support » How-To and Troubleshooting » Add Custome Price in wocommerce Plugin

Add Custome Price in wocommerce Plugin

  • Hello,

    I am creating site using wocommerce plugin of wordpress.

    I want to change my product price for only particular users.
    It will same for all which we provide in product detail.
    But when for only few user add this product into cart ,the price will be change as per my requirement.

    I found some code for that , but don’t know how can I use that and where I put that modification.

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

    Any one can help me. It’s urgent for me.

    Thanks
    Crish

  • The topic ‘Add Custome Price in wocommerce Plugin’ is closed to new replies.