Skip to content

Instantly share code, notes, and snippets.

View Pebblo's full-sized avatar
🏠
Working from home

Tony Warwick Pebblo

🏠
Working from home
  • Event Espresso
  • Liverpool, UK
View GitHub Profile
@Pebblo
Pebblo / add_calendar_scripts.php
Last active September 19, 2024 11:23 — forked from joshfeck/add_calendar_scripts_everywhere.php
Add calendar scripts to a specific page. Page builder themes rejoice!
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'template_redirect', 'tw_add_ee_calendar_assets' );
function tw_add_ee_calendar_assets() {
// change is_page() parameter to match your calendar page slug
if ( class_exists( 'EED_Espresso_Calendar' ) && is_page( 'whats-on' ) ) {
global $is_espresso_calendar;
$is_espresso_calendar = TRUE;
add_action( 'wp_enqueue_scripts', array( EED_Espresso_Calendar::instance(), 'calendar_scripts' ) );
@Pebblo
Pebblo / my_custom_checkboxes_for_additional_question_groups.php
Last active January 8, 2024 23:49 — forked from joshfeck/my_custom_checkboxes_for_primary_question_groups.php
Check a question group box by default. For the Event Espresso 4 event editor. Additional Question group ID 1 (Personal Information).
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_editor_questions_notice', 'my_custom_checkboxes_for_additional_question_groups' );
function my_custom_checkboxes_for_additional_question_groups() {
echo '<script>jQuery(
"#espresso_events_Registration_Form_Hooks_Extend_additional_questions_metabox input[value=\'1\']"
)
.prop( "checked", true );</script>';
}
@Pebblo
Pebblo / tw_filter_thank_you_text_based_on_pm.php
Created August 22, 2023 13:20
Example of how to filter the thank you page text based on the select payment method used on the EE_Transaction
<?php
add_action('AHEE__thank_you_page_overview_template__top', 'tw_filter_thank_you_text_based_on_pm');
function tw_filter_thank_you_text_based_on_pm($transaction) {
$payment_method = $transaction->payment_method();
if($payment_method instanceof EE_Payment_Method) {
if($payment_method->type() == 'Invoice') {
add_filter('FHEE__thank_you_page_overview_template__order_conf_desc', 'tw_filter_thank_you_text_for_invoice');
}
@Pebblo
Pebblo / tw_ee_set_ee_rest_datetime_order_by.php
Created June 28, 2023 13:55
Example of how to change the default order_by used in for datetimes within the EE REST API.
<?php //Do not include the opening PHP tag if you already have one
add_filter('FHEE__Read__create_model_query_params', 'tw_ee_set_ee_rest_datetime_order_by', 10, 3);
function tw_ee_set_ee_rest_datetime_order_by( $model_query_params, $query_params, $model ) {
if($model instanceof EEM_Datetime) {
// Match default order_by array to compare.
$default_order_by['DTT_ID'] = 'ASC';
// Check if the order_by currently set is the default order_by.
if( $default_order_by === $model_query_params['order_by']) {
// Order by DTT_ID => ASC so override that with DTT_EVT_Start => DESC
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action(
'wp_enqueue_scripts',
'tw_ee_change_default_ee_country_and_state_option',
20
);
function tw_ee_change_default_ee_country_and_state_option(){
$custom_js = 'jQuery(document).ready(function($){';
@Pebblo
Pebblo / tw_ee_csv_add_ticket_base_price.php
Created May 18, 2023 22:28
Example of how to add an additional 'Ticket Base price' column into the CSV.
<?php
add_filter(
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
'tw_ee_csv_add_ticket_base_price',
20,
2
);
function tw_ee_csv_add_ticket_base_price(
array $csv_row,
<?php //Do not include the opening PHP tag if you already have one.
add_filter(
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
'tw_ee_csv_always_add_event_name',
20,
2
);
function tw_ee_csv_always_add_event_name(
array $csv_row,
@Pebblo
Pebblo / add_currency_code_spco.php
Last active January 27, 2023 14:59 — forked from joshfeck/add_currency_code_spco.php
Add currency code to the checkout display in Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function my_ee_add_currency_checkout() {
wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).one( "ajaxStop", function() {
jQuery("#spco-payment-info-table")
.find(".spco-grand-total .total:nth-of-type(2)")
.append("<span>(CHF)</span>");
@Pebblo
Pebblo / tw_ee_remove_address_fields_from_stripe_billing_form.php
Created January 11, 2023 21:59
Example of how to remove the State and Country fields from the Stripe payment method form
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_remove_address_fields_from_stripe_billing_form( $options, $form ) {
if( $form instanceof EE_Billing_Attendee_Info_Form
&& isset( $options[ 'name' ] )
&& $options[ 'name' ] === 'Stripe_Payment_Intent_and_Elements_Form'
) {
$fields_to_remove = array(
//'address',
//'address2',
@Pebblo
Pebblo / ee_tw_zero_vat_or_20.php
Last active October 6, 2022 19:16 — forked from joshfeck/canada_taxes.php
VAT 20 or 0? Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
/**
* PLEASE READ AND FOLLOW ALL INSTRUCTIONS IN CAPS
*
* IN ORDER FOR THIS TO WORK YOU NEED TO ADD A QUESTION USED FOR A TAX NUMBER
*
* BECAUSE THIS QUESTION SHOULD ONLY BE ASKED ONCE PER TRANSACTION
* YOU SHOULD ADD THE ABOVE QUESTION TO A GROUP ONLY ASKED FOR THE PRIMARY REGISTRANT