WebBox

Show variation price as main price

Nov 19th, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | Source Code | 0 0
  1. add_action( 'woocommerce_variable_add_to_cart', 'wb_update_price_with_variation_price' );
  2.  
  3. function wb_update_price_with_variation_price() {
  4.    global $product;
  5.    $price = $product->get_price_html();
  6.    wc_enqueue_js( "    
  7.      $(document).on('found_variation', 'form.cart', function( event, variation ) {  
  8.         if(variation.price_html) $('.summary > p.price').html(variation.price_html);
  9.         $('.woocommerce-variation-price').hide();
  10.      });
  11.      $(document).on('hide_variation', 'form.cart', function( event, variation ) {  
  12.         $('.summary > p.price').html('" . $price . "');
  13.      });
  14.   " );
  15. }
Advertisement
Add Comment
Please, Sign In to add comment