Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Created January 26, 2018 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreamweb/24a47e57817fa13431326ab4a14bc6e3 to your computer and use it in GitHub Desktop.
Save kreamweb/24a47e57817fa13431326ab4a14bc6e3 to your computer and use it in GitHub Desktop.
the rewards discount is calculate on product price and not from cart item price. adding this filter the discount is calculate on cart item price
<?php
add_filter('ywpar_calculate_product_max_discounts','ywpar_calculate_product_max_discounts', 10, 2);
function ywpar_calculate_product_max_discounts( $price, $product_id ){
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if( $product_id == $_product->id ) {
return $_product->get_price();
}
}
return $price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment