Woocommerce dynamic variation prices
-
Hello,
I have a question that I’ve been struggling with for hours, I’m sure you’ll be able to help me.
Here’s the context :
I developped a website where people can order variable products. But these products have prices that are variable, depending on different parameters that I won’t explain here.
I was able to develop some functions that deal with all this stuff, and everything workds fine.However, when the user is on the product page, when he chooses different options, the price remains the same – until now I had decided to hide the price and it was only showed to the customer after adding the product into the cart. Because my dynamic price calculation was happening on the add to cart event.
Now I’d like to actually show the user what the price will be BEFORE he adds the item to the cart. But in my case, I setup variation prices to a fixes value, always the same.
I was able to locate the jquery function that is triggered when the user chooses the options, and I can see that there’s an ajax call that updates a variable called “variation”. So I’d like to be able to act during this call so that the “variation” variable gets returned with the correct price (and not the one that I put in the beginning).
I tried to add a filter on woocommerce_variation_prices :
I was able to change the value of $transient_cached_prices_array_price_hash and put there the correct price. However my page still displays the former prices and not the ones that I updated.Could you please help me ?
What am I doing wrong ?
Is there another hook that I could use ?Thanks for your help, I’m really stuck…
- The topic ‘Woocommerce dynamic variation prices’ is closed to new replies.