WooCommerce, Add Product to Cart with different price each time
-
Hello
I have one product in Woo Commerce, lets say MY Product
This product price varies for each user.
Lets say
For User 1, product price is $10
For User 2, product price is $20
For User 3, product price is $30I have multiple number of users, so i dont want to create multiple product for each user.,
Please suggest how can i change product price depending on user IDI have checked woocommerce_before_calculate_totals action and it may work for me, but i am not getting how can i change product price based on user ID
Here is action codeadd_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; } }
Also I don’t want to use Variable products
Thank you
Sajid
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘WooCommerce, Add Product to Cart with different price each time’ is closed to new replies.