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

Enhancement: Properly handle discount_code so its automatically added to $data sent to Zapier #53

Open
toodlepip opened this issue Nov 10, 2020 · 0 comments

Comments

@toodlepip
Copy link

toodlepip commented Nov 10, 2020

When data is constructed in class-pmpro-zapier.php from the MemberOrder object, the discount code is not properly added to the $data array that is then sent to Zapier.

When the order is loaded it's handled in the code below for all of the different Zapier options available:

static function pmpro_added_order( $order ) {
		// bail if setting is not checked
		$options = PMPro_Zapier::get_options();
		if ( empty( $options['pmpro_added_order'] ) ) {
			return;
		}

		// Get the saved order.
		$order = new MemberOrder( $order->id );

But this code loads in the DiscountCode object into $order, which is then set to NULL when passed through to Zapier.

The additional of this line will retrieve the discount code used and replace the discount_code object:

$order->discount_code = $order->getDiscountCode()->code;

This will then be available from Zapier to assign to the target application.

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

1 participant