I really wonder if there is a way to regenerate all the native transients for a given product or variation object.
I'm in a case where I display dynamic prices, and everything is fine. But I need to update transients like wc_prices_{id}
in order for it to take into account this new custom price. If not, the first page load is horrible (especially on the shop page displaying several products at a time).
I'm hooking into woocommerce_product_variation_get_price
, woocommerce_product_variation_get_regular_price
, woocommerce_variation_prices_price
and woocommerce_variation_prices_regular_price
(in short, this modify on the fly EVERY SINGLE PRICE of a page, and if it's a parent containing children, it change prices for children too in order to calculate the range prices (min/max) of the parent).
When digging into Woocommerce code, I have found which method generate the prices transient : it's read_price_data()
located in wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php
. But I can't find a way to call it my Cron Job script to call it on a product or variation object.
Are you guys aware of solution for this task?
Kind regards.