Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Created January 12, 2018 13:10
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/e1996909cf5433bc8b7eaf801e2b1906 to your computer and use it in GitHub Desktop.
Save kreamweb/e1996909cf5433bc8b7eaf801e2b1906 to your computer and use it in GitHub Desktop.
<?php
/** ticket 113379 */
if ( class_exists( 'YITH_WC_Points_Rewards_Redemption' ) ) {
add_filter( 'ywpar_calculate_rewards_discount_max_discount', 'ywpar_calculate_rewards_discount_max_discount' );
function ywpar_calculate_rewards_discount_max_discount( $max_discount ) {
return floatval( intval( $max_discount ) );
}
add_filter( 'ywpar_calculate_rewards_discount_max_points', 'ywpar_calculate_rewards_discount_max_points', 10, 3 );
function ywpar_calculate_rewards_discount_max_points( $max_points, $obj, $conversion ) {
if( $obj->get_conversion_method() == 'fixed')
$max_points = ( $obj->get_max_discount() * $conversion['points'] ) / $conversion['money'];
return floatval( intval( $max_points ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment