• Resolved benplum

    (@benplum)


    It seems the sale price isn’t calculated outside the loop. We’re using WP Product Feed Manager and the sale prices are not populated properly. Is there a function we can call to get the calculated sale price based on a product or variation ID?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Can you please provide us a download link for this plugin so we can check it out?

    quimo72

    (@quimo72)

    It would be convenient to invoke a function to display the discounted price of a variant based on the ID of a product. Thanks.

    Plugin Author Marco Almeida | Webdados

    (@webdados)

    @quimo72 A public function and a shortcode, maybe?

    Keep in mind that this would only work for “Percentage” based discounts and not for “Buy x get y free” because the function has no way of knowing how many items will the client actually buy.

    quimo72

    (@quimo72)

    Hi Marco, thanks.
    I used this:

    $variations = $product->get_available_variations();
    for ($j = 0; $j < count($variations); $j++) {
        $dummy = wc_get_product($variations[$j]['variation_id']);
        if ($dummy->is_on_sale()) {
            $discount_price = $discount->kuantokusta_product_node_variation_current_price($dummy->get_price(), $product, $dummy);
            $discount_price = number_format((float)$discount_price, 2, ',', '') . get_woocommerce_currency_symbol();
            break;
        }
    }
    • This reply was modified 6 years ago by quimo72.
    Plugin Author Marco Almeida | Webdados

    (@webdados)

    Yes, that will do the trick.

    The kuantokusta_product_node_variation_current_price function is used by another plugin of ours.

    We’ll try to add something more meaningful.

    Plugin Author Marco Almeida | Webdados

    (@webdados)

    Please update to 1.3

    You can use the wctd_get_product_current_price helper function with the product or variation object or id as the first argument.

    You can also pass the quantity as the second argument, so that the calculations are made for percentage discounts with a minimum quantity higher than one or for “buy x get y free” discounts. The returned price will be the price per unit.

    quimo72

    (@quimo72)

    It’s a big improvement. Thanks a lot.

    Plugin Author Marco Almeida | Webdados

    (@webdados)

    ??

    Another big improvement is a link on the admin interface that allows you to buy me a beer ?? ahahah

    Plugin Author Marco Almeida | Webdados

    (@webdados)

    @benplum please get back to us with feedback

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Sale Price Outside Loop’ is closed to new replies.