Support

Home Forums Event Espresso Premium Editing Reg-IDs

Editing Reg-IDs

Posted: June 26, 2014 at 2:22 am

Viewing 19 reply threads


B Cleave

June 26, 2014 at 2:22 am

Hi there,

We’re having issues with the unique Reg-ID assigned to purchased tickets through Worldpay on EE3. We need to be able to customise these IDs to include the show name for the tickets purchased for accounting purposes.

eg. instead of 5-53aa94b900dd9 it would be Ascot-5-53aa94b900dd9

How can I go about doing this?

Thanks


B Cleave

June 26, 2014 at 2:25 am

Actually sorry – it’s the Transaction ID or Cart ID for Worldpay that I need to change, not necessarily the Reg-ID that shows in the EE3 system. Any idea how I would change these as they must be linked somehow.

Thanks


Dean

June 26, 2014 at 2:41 am

Hi,

You could amend the Cart ID to include it.

In gateways/worldway/worldpay_vars.php, on line 22 is this:

$myworldpay->addField('cartId', 'wp-' . event_espresso_session_id());

amend it to something like this

$myworldpay->addField('cartId', 'wp-' . $payment_data['event_name'] . '-' . event_espresso_session_id());

Please note that updates to the plugin will over write these changes.


B Cleave

June 30, 2014 at 5:01 am

Thanks. I tried this last week but it’s not working – my CartID on Worldpay is still something like ‘wp-ltfdekf3vk9ni4861i5bk4ouf7-53aa92eb8f9ec6.79929151’ with no mention of the show.

Any idea why?

Thanks


Dean

June 30, 2014 at 7:13 am

Hi,

The code definitely changes the Cart ID (screenshot http://take.ms/ZWEJ0), though I am unable to test whether this is correctly passed to WorldPay currently (having some issues with their test server).


B Cleave

June 30, 2014 at 9:16 am

Thanks. I’ve checked the code and my one is still showing without the event name, despite adding the line of php above:

<input type=”hidden” name=”cartId” value=”wp–o2h4o0dh7aah2ov6086kr2nhb1-53b17c40582db5.73546316″/>

Have I done something wrong here? I went to add it in wp-content>plugins>event-espresso>gateways>worldpay>worldpay_vars.php

Thanks


Josh

  • Support Staff

June 30, 2014 at 5:34 pm

You might try the following instead:

$myworldpay->addField('cartId', 'wp-' . sanitize_title_with_dashes( $payment_data['event_name'] ) . '-' . event_espresso_session_id());

The sanitize_title_with_dashes function will replace the whitespace from the event’s title with dashes. If changing the code makes no difference when you run the transaction, perhaps you can post your code changes in context in a gist or pastebin and link to it here so we can take a look.


B Cleave

July 1, 2014 at 2:17 am

Ok, unfortunately no change with this code. The file reads:

<?php

function espresso_display_worldpay($payment_data) {
extract($payment_data);

include_once (‘Worldpay.php’);

global $wpdb, $org_options;

$myworldpay = new Espresso_Worldpay(); // initiate an instance of the class
echo ‘<!– Event Espresso WorldPay Gateway Version ‘ . $myworldpay->worldpay_gateway_version . ‘–>’;
$worldpay_settings = get_option(‘event_espresso_worldpay_settings’);
$use_sandbox = $worldpay_settings[‘use_sandbox’];
if ($use_sandbox) {
$myworldpay->enableTestMode();
}
if ($use_sandbox) {
// Enable test mode if needed
$myworldpay->addField(‘testMode’, ‘100’);
}
$myworldpay->addField(‘instId’, $worldpay_settings[‘worldpay_id’]);
$myworldpay->addField(‘cartId’, ‘wp-‘ . sanitize_title_with_dashes( $payment_data[‘event_name’] ) . ‘-‘ .

event_espresso_session_id());
$myworldpay->addField(‘amount’, $event_cost);
$myworldpay->addField(‘MC_id’, $attendee_id);
$myworldpay->addField(‘MC_registration_id’, $registration_id);
//$myworldpay->addField(‘MC_session_id’, session_id());
$myworldpay->addField(‘MC_type’, ‘worldpay’);
$myworldpay->addField(‘accId1’, ‘ARCHANTLIFEM2’);
$myworldpay->addField(‘currency’, $worldpay_settings[‘currency_format’]);
$myworldpay->addField(‘MC_callback’, get_permalink($org_options[‘return_url’]));

if (!empty($worldpay_settings[‘bypass_payment_page’])) {
$myworldpay->submitPayment(); //Enable auto redirect to payment site
} else {
$button_url = espresso_select_button_for_display($worldpay_settings[‘button_url’], “worldpay/worldpay-logo.png”);
$myworldpay->submitButton($button_url, ‘worldpay’); //Display payment button
}

if ($use_sandbox) {

echo ‘<h3 style=”color:#ff0000;” title=”Payments will not be processed”>’ . __(‘WorldPay Debug Mode Is Turned On’,

‘event_espresso’) . ‘</h3>’;
$myworldpay->dump_fields(); // for debugging, output a table of all the fields
}
}

add_action(‘action_hook_espresso_display_offsite_payment_gateway’, ‘espresso_display_worldpay’);


