The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Add Custome Price in wocommerce Plugin (1 post)

  1. cristopher_elsner
    Posted 3 years ago #


    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.


Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by cristopher_elsner
  • This topic is not resolved
  • WordPress version: 3.5.1