Created
December 23, 2025 10:10
-
-
Save dwanjuki/94cb834df7ce4d110dfd3f400dacf4ae to your computer and use it in GitHub Desktop.
Update discount code uses, if found, when an order is deleted
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 | |
| /** | |
| * Update discount code uses when the order is deleted. | |
| * | |
| * 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_delete_order_update_discount_code( $order_id, $order ) { | |
| $order->updateDiscountCode( null ); | |
| } | |
| add_action( 'pmpro_delete_order', 'my_pmpro_delete_order_update_discount_code', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment