Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Small price display hack in Woocommerce WordPress

Hello Wordpress people,

For our shop, I would like to disable the variable products price range, and instead just show the single variation price instead.


I would like this:

To look like this:

I would prefer a solution that does not involve hacking template files, but only functions.php.

Answers (1)


Bob answers:

please put this code in your themes's functions.php file.
and try to change the variation in dropdown.

function wpq_change_variation_price() {
jQuery(document).on( 'found_variation', 'form.cart', function( event, variation ) {
jQuery('p.price').html('<span calss="woocommerce-Price-amount amount">'+variation.display_price+'</span><span class="woocommerce-Price-currencySymbol">DKK</span>');
add_action( 'wp_footer', 'wpq_change_variation_price', 100 );

Let me know if it could change amount at proper place.

medico comments:

I think that's a terrible solution, can't it be done in PHP?