Replace variable price with variation price in WooCommerce

Replace variable price with variation price in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_action( 'woocommerce_variable_add_to_cart', 'wc_update_price_with_variation_price' );
  
function wc_update_price_with_variation_price() {
   global $product;
   $price = $product->get_price_html();
   wc_enqueue_js( "      
      $(document).on('found_variation', 'form.cart', function( event, variation ) {   
         $('.summary > p.price').html(variation.price_html);
         $('.woocommerce-variation-price').hide();
      });
      $(document).on('hide_variation', 'form.cart', function( event, variation ) {   
         $('.summary > p.price').html('" . $price . "');
      });
   " );
}
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.