• Resolved loveneee

    (@loveneee)


    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

    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)
Viewing 1 replies (of 1 total)
  • The topic ‘Issue with calculation with custom function’ is closed to new replies.