Created
July 10, 2024 11:32
-
-
Save dwanjuki/26567b0c2baf50251e763929c0bcc7f0 to your computer and use it in GitHub Desktop.
Exclude discounted checkouts from PMPro Affiliate tracking
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 | |
/** | |
* Exclude discounted membership checkouts from PMPro Affiliate tracking | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_affiliates_skip_discounted_checkouts( $order ){ | |
if( ! function_exists( 'pmpro_affiliates_pmpro_added_order' ) ) { | |
return; | |
} | |
$pmpro_level = $order->getMembershipLevel(); | |
if ( isset( $pmpro_level->code_id ) ) { | |
remove_action( 'pmpro_added_order', 'pmpro_affiliates_pmpro_added_order' ); | |
remove_action( 'pmpro_after_checkout', 'pmpro_affiliates_no_order_checkout' ); | |
} | |
} | |
add_action( 'pmpro_added_order', 'my_pmpro_affiliates_skip_discounted_checkouts', 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment