WordPress.org

Ready to get started?Download WordPress

Forums

Add Custome Price in wocommerce Plugin (1 post)

  1. cristopher_elsner
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

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