Created
March 20, 2024 09:58
-
-
Save andrewlimaza/0ac2d1caf922c4a1a2c80dea0b4febc8 to your computer and use it in GitHub Desktop.
PMPro remove discount for non-approved members and Woo
This file contains 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 | |
/** | |
* Adjust the Woo membership discount only if the member is approved. | |
* This won't discount for pending or denied members. | |
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmprowoo_price_adjust_approvals( $discount_price, $lowest_price_level, $price, $product ) { | |
if ( ! class_exists( 'PMPro_Approvals' ) ) { | |
return $discount_price; | |
} | |
// Check if the member is not approved, and if so, return the regular price. | |
if ( ! PMPro_Approvals::isApproved() ) { | |
return $price; | |
} | |
return $discount_price; | |
} | |
add_filter( 'pmprowoo_get_membership_price', 'my_pmprowoo_price_adjust_approvals', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment