Title: TALAWEB - the freelance web geek's Replies | WordPress.org

---

# TALAWEB - the freelance web geek

  [  ](https://wordpress.org/support/users/talaweb/)

 *   [Profile](https://wordpress.org/support/users/talaweb/)
 *   [Topics Started](https://wordpress.org/support/users/talaweb/topics/)
 *   [Replies Created](https://wordpress.org/support/users/talaweb/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/talaweb/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/talaweb/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/talaweb/engagements/)
 *   [Favorites](https://wordpress.org/support/users/talaweb/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Replace Sale Price with a button to show/hide the value](https://wordpress.org/support/topic/replace-sale-price-with-a-button-to-show-hide-the-value/)
 *  Thread Starter [TALAWEB – the freelance web geek](https://wordpress.org/support/users/talaweb/)
 * (@talaweb)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/replace-sale-price-with-a-button-to-show-hide-the-value/#post-14721865)
 * Here’s my solution:
 * **functions.php**
 *     ```
       add_filter( 'woocommerce_get_price_html', 'tlw_custom_price', 10, 2 );
       function tlw_custom_price() {
           global $product;
           $saleprice = $product->get_sale_price();
           $fullprice = $saleprice + 200;
   
           if ( is_product() ) {
               if ( $product->is_on_sale() ) {
                   if( $product->is_type('simple') || $product->is_type('external') || $product->is_type('grouped') ) {
                       $regular_price = get_post_meta( $product->get_id(), '_regular_price', true ); 
                       $sale_price = get_post_meta( $product->get_id(), '_sale_price', true );
                       if( !empty($sale_price) ) {
                           print '<p class="price">' . 
                                   '<div class="regular-price">' .
                                   '<h4 class="woocommerce-Price-amount amount">Original price:<br />' . number_format($regular_price, 0, '', ' ') . ' EUR</h4></div>' .
                                   '<h5 class="red">Need it cheaper? Click here!</h5>' .
                                   '<p><button class="show-price-button button blue" onclick="showPrice()">Get my discount</button></p>' .
                                   '<h4 id="hidden-price" class="sale-price">Discount price:<br />' . number_format($sale_price, 0, '', ' ') . ' EUR</h4>' .
                                 '</p>';
                       }
                   }
               }
           }
       }
       ```
   
 * **Before </head> tag**
 *     ```
       <script>
               function showPrice() {
                   var price = document.getElementById("hidden-price");
   
                   if (price.style.display === "block") {
                       price.style.display = "none";
                   } else {
                       price.style.display = "block";
                   }
               } 
       </script>
       ```
   
    -  This reply was modified 4 years, 9 months ago by [TALAWEB - the freelance web geek](https://wordpress.org/support/users/talaweb/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Replace Sale Price with a button to show/hide the value](https://wordpress.org/support/topic/replace-sale-price-with-a-button-to-show-hide-the-value/)
 *  Thread Starter [TALAWEB – the freelance web geek](https://wordpress.org/support/users/talaweb/)
 * (@talaweb)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/replace-sale-price-with-a-button-to-show-hide-the-value/#post-14672854)
 * Custom coding is okay. But how can I modify the price HTML with a function from**
   functions.php** file?

Viewing 2 replies - 1 through 2 (of 2 total)