Hello,
I'm using WC and wants to display the product price in the product page (Views content). For this, I'm using the [wpv-woo-product-price] shortcode. That's OK is the product is single of with the same price for all variations.
If the product has several variations with different prices, then, this shortcode always return the min / max prices. I want to display the price related to the current chosen variation. Which shortcode do I need to use for this?
Regards
Pat
Dear Pat,
Please try with another shortcode [wpv-woo-buy-options]
For Variable products, user will be presented with a drop-down menu of Variations to select from.
https://toolset.com/documentation/views-shortcodes/#wpv-woo-product-price
Hi Luo,
I know this shortcode and I have it also in my content Views. The problem here is that this shortcode display only price variation when they are different prices for each variation. If the same price is applied to all variations, this shortcode does not display anything.
So currently, I need to use both shorcodes, knowing that they are not displaying the same way in term of positionand design, which is ennoying !
I think the good way will be to have a kind of generic shortcode that could display dynamically the variation prices but also, the single product price.
Regards
Pat
You will need to try with some custom PHP codes.
The View's shortcode [wpv-woo-product-price] is using woocommerce function get_price_html() to get the product price, see source code of woocommerce-views plugin, file \woocommerce-views\Class_WooCommerce_Views.php, line 3660~3685:
public function wpv_woo_product_price_func($atts) {
...
$product_price=$product->get_price_html();
...
}
And in the function get_price_html() of woocommerce plugin, you can customize the product price as what you want with the filter woocommerce_get_price_html, see the source of woocommerce plugin:
hidden link
public function get_price_html( $price = '' ) {
...
return apply_filters( 'woocommerce_get_price_html', $price, $this );
}