Skip to content

Instantly share code, notes, and snippets.

View sidharrell's full-sized avatar

Sidney Harrell sidharrell

  • Vivian-Harrell Web Development Studios, LLC
  • Harpers Ferry, WV, United States
View GitHub Profile
@sidharrell
sidharrell / gist:7549987
Last active December 28, 2015 19:29
get a single price sans surcharge
function espresso_return_single_price_sans_surcharge($event_id, $number=0) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $wpdb, $org_options;
$number = $number == 0 ? '0,1' : $number . ',' . $number;
$results = $wpdb->get_results("SELECT event_cost FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='" . $event_id . "' ORDER BY id ASC LIMIT " . $number);
if ($wpdb->num_rows > 0) {
foreach ($results as $result) {
$event_cost = $result->event_cost;
@sidharrell
sidharrell / gist:7895923
Last active December 30, 2015 22:39
fix eway response message
// replaces gateways/eway/ewaypaymentprocess.php lines 87-97
if ($eway_settings['use_sandbox']) {
echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debugging / Sandbox output', 'event_espresso') . '</h3><br />';
echo "Response code = " . $responsecode;
echo "\nResponse = ";
var_dump($response);
echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('End of Debugging / Sandbox output (this will go away when you switch to live transactions)', 'event_espresso') . '</h3>';
$subject = 'Instant Payment Notification - Gateway Variable Dump';
$body = "An instant payment notification failed\n";
$body .= "from " . " on " . date('m/d/Y');
@sidharrell
sidharrell / gist:7946710
Last active December 31, 2015 06:19
count number of events in a category
function espresso_count_the_events_in_a_category ($atts) {
extract(shortcode_atts(array('event_category_id' => FALSE), $atts));
if (!$event_category_id) return FALSE;
global $wpdb;
return $wpdb->get_var($wpdb->prepare("SELECT COUNT(ed.id) FROM " . EVENTS_DETAIL_TABLE . " ed JOIN " . EVENTS_CATEGORY_REL_TABLE . " cr ON ed.id = cr.event_id JOIN " . EVENTS_CATEGORY_TABLE . " cd ON cr.cat_id = cd.id WHERE cd.category_identifier = '%s' AND ed.event_status != 'D'", $event_category_id));
}
add_shortcode('COUNT_EVENTS_IN_CATEGORY', 'espresso_count_the_events_in_a_category');
@sidharrell
sidharrell / gist:7947711
Created December 13, 2013 17:15
show cart widget if empty
//replaces lines 24-43 of plugins/espresso-multiple/cart-widget.php
public function widget($args, $instance) {
//if (empty($_SESSION['espresso_session']['events_in_session'])){return;}
extract($args);
global $org_options;
$grand_total = !empty($_SESSION['espresso_session']['grand_total']) ? $_SESSION['espresso_session']['grand_total'] : 0.00;
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
echo $before_title . $title . $after_title;
//Debug
@sidharrell
sidharrell / gist:7992131
Created December 16, 2013 18:45
custom espresso_update_attendee_payment_status_in_db to work with partial payments
function espresso_update_attendee_payment_status_in_db_custom($payment_data) {
// echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
remove_filter('filter_hook_espresso_update_attendee_payment_data_in_db', 'espresso_update_attendee_payment_status_in_db');
global $wpdb;
$payment_data['payment_date'] = date(get_option('date_format'));
if ($payment_data['payment_status'] == "Completed") {
$payment = $payment_data['total_cost'];
} elseif($payment_data['payment_status'] == "Pending" && !empty($payment_data['amount_paid'])) {
@sidharrell
sidharrell / gist:8106350
Created December 23, 2013 23:06
fix for timeslot reg limit time selector dropdown count
// replaces lines 183-192 of includes/functions/time_date.php:
$SQL .= "( SELECT COALESCE( (SELECT sum(quantity) FROM " . EVENTS_ATTENDEE_TABLE . " ATT ";
$SQL .= "WHERE ATT.event_id= %d ";
$SQL .= "AND ATT.payment_status != 'Incomplete' ";
$SQL .= "AND ATT.event_time = ESE.start_time ";
$SQL .= "AND ATT.end_time = ESE.end_time), 0 ) ) ";
$SQL .= ") AS available_spaces ";
$SQL .= "FROM " . EVENTS_START_END_TABLE . " ESE ";
$SQL .= "WHERE ESE.event_id= %d ";
$SQL .= "GROUP BY ESE.id ";
@sidharrell
sidharrell / gist:8193255
Created December 31, 2013 06:09
fix for attednee_numbers shortcode to make it work independent of specific event id (REM)
function espresso_attendees_data_sc($atts) {
global $wpdb, $org_options, $this_event_id;
extract(shortcode_atts(array('event_id' => $this_event_id, 'type' => ''), $atts));
$event_id = "{$event_id}";
$type = "{$type}";
$data = get_number_of_attendees_reg_limit($event_id, $type);
return $data;
}
@sidharrell
sidharrell / gist:8203590
Created January 1, 2014 00:20
custom function to make price_option available in payment_overview.php template
function espresso_prepare_payment_data_for_gateways_custom( $payment_data ) {
remove_filter('filter_hook_espresso_prepare_payment_data_for_gateways', 'espresso_prepare_payment_data_for_gateways');
global $wpdb, $org_options;
$SQL = "SELECT ea.price_option, ea.email, ea.event_id, ea.registration_id, ea.txn_type, ed.start_date,";
$SQL .= " ea.attendee_session, ed.event_name, ea.lname, ea.fname, ea.total_cost,";
$SQL .= " ea.payment_status, ea.payment_date, ea.address, ea.city, ea.txn_id,";
$SQL .= " ea.zip, ea.state, ea.phone, ed.event_meta FROM " . EVENTS_ATTENDEE_TABLE . " ea";
$SQL .= " JOIN " . EVENTS_DETAIL_TABLE . " ed ON ed.id=ea.event_id";
$SQL .= " WHERE ea.id = %d";
$temp_data = $wpdb->get_row( $wpdb->prepare( $SQL, $payment_data['attendee_id'] ), ARRAY_A );
@sidharrell
sidharrell / gist:8343222
Created January 9, 2014 22:24
conditional questions jQuery hack
<script>
jQuery( document ).ready( function() {
jQuery('.DROPDOWN_37').html('');
jQuery('.DROPDOWN_36').on('change', function() {
switch(jQuery(this).val()) {
case '1':
jQuery('.DROPDOWN_37').html('<option value="">Select One</option><option value="1"> 1</option><option value="2"> 2</option><option value="3"> 3</option>');
break;
case '2':
jQuery('.DROPDOWN_37').html('<option value="">Select One</option><option value="4"> 4</option><option value="5"> 5</option><option value="6"> 6</option>');
@sidharrell
sidharrell / gist:8461296
Created January 16, 2014 19:09
edit attendee links on payment overview.php
<tr>
<?php
$attendees = $wpdb->get_results($wpdb->prepare("SELECT registration_id, id, event_id, fname, lname FROM ".EVENTS_ATTENDEE_TABLE." WHERE attendee_session=%s", $attendee_session), OBJECT);
foreach ($attendees as $attendee) {
echo espresso_edit_attendee($attendee->registration_id, $attendee->id, $attendee->event_id, 'attendee', sprintf(__('Edit Registration Details for %s, %s','event_espresso'), $attendee->lname, $attendee->fname)); ?><br/>
<?php } ?>
</tr>
// Not sure why it jumps out of the table to above it.