[Resolved] Variable subscription price (Woocommerce subscription) and Toolset
This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
If I want to show a price table (DIVI module) for a subscription based on the 'variable subscription' type of a woocommerce subscription product, with Toolset can I show the price of each of the variations?
That is, can I show the price of a certain variation of a particular product?
Thanks for your help.
Best regards,
Francisco R.
The WC Subscriptions extension stores the prices for variable products the same way that standard WooCommerce variable product prices are stored, which is in a proprietary way that is not readily accessible to Toolset.
Views includes shortcodes to display the product prices, but using WooCommerce's own API to output the standard UI.
You can display individual prices from the product variations, but this is somewhat brittle (i.e. it can break easily).
When you create a product with variations, the prices of these are stored as post meta with a key of "_price". If you create four variations, there will be four "_price" entries for the post in wp_postmeta.
There is no easy way to connect these prices to the variations, except that they are in the same order as the variations are initially added to the product when first saved. If you re-order the variations on the product edit page, the _price fields do not change.
But if you create the product variations and do not change the order, then you can output the prices using the wpv-post-field shortcode with the index attribute to specify which _price field to output.
This will display the prices of the variations separately, for example:
Thank you very much for your explanation Nigel.
I guess that these shortcodes work if the page of the product is being rendered, if I wanted to put them on any other page, I could do it?
Yes, then you would need to use the id attribute in the wpv-post-field shortcode with the ID of the product so that the shortcode knew which post to get the fields from.