Support

Home Forums Event Espresso Premium How do I send number of attendees / ticket quantity, to custom payment gateway

How do I send number of attendees / ticket quantity, to custom payment gateway

Posted: November 27, 2013 at 4:48 pm

Viewing 5 reply threads


Tristan Mills

November 27, 2013 at 4:48 pm

is there a simple way to do this?

I have tried adding
$data['total_quantity'] = $num_attendees;
(among other things) in gateway_display.php , but its not setting a value, I can read off $total_quantity fine in my gateway_vars.php [I tested it by setting it manually as e.g. “3”]

what should be there instead of $num_attendees to get it working?

Any help gratefully received!

i also tried things like:
isset( $attendees[ $event_id ]) ? $attendees[ $event_id ]->quantity : 0
isset($total_quantity) && !empty($total_quantity) ? $total_quantity : '';
$ticket['quantity']

Unfortunately my knowledge has big gaps and I am mainly guessing.

I’m also looking to do the same with event price and tax, I can already pass total amount, description etc fine.


Tony

  • Support Staff

November 28, 2013 at 5:04 am

Hi Tristan,

Do you need to display this within gateway_display.php? If so why? Reason I ask is that file is a core file, any changes made there will be lost after each update. You can use quantity without modifying that page.

Unfortunately custom payment gateways are beyond the scope of general support but I can give you some advice. If you look through some of the other gateways, you’ll see:

$quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id);

Which pulls in the quantity for that registration.

If you look in gateways/authnet/authnet_vars.php line 48 you’ll see another method for pulling in the information:

$sql = "SELECT a.final_price, a.quantity, ed.event_name, a.price_option, a.fname, a.lname FROM " . EVENTS_ATTENDEE_TABLE . " a JOIN " . EVENTS_DETAIL_TABLE . " ed ON a.event_id=ed.id ";

As part of the SQL query, quantity is being retrieved from the database then used further down within the foreach loop $item->quantity.
*that is only part of the query just to show an example

Custom Gateways were intended for developers to add ‘unsupported’ (from an EventEspresso point of view) gateways for their clients.

Are you copying another gateway and modifying it to suit?
What custom gateway is this for?

  • This reply was modified 11 years ago by Tony. Reason: Code editor


Tristan Mills

November 28, 2013 at 5:51 am

Hi,

Thanks, adding $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); in my vars file works just fine, I won’t touch gateway_display.

Any idea how to carry across the event cost [cost for a single ticket] and tax.. although now I have quantity working I could just use some math to work out event cost and tax, but would rather call the variables if they are available.

It is for the Sagepay gateway

Thanks again for your help, much appreciated!


Tristan Mills

November 28, 2013 at 6:42 am

actually i don’t need to send the tax amount anyway, and i have easily got the ticket cost by doing amount / quantity. I do need the start date however – I have this at the moment by adding $data['start_date'] = $start_date; to gateway_display.php then calling $start_date in …vars.php file for the gateway, but is there a way to do this without touching gateway_display – as you point out this file might take updates in future.. thanks in advance for any suggestions!

slightly off topic, but can i copy gateway_display.php to a /templates folder which will get read if exists and not get written over on updates?


Tony

  • Support Staff

November 28, 2013 at 7:16 am

I’ve just checked into this and it turns out that yes you can copy the gateway_display.php file to wp-content/uploads/espresso/gateways/

Copy the file there and modify the new version there. That will keep it safe from updates. (from time to time you may find we add sections to these files which you will need to match in your modified versions)

That way you should be able to use the method above for start_date.

Just to clarify, that file is used by all gateways, adding what you have mentioned should not cause any issues, however it is untested and unfortunately unsupported by ourselves.

There is nothing wrong with what your trying to do just that if you find issues further down the line, whilst we will usually help as best we can you may find you also need the help of a developer.


Tristan Mills

November 28, 2013 at 7:31 am

Thanks for your help. Maybe defining the start date in gateway_display.php could be added in future updates as its quite important to be able to confirm the date of the event in emails and payment confirmations when there are multiple dates for the same event.


Tony

  • Support Staff

November 28, 2013 at 7:56 am

No Problem, thank you for your feedback.

I would need to double check this, but iirc information used within gateway_display.php (and the gateways) is used almost exclusively for the gateways only.

The emails are built using the registration information from within the Database and you can use the [start_date] shortcode within the payment confirmation email to retrieve the start date for that attendee. The gateways ‘trigger’ the building of said emails on successful payment notification, but other than that are not involved afaik.

I may well be wrong and will double check this, but due to the holidays it may be a little before I can provide a definitive answer.

Viewing 5 reply threads

The support post ‘How do I send number of attendees / ticket quantity, to custom payment gateway’ 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