Support

Home Forums Event Espresso Premium IF customer chooses check option on checkout then changes to CC price broken Reply To: IF customer chooses check option on checkout then changes to CC price broken

Reply To: IF customer chooses check option on checkout then changes to CC price broken

Author Replies
Bob Randklev # Posted on May 17, 2018 at 6:24 am

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 );
Do NOT follow this link or you will be banned from the site!