Created
July 13, 2015 19:13
-
-
Save bappi-d-great/783d8ebc6db1d3a99aad to your computer and use it in GitHub Desktop.
Apply discount automatically based on another membership
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('ms_signup_payment_details', 'ms_signup_payment_details_cb', 10, 3); | |
function ms_signup_payment_details_cb( $invoice, $subscription, $membership ) { | |
$current_membership_id = 1601; | |
$discount = 30; | |
$target_membership_id = 1343; | |
if( $target_membership_id == $membership->id ){ | |
$member = MS_Model_Member::get_current_member(); | |
$membership_items = $member->get_membership_ids(); | |
if( in_array( $current_membership_id, $membership_items ) ) { | |
$invoice->discount = $discount; | |
} | |
} | |
return $invoice; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment