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.

So..

I would like this: https://dl.dropboxusercontent.com/u/2666961/Screen_Shot_2016-09-16_at_14_54_08.jpg

To look like this: https://dl.dropboxusercontent.com/u/2666961/Screen_Shot_2016-09-16_at_14_56_59.jpg

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

Answers (1)

2016-09-17

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() {
?>
<script>
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>');
});
</script>
<?php
}
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?