Support

Home Forums Event Espresso Premium Partial Payments

Partial Payments

Posted: October 7, 2013 at 7:22 am


cori nevruz

October 7, 2013 at 7:22 am

I realize this isnt an implemented function but I read this post

and this work around may help for the time being. I have been able to add the new shortcodes for [amount_paid] and [amount_owed] into the payment reminder email, however the payment page is still displaying the total price and sending that price to paypal. Can anyone point me to where I can replace that variable and what I can replace it with since the shortcodes will not work there. Thanks!
Using Pro

  • This topic was modified 10 years, 6 months ago by  cori nevruz.
  • This topic was modified 9 years, 1 month ago by  Seth Shoultes. Reason: fixing url


Josh

  • Support Staff

October 7, 2013 at 2:00 pm

Hi Cori,

The paypal_vars.php on lines 52 and 57 are two places where the amount sent to PayPal is sent. You will likely need to introduce a few new variables there that will allow for the calculation to be made, which will involve altering the query on line 33 in the same file. You will need to add a.amount_pd to the query there on line 33 to get the amount paid variable.


cori nevruz

October 7, 2013 at 3:48 pm

Thanks Josh, I may need a bit more guidance than that… my lines dont seem to be matching up with yours…


Josh

  • Support Staff

October 7, 2013 at 4:08 pm

You may be on a different version. Here are code snippets based on the current version of Event Espresso (3.1.35.1.P). Starting with the loop that sets the payment amount that is sent to PayPal taken from /gateways/paypal/paypal_vars.php:

	foreach ($items as $key => $item) {

		$item_num = $key + 1;
		$myPaypal->addField('item_name_' . $item_num, $item->price_option . ' for ' . $item->event_name . '. Attendee: ' . $item->fname . ' ' . $item->lname);
		$myPaypal->addField('quantity_' . $item_num, absint($item->quantity));

		if ($item->final_price < $item->orig_price) {
			$adjustment = abs($item->orig_price - $item->final_price);
			if (absint($item->quantity) > 1) {
				$adjustment = $adjustment * absint($item->quantity);
			}
			$myPaypal->addField('amount_' . $item_num, $item->orig_price);
			$myPaypal->addField('discount_amount_' . $item_num, $adjustment);
			//$myPaypal->addField('discount_amount2_' . $item_num, $adjustment);//Not sure this line is needed.
		} else {

			$myPaypal->addField('amount_' . $item_num, $item->final_price);
		}

		if (isset($paypal_settings['tax_override']) && $paypal_settings['tax_override'] == true) {
			$myPaypal->addField('tax_' . $item_num, '0.00');
		}
		if (isset($paypal_settings['shipping_override']) && $paypal_settings['shipping_override'] == true) {
			$myPaypal->addField('shipping_' . $item_num, '0.00');
		}
	}

In the above code block you’ll see the ‘amount_’ fields are set for PayPal on lines 52 (when a discount is applied) and 57 (no discount applied). This is where some logic may be added to factor in any amount paid and then deducted from the due amount sent to PayPal.

then on line 33 is where the query gets started being built:

$SQL = "SELECT a.final_price, a.orig_price, a.quantity, ed.event_name, a.price_option, a.fname, a.lname ";

the amount paid can be added to the query:

$SQL = "SELECT a.final_price, a.orig_price, a.quantity, ed.event_name, a.price_option, a.fname, a.lname, a.amount_pd ";

Then, the $item->amount_pd can be used in the foreach loop as a variable that will pull in the amount paid.


cori nevruz

October 8, 2013 at 7:26 am

Thank you,
After adding a.amount_pd to the sql query, I commented out the original ‘amount_’ calculation to use final_price – amount_pd below:

<code>//only display amount owed
			$myPaypal-&gt;addField(&#039;amount_&#039; . $item_num, $item-&gt;final_price - absint($item-&gt;amount_pd));
			//$myPaypal-&gt;addField(&#039;amount_&#039; . $item_num, $item-&gt;orig_price);</code>

However, I dont see that value getting passed to paypal. Is that the variable that is actually getting passed? Also, on the ‘thank-you’ page where the invoice and email payment reminders direct you, where is that Amount Paid/Owed: value coming from. I need that to be updated as well. It seems to be on the payment_overview.php page but I do not see where the $total_cost variable is being set.


Sidney Harrell

October 8, 2013 at 1:03 pm

I tested it and it’s working, except you don’t need to be sending the amount_pd_ and amount_owed_ fields, so I commented those out. They aren’t in the paypal list of fields, so they were probably just getting ignored. The one that they are looking for is amount_ If you look at the html of the button, or put it into sandbox mode so that all the fields get listed, you’ll see it as amount_1, since it is the amount for item number 1. If you checkout with multiple attendees you’ll see amount_2, etc.
I went ahead and copied the paypal folder from plugins/event-espresso/gateways to uploads/espresso/gateways so that your changes will be preserved when you upgrade EE.
To get the payment overview correct, I had to make a customization to a function that gets the total cost for the payment overview. It now gets the $amount_pd, the $amount_owed, as well as the $total_cost and $quantity that it was getting before. The customized function is now in your uploads/espresso/custom_functions.php file. I made the display change to your payment_overview.php template file and copied it into uploads/espresso/templates to preserve it from future upgrades.


cori nevruz

October 8, 2013 at 2:08 pm

Wow, I am just blow away by your quick and thorough help! Thank you!!!

The support post ‘Partial Payments’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso