• Resolved anjanphukan

    (@anjanphukan)


    Hi,

    I used your plugin. It works almost the same way I want. But I need a little help.

    I have a product to sell with these discount rules.

    If user selects 1 quantity then the price is 10. But if the quantity is 2 then the price will be 15. That mean on every even quantity customer will get a discount of 5.

    For example, price for quantity 4 will be = 10+5+10+5 = 30 (your plugin gives this correctly)
    For 5 = 10+5+10+5+10 = 40 (here your plugin gives 50)

    I tried these settings – https://www.awesomescreenshot.com/image/1651645/1dde3f1af6f7d2756092f03ccb4debfa

    Can you please help?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Hermann LAHAMI

    (@mano88)

    These settings allows a discount of 25% if the customer purchases a multiple of two, that’s it. So if he buys 2, 4, 6 or any multiple of two, he gets a 25% discount on the prices.

    Thread Starter anjanphukan

    (@anjanphukan)

    But when he purchase 5 items he should get 25% off on first 4 items but doesn’t get not any discount for the additional 1. I think this looks much realistic and my requirement is that too. Please let me know what you think.

    Plugin Author Hermann LAHAMI

    (@mano88)

    Yes i agree but unfortunately we don’t have that feature currently…

    Thread Starter anjanphukan

    (@anjanphukan)

    Thanks. Do you think that can be achieved by modifying the plugin’s core files? How tough will it be to implement that?

    Plugin Author Hermann LAHAMI

    (@mano88)

    Honnestly probably few hours but this week we really can’t because we already have huge delays on the past weeks tasks.

    Thread Starter anjanphukan

    (@anjanphukan)

    Okay I understand.

    I found a paid plugin in codecanyon under your name. Plugin name is ‘Woocommerce All Discounts & Deals – Wholesale, Bulk, Categories, Facebook, Users and Loyaly Pricing’. Is that your plugin? Does it have the feature I need?

    Or do you have any other suggestion please?

    Thank you.

    Plugin Author Hermann LAHAMI

    (@mano88)

    Yes it’s the pro version of our plugin but unfortunately no…

    Thread Starter anjanphukan

    (@anjanphukan)

    Oh okay. I will try to modify the plugin code. But if I stuck somewhere then can I ask you for your quick help?

    Plugin Author Hermann LAHAMI

    (@mano88)

    Sure.

    Thread Starter anjanphukan

    (@anjanphukan)

    Hi,

    I think, I have solve it. I made some changes in the code around line #956 in this file:
    wp-content/plugins/woo-advanced-discounts/includes/class-wad-discount.php

    I changed this:

    foreach ($quantity_pricing["rules-by-step"] as $rule) {
        if ($products_qties[$id_to_check] % $rule["every"] == 0) {
            if ($quantity_pricing["type"] == "fixed")
                $normal_price-=$rule["discount"];
            else if ($quantity_pricing["type"] == "percentage")
                $normal_price-=($normal_price * $rule["discount"]) / 100;
            break;
        }
    }

    to this:

    foreach ($quantity_pricing["rules-by-step"] as $rule) {
        if ($products_qties[$id_to_check] >= $rule["every"]) {
            $total_discount = $rule["discount"] * floor($products_qties[$id_to_check] / $rule["every"]);
            $per_qnty_discount = $total_discount / $products_qties[$id_to_check];
            if ($quantity_pricing["type"] == "fixed")
                $normal_price-=$per_qnty_discount;
            else if ($quantity_pricing["type"] == "percentage")
                $normal_price-=($normal_price * $rule["discount"]) / 100;
            break;
        }
    }

    and it worked for me till now.

    Hope it will help you to work further on it.

    Thanks.

    • This reply was modified 8 years, 5 months ago by anjanphukan.
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Discount Calculation on every even quantity’ is closed to new replies.