Last active
August 29, 2015 14:13
-
-
Save bappi-d-great/1449e0e5e0b3687ca176 to your computer and use it in GitHub Desktop.
Provide MarketPress coupon based on Membership level
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
add_filter( 'mp_coupon_value', 'mp_coupon_value_cb', 10, 3 ); | |
function mp_coupon_value_cb( $return, $code, $total ) { | |
$arr = array( | |
'XXX' => 1, | |
'YYY' => 2 | |
); | |
if( current_user_on_level( $arr[$code] ) ){ | |
return $return; | |
}else{ | |
global $mp; | |
$currency = $mp->get_setting('currency', 'USD'); | |
$symbol = $mp->currencies[$currency][1]; | |
$symbols = explode(', ', $symbol); | |
if (is_array($symbols)) { | |
$symbol = ""; | |
foreach ($symbols as $temp) { | |
$symbol .= '&#x'.$temp.';'; | |
} | |
} else { | |
$symbol = '&#x'.$symbol.';'; | |
} | |
$del = explode( $symbol, $return['discount'] ); | |
$return['new_total'] = $return['new_total'] + $del[1]; | |
$return['discount'] = 0; | |
return $return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment