I’m customizing the product page of a site that will have variable products.
Currently, using the Booster for Woocommerce plugin, which gives me convenient shortcodes like [wcj_product_regular_price] and [wcj_product_sale_price], that nicely display the regular and sale prices of the product.
Problem is, when it comes to variable products, they both show $ 0 until variations are selected.
Is there a Woocommerce native shortcode (or a PHP code) to display the current price (or the price range) of a variable product? Like, if the product’s variations range from $ 20 to $ 50, how can I display something like “This product’s price ranges between {shortcode_I_don’t_know}, please choose options to see the exact pricing”?
2
Answers
OK, got it figured out.
Edwin's answer to use the Booster shortcode [wcj_product_price] (instead of [wcj_product_regular_price] and [wcj_product_sale_price]) outputs the min-max range, i.e. $40-$80.
For people who don't use Booster, there's a way to use Woocommerce's built-in variables:
Output:
Bonus: if you don't want the trailing zeroes, use floatval:
Output:
For future reference, here are the WooCommerce native PHP variables for variable products:
Try these shortcode