Always show price before the Add to cart button
-
Hey !
I added the following snipet of code to a child theme to hide the price range on the top of the screen on variable products:
add_action( 'woocommerce_before_single_product', 'my_remove_variation_price' ); function my_remove_variation_price() { global $product; if ( $product->is_type( 'variable' ) ) { remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price' ); } }
I was happy with that solution because the price appeared after the variation choice: https://i.imgur.com/i7j0v3E.png
Turns out this is the case only when variations have different prices. I fixed it by forcing this display with one line:
add_filter( 'woocommerce_show_variation_price', '__return_true' );
Now, even better: can I do the same for simple products?
(i.e. have the price before the [Add to cart] button and not after the title)
I would like it to look just like the woocommerce_show_variation_price with the little horizontal bar before
- The topic ‘Always show price before the Add to cart button’ is closed to new replies.