Title: Issue with calculation with custom function
Last modified: July 31, 2021

---

# Issue with calculation with custom function

 *  Resolved [loveneee](https://wordpress.org/support/users/loveneee/)
 * (@loveneee)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/issue-with-calculation-with-custom-function/)
 * Hi first just wanna say I absolutely love your plugin, thank you for it! It works
   really well with everything.
 * However, until I used a custom function for my woocommerce, it calculated the
   price wrong.
 * I have a variable product on sale. I have a custom function to show only the 
   one price, the maximum.
 * **Here’s a screenshot:** [https://snipboard.io/MJTR5D.jpg](https://snipboard.io/MJTR5D.jpg)
 * EX:
    VARIATION1 reg price: 5,980 php sale price: 4,648 php VARIATION2 reg price:
   1100 PHP
 * plugin usd result
    reg price: 1.86 usd sale price: 2.39 usd
 * However it does show correctly on the variation options, its juts the main price
   displayed having issues. Here’s the custom function code I used
 *     ```
       add_filter('woocommerce_variable_sale_price_html', 'shop_variable_product_price', 10, 2);
       add_filter('woocommerce_variable_price_html','shop_variable_product_price', 10, 2 );
       function shop_variable_product_price( $price, $product ){
           $variation_min_reg_price = $product->get_variation_regular_price('max', true);
           $variation_min_sale_price = $product->get_variation_sale_price('max', true);
           if ( $product->is_on_sale() && !empty($variation_min_sale_price)){
               if ( !empty($variation_min_sale_price) )
                   $price = '<ins class="highlight">' .wc_price($variation_min_sale_price).'</ins> <del class="strike">' .wc_price($variation_min_reg_price) . '</del>';
           } else {
               if(!empty($variation_min_reg_price))
                   $price = '<ins class="highlight">'.wc_price( $variation_min_reg_price ).'</ins>';
               else
                   $price = '<ins class="highlight">'.wc_price( $product->regular_price ).'</ins>';
           }
           return $price;
       }
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [WBW Plugins](https://wordpress.org/support/users/woobewoo/)
 * (@woobewoo)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/issue-with-calculation-with-custom-function/#post-14728138)
 * Hello [@loveneee](https://wordpress.org/support/users/loveneee/),
 * Thank you for your kind words.
    Please contact our internal support team – [https://woobewoo.com/contact-us/](https://woobewoo.com/contact-us/)
   We need more detailed information on this issue.

Viewing 1 replies (of 1 total)

The topic ‘Issue with calculation with custom function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/woo-currency_768db6.svg)
 * [Currency Switcher for WooCommerce by WBW](https://wordpress.org/plugins/woo-currency/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-currency/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-currency/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-currency/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-currency/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-currency/reviews/)

## Tags

 * [woocommerce currency](https://wordpress.org/support/topic-tag/woocommerce-currency/)

 * 1 reply
 * 2 participants
 * Last reply from: [WBW Plugins](https://wordpress.org/support/users/woobewoo/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/issue-with-calculation-with-custom-function/#post-14728138)
 * Status: resolved