About this:
Adding this to your functions.php will update the price label with the variation price.
Step 1: Adding the Function
This function should be added into the functions.php. You can often find this under Appearance > Theme editor. Be sure to select the Flatsome Child so it does not get deleted with a new update.
If you don’t have a child theme, you can find how to install it here: How to install Flatsome Child theme?
// Update Price label on price select
add_action( 'woocommerce_variable_add_to_cart', 'update_price_with_variation_price' );
function update_price_with_variation_price() {
global $product;
$price = $product->get_price_html();
wc_enqueue_js( "
$(document).on('found_variation', 'form.cart', function( event, variation ) {
if(variation.price_html) $('p.price').html(variation.price_html);
$('.woocommerce-variation-price').hide();
});
$(document).on('hide_variation', 'form.cart', function( event, variation ) {
$('p.price').html('" . $price . "');
});
" );
}
Stay Connected
Flatsome is the perfect theme for your shop, company websites or client websites. It has all the tools needed to create super fast responsive websites with amazing user experience.
Starting a project?
Looking to start a website project for a new Flatsome website or webshop? Already got a Flatsome site but looking to redesign it?
Got a question?
Want to ask a question of request more information on what we do within Flatsome? Shoot us a message or feedback.