vyskoczilova / woocommerce-payforpayment-old

Setup individual charges for each payment method in woocommerce.
19 stars 15 forks source link

Charges over full amount with WooCommerce Bulk Discount #25

Closed chicoovk closed 10 years ago

chicoovk commented 10 years ago

WC payforpayment charges the costs over the original full amount when WooCommerce Bulk Discount is being applied.

For instance, WooCommerce Bulk Discount has the rule that when the qty is 2 or more, you get 50% discount. WC payforpayment then still charges over 100% of the price instead of 50% of the price.

See the following item and add a qty of 10 to your cart and go to checkout, then toggle from iDeal to PayPal to see the difference in price and calculation. http://tinyurl.com/lgrv9a8

mcguffin commented 10 years ago

The problem lies somewhere within WC Bulk Discount. I'll try to explain.

Pay4Pay gets active after WooCommerce has calculated all cart totals. It calculates its own fee based on the cart totals, adds it to the cart and then calculates all cart totals again but this time with the payment fee included. (This turned out to be the only reliable way to do it – I had gazillion issues about false calculations eating very much time.)

Bulk Discount calculates its percentage discount only once, and denies to do it a second time, regardless of the cart totals having been reset or not. You can try to comment out the lines 350 to 352 and 382 to 384 in woocommerce-bulk-discount/woocommerce-bulk-discount.php in the functions action_before_calculate and filter_before_calculate. Should look like this:

Before:

if ($this->bulk_discount_calculated) {
    return $res;
}

After:

//  if ($this->bulk_discount_calculated) {
//      return $res;
//  }

I can not promise that this won't not mess up any other thing. The bulk_discount_calculated check in question may or may not make sense in this place. But it should be worth a try. Additionally I'd recommend that you to post an issue in the bulk discount forum.

Good Luck!