Hi,
I’m trying to get partial payments to work with my event registration. I came across this wiki article: https://eventespresso.com/wiki/setting-partial-payments-ee/
which explains everything very clearly. However, when I copy and paste the raw code for the second function (which starts with <?php
function espresso_get_total_cost_custom($payment_data) { etc) it just gives an error. I tried it in my functions.php (which made the whole site stop working!) and then tried it in the blank plugin for custom functions, where it said it was deactivated for a fatal error.
I would really appreciate some help, I’ve got a whole bunch of clients who have already made partial payments and now are struggling with trying to pay the correct amount owing.
Parse error: syntax error, unexpected ‘<‘ in /home/sites/activateyourlife.org.uk/public_html/wp-content/plugins/CustomFunctionsPlugin/CustomFunctionsPlugin.php on line 12
<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”><?php
/**
* Plugin Name: Custom Functions Plugin
* Plugin URI: https://eventespresso.com
* Description: A blank plugin where you can put custom functions
* Version: 1.0
* Author: Sidney Harrell
* Author URI: http://sidneyharrell.com
* License: GPL2
*/
<?php
function espresso_get_total_cost_custom($payment_data) {
remove_filter(‘filter_hook_espresso_get_total_cost’, ‘espresso_get_total_cost’);
global $wpdb;
//if for some reason attendee_session isn’t setin the payment data, set it now
if(!array_key_exists(‘attendee_session’,$payment_data) || empty($payment_data[‘attendee_session’])){
$SQL = “SELECT attendee_session FROM ” . EVENTS_ATTENDEE_TABLE . ” WHERE id=%d”;
$session_id = $wpdb->get_var( $wpdb->prepare( $SQL, $payment_data[‘attendee_id’] ));
$payment_data[‘attendee_session’]=$session_id;
}
//find all the attendee rows
$sql = “SELECT a.final_price, a.quantity, a.amount_pd FROM ” . EVENTS_ATTENDEE_TABLE . ” a “;
$sql .= ” WHERE a.attendee_session='” . $payment_data[‘attendee_session’] . “‘ ORDER BY a.id ASC”;
$tickets = $wpdb->get_results($sql, ARRAY_A);
$total_cost = 0;
$total_quantity = 0;
$amount_pd = 0;
//sum up their final_prices, as this should already take into account discounts
foreach ($tickets as $ticket) {
$total_cost += $ticket[‘quantity’] * $ticket[‘final_price’];
$total_quantity += $ticket[‘quantity’];
$amount_pd += $ticket[‘amount_pd’];
}
Alright, never mind, I got it to work. 🙂 I just deleted the <?php part from right before function espresso_get_total_cost_custom($payment_data) and it stopped the error message. And, I followed the rest of the steps in article and my partial payments are now working beautifully! Thanks so much Event Espresso!
The support post ‘Code not working from Partial Payments wiki article’ 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.
Support forum for Event Espresso 3 and Event Espresso 4.