title: Change and save the product price in Woocommerce single product pages
body: <p>I have this function which get fire when a page loads. It checks that the post type is 'product' and this case I need to change the product price and save the page.</p>
  
  <p>I works fine, but I need to know how to set the new product price.</p>
  
  <pre><code>function changeAndSave( $array ) { 
  
      $post_type = get_post_type();
      if ($post_type == "product"){
  
          /*GET THE PRODUCT*/
          global $product;
          $product_id=$product-&gt;id;
  
          /*GET CURRENT PRICE*/
          $currentPrice=$product-&gt;get_price_html();
  
          /*SET NEW PRICE*/
          /* HERE.... ¿¿ how do I set my new price */
          $newPrice = 100€;
  
          /*SAVE THE PRODUCT*/    
          $product = wc_get_product($product_id);
          $product-&gt;save();
      }
  }; 
  
  // add the action 
  add_action( 'loop_start', 'changeAndSave', 10, 1 ); 
  </code></pre>
  
  <p><strong>UPDATE: I tried this, but not working:</strong></p>
  
  <pre><code>function changeAndSave( $array ) { 
  
      $post_type = get_post_type();
      if ($post_type == "product"){
  
          /*GET THE PRODUCT*/
          global $product;
          $product_id=$product-&gt;id;
          $product = wc_get_product($product_id);
  
          /*GET CURRENT PRICE*/
          $currentPrice=$product-&gt;get_price_html();
  
          /*SET NEW PRICE*/
          $newRegularPrice = 81;
          $product-&gt;set_regular_price($newRegularPrice);
  
          /*SAVE THE PRODUCT*/    
          $product-&gt;save();
      }
  }; 
  
  // add the action 
  add_action( 'loop_start', 'changeAndSave', 10, 1 ); 
  </code></pre>