Created
January 26, 2018 11:58
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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