B Cleave

July 1, 2014 at 2:19 am

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>
<?php

function espresso_display_worldpay($payment_data) {
extract($payment_data);

include_once ('Worldpay.php');

global $wpdb, $org_options;

$myworldpay = new Espresso_Worldpay(); // initiate an instance of the class
echo '<!– Event Espresso WorldPay Gateway Version ' . $myworldpay->worldpay_gateway_version . '–>';
$worldpay_settings = get_option('event_espresso_worldpay_settings');
$use_sandbox = $worldpay_settings['use_sandbox'];
if ($use_sandbox) {
$myworldpay->enableTestMode();
}
if ($use_sandbox) {
// Enable test mode if needed
$myworldpay->addField('testMode', '100');
}
$myworldpay->addField('instId', $worldpay_settings['worldpay_id']);
$myworldpay->addField('cartId', 'wp-' . sanitize_title_with_dashes( $payment_data['event_name'] ) . '-' .

event_espresso_session_id());
$myworldpay->addField('amount', $event_cost);
$myworldpay->addField('MC_id', $attendee_id);
$myworldpay->addField('MC_registration_id', $registration_id);
//$myworldpay->addField('MC_session_id', session_id());
$myworldpay->addField('MC_type', 'worldpay');
$myworldpay->addField('accId1', 'ARCHANTLIFEM2');
$myworldpay->addField('currency', $worldpay_settings['currency_format']);
$myworldpay->addField('MC_callback', get_permalink($org_options['return_url']));

if (!empty($worldpay_settings['bypass_payment_page'])) {
$myworldpay->submitPayment(); //Enable auto redirect to payment site
} else {
$button_url = espresso_select_button_for_display($worldpay_settings['button_url'], "worldpay/worldpay-logo.png");
$myworldpay->submitButton($button_url, 'worldpay'); //Display payment button
}

if ($use_sandbox) {

echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('WorldPay Debug Mode Is Turned On',

'event_espresso') . '</h3>';
$myworldpay->dump_fields(); // for debugging, output a table of all the fields
}
}

add_action('action_hook_espresso_display_offsite_payment_gateway', 'espresso_display_worldpay');


B Cleave

July 1, 2014 at 2:20 am

Sorry, not sure why that posted twice but I can’t delete it now! The link to the pastebin is here: http://pastebin.com/29KrdiJs#

Thanks


Tony

  • Support Staff

July 1, 2014 at 2:38 am

Do you have any gateways within wp-content/uploads/espresso/gateways/?

Specifically do you have a ‘worldpay’ directory there?


B Cleave

July 1, 2014 at 2:46 am

No, this folder is empty at present.

Thanks


Dean

July 1, 2014 at 4:57 am

Barring a couple of line breaks in the code (I’m assuming that’s from pasting it in) the code looks right and adds the event name into the cart ID http://take.ms/eGDTq


B Cleave

July 1, 2014 at 6:12 am

This is what I get….
http://i953.photobucket.com/albums/ae15/brookecleave/screenshot_zps340c91cc.png

Is it possible I haven’t put the event name in the correct place?

Thanks


Lorenzo Orlando Caum

  • Support Staff

July 1, 2014 at 10:07 am

Hello,

Could you send an email to the following address so we can provide you with an updated version of the file?

support [at] eventespresso.com

Be sure to include a link to this existing support post.


Lorenzo


Dean

July 2, 2014 at 1:44 am

Hi Brooke,

Before we send the file over, can I just clarify are you using Multiple Event Manager (add to cart) to register these events?


B Cleave

July 2, 2014 at 2:02 am

I’m not entirely sure – how would I know if I am?

Thanks


Dean

July 2, 2014 at 4:28 am

Hi,

The plugin would be active in your Plugins list and if you go to the list of events on the front end, each one would say Register or Add to Cart.


Tony

  • Support Staff

July 2, 2014 at 4:35 am

Hi,

I checked your site and your events are using MER (the ‘cart’ system when you click ‘Register’)

This is actually due to how MER handles the Event Name(s) in that when you use MER $payment_data[‘event_name’] is not set.

I have created a ticket to alter this within a future version of Event Espresso 3 (likely 3.1.38) but can provide you with some code for this to work, however this would require modifying a core file which would need to be repeated with each EE update.

If you open up \event-espresso\includes\process-registration\add_attendees_to_db.php

On line 819 you’ll find:

<?php foreach ($attendees as $attendee) { ?>

Under that add:

<?php $event_names[] = $attendee->event_name; ?>

Then look for line 862, you’ll find 2 br tags. Under that add this:

<?php
	$event_names_combined = array_unique($event_names);
	$event_names_combined = implode($event_names_combined, '-');
	$event_name = apply_filters('filter_hook_espresso_combine_mer_event_names', $event_names_combined, $event_names); 	
?>

So it will end up looking something like this: http://take.ms/qXZ3f

Then the modification Dean provided should also work.

A reminded that until this code is included within EE this will need to added with each update.


B Cleave

July 2, 2014 at 10:38 am

This is now working. Thank you so much for your help on this one!

Viewing 19 reply threads

The support post ‘Editing Reg-IDs’ 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