Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Displaying incorrect amount when discount code is applied. #47

Open
messica opened this issue Feb 20, 2019 · 1 comment
Open

Bug: Displaying incorrect amount when discount code is applied. #47

messica opened this issue Feb 20, 2019 · 1 comment

Comments

@messica
Copy link
Contributor

messica commented Feb 20, 2019

When a discount code is applied on the checkout page via AJAX, only the discount code level for the "main" level ID is displayed. This is because applydiscountcode.php only handles the "main" level ID: https://github.com/strangerstudios/paid-memberships-pro/blob/dev/services/applydiscountcode.php#L26

We should be able to use the pmpro_discount_code_level filter on applydiscountcode.php only to calculate the returned level cost based on all of the levels in $pmpro_checkout_levels:
i.e.

function pmprommpu_pmpro_discount_code_level( $code_level, $discount_code_id ) {
	// Make sure this is being called by applydiscountcode.php
	// Calculate level based on all levels
		// Check for all levels in $pmpro_checkout_levels or rebuild array from $_REQUEST
		// Sum applied level initial_payments, billing_amounts
	// Return level
}
add_action( 'pmpro_discount_code_level' , 'pmprommpu_pmpro_discount_code_level', 10, 2);

or we could update applydiscountcode.php to handle multiple levels.

Support Ticket (Moderators Only)
https://www.paidmembershipspro.com/forums/topic/discount-code-not-summing-when-selecting-multiple-items/

@ideadude
Copy link
Member

This makes sense. We also need to make sure the call to pmpro_checkDiscountCode() checks if a code works for ANY of the supplied levels instead of just one. The function itself takes one level id as a param. So we'd have to add a filter there and filter it... or we can sometimes update things in core to make them handle a single level or multiple.

The applydiscountcode.php service would be changed or have a filter added to allow us to instead of checking just the one level call pmpro_checkDiscountCode for all levels... something like that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants