I know this is “old school” but client has an option for each class to pay by check or credit card. Customers get a $10 discount for paying by check.
So if you go to check out and choose check… then after you submit your info/registration and on the final checkout page change your mind and choose credit card… the price doesn’t change so customers get the “check” price on credit card check out.
So customer has to call clients for $10 charge.
We’ve cleared Cloudflare cache and have our exceptions setup per the attached image.
I don’t think this is a caching issue, it’s more that Event Espresso doesn’t have a way to enforce that type of discount if it’s tied to a specific payment type.
May I ask how is the discount given in the first place? Are they selecting a ticket option or inputing a promo code at checkout? I’m not aware of an option within the payment methods that gives a discount if a specific type of payment is selected at checkout. Maybe that’s something that was custom developed for your website?
They set two pricing options in the event for the customer to choose like:
$350 Payment by check
$360 payment by CC
Ok, so that’s 2 different ticket options within the event and EE has no way to know which payment method should be used for either, it just knows which payment methods are available for the event itself (not the tickets within that event).
There’s no way to change the ticket selection based on the payment method selected but what you can do tell EE to only show a check payment method if the ticket name contains the string ‘check’, you can do that using this example:
Add that to a custom functions plugin on your site and if the user selects a ticket that is named ‘Payment by check’ EE will only show a check payment method, otherwise it will show all payment methods.
That’s exactly what the function should do. If the ticket name has ‘check’ in the name it should only show the check payment method.
You said it worked better with the function but what is it doing on your site to make it better? As it looks like it’s not doing anything from the above.
Sorry I never should have said that, I was confusing something else with this.
Here’s our complete functions.php. We’ve added a number of items over the years so maybe you can see something that is conflicting?
<?php
function ee_change_ticket_messaging_registration( $translated, $original, $domain ) {
$strings = array(
'Available Tickets' => 'Choose Payment Option',
' / ticket' => ' / class',
'Ticket Details' => 'Class Details',
'Ticket Sale Dates' => 'Class Dates',
'Please note that a maximum number of %d tickets can be purchased for this event per order.' => 'Please note that a maximum number of %d registrations can be purchased for this event per order.',
'The dates when this ticket is available for purchase.' => 'The dates when this class registration is available for purchase.',
'This ticket allows access to the following event dates and times. "Remaining" shows the number of this ticket type left:' => 'This class registration allows access to the following event dates and times. "Remaining" shows the number of this registration type left:',
'This Ticket<br/>Sold' => 'This Class<br/>Sold',
'This Ticket<br/>Left' => 'This Class<br/>Left',
'Total Tickets<br/>Sold' => 'Total Classes<br/>Sold',
);
if ( isset( $strings[$original] ) ) {
$translations = get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'ee_change_ticket_messaging_registration', 10, 3 );
// Code to display EE3 custom meta
function display_custom_meta_in_ee4( $atts ){
global $post;
extract( shortcode_atts( array( 'type' => '', 'name' => '' ), $atts ) );
$post_meta = get_post_meta( $post->ID, $name, TRUE );
return $post_meta;
}
add_shortcode( 'EE_META', 'display_custom_meta_in_ee4' );
/**
* The purpose of this snippet is to filter the event archive (and event taxonomy archive) pages so that they exclude events
* that have tickets no longer on sale.
*
* NOTE: The query for the ticket expiry time is correct at time of posting, but at some point in the future there will be a
* change to how date queries are done with Event Espresso and this snippet will be out of date then. Watch for blog posts
* about datetime changes.
*
* To Implement this code, add it to the bottom of your themes functions.php file, or add it to a site specific plugin.
*
*/
function ee_view_details_button() {
return 'Click Here for Class Details & Registration';
}
add_filter ('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', 'ee_view_details_button');
/**** change default to mc visa****/
function my_ee_change_add_default_ticket() {
wp_add_inline_script(
'ticket_selector',
'jQuery( document ).ready(function($) {
$(".ee-ticket-creditdebit-card")
.find("input.ticket-selector-tbl-qty-slct")
.prop("checked", true);
} );'
);
}
add_action( 'wp_enqueue_scripts', 'my_ee_change_add_default_ticket', 11 );
//***Relevassi search form shortcode [searchform] ****/
add_shortcode('searchform', 'rlv_search_form');
function rlv_search_form() {
$url = get_site_url();
$form = <<<EOH
<form role="search" method="get" id="searchform" class="searchform" action="$url">
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</form>
EOH;
return $form;
}
//*** Change name to Upcoming Classes - Sept 2017 ***//
add_action(
'FHEE__archive_espresso_events_template__upcoming_events_h1',
function(){return 'Upcoming Classes';}
);
//*** May 17 2018 *** after choosing check only display check on checkout ***//
function tw_ee_only_check_payment_method_based_on_ticket_name($payment_methods, $transaction, $scope) {
//Double check we have a transaction object.
if ( $transaction instanceof EE_Transaction) {
//Initialize an array used to hold the ticket names.
$ticket_names = array();
//Loop over all registrations and add the ticket name for each reg to the ticket_names array.
foreach( $transaction->registrations() as $registration ) {
$ticket_names[] = $registration->ticket()->name();
}
//Loop over ticket_names, if any of them have 'check' in the name then pull a check payment method and return only that.
foreach($ticket_names as $ticket_name){
if (strpos($ticket_name, 'check') !== false) {
$check_payment_method = EEM_Payment_Method::instance()->get_one_of_type( 'Check' );
if( $check_payment_method instanceof EE_Payment_Method) {
$payment_methods = array();
$payment_methods[] = $check_payment_method;
break;
}
}
}
}
return $payment_methods;
}
add_filter('FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', 'tw_ee_only_check_payment_method_based_on_ticket_name', 20, 3 );
The above shouldn’t really slow down the request all that much, if it’s a check ticket it does query the database to pull a check payment method but it shouldn’t slow down the site all that much at all really.
The client has tested and they are ok with it so we will monitor and advise if there are any issues.
Thanks again for the help
Viewing 10 reply threads
The support post ‘IF customer chooses check option on checkout then changes to CC price broken’ 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.