Disable Ticket Emails

Home Forums Ticket Products Event Tickets Plus Disable Ticket Emails

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1120299
    Vivianne
    Participant

    Is there a chance to disable the ticket emails for one specific shipping option?
    My client uses the shipping options “print@home” and “real shipping”.
    If someone chooses to order “real” paper tickets they choose “real shipping”. But then they shouldn´t receive the ticket email also.

    #1120396
    Brian
    Member

    Hi,

    Thanks for using our plugins. I can try to help out here, but we are limited in supporting customizations per our terms and conditions.

    We do not have a feature to disable tickets, but we do have this snippet to do that:

    https://gist.github.com/jesseeproductions/9ff8863230e5a05b9303

    If you can find a way to detect the shipping selection of the order and then disable when it has that value you could use that snippet to prevent the tickets from being sent.

    I found this guide that might help get that status:

    https://stanhub.com/how-to-detect-chosen-shipping-method-in-woocommerce/

    I can try to help answer some questions about this, but limited in providing much more then this.

    Cheers

    #1125538
    Vivianne
    Participant

    Thanks for your code snippets.
    I added following code to my functions.php:

    add_action( 'init', 'wootickets_stop_sending_email' );
    
    function wootickets_stop_sending_email() {
    	$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    	$chosen_shipping = $chosen_methods[0]; 
    
    	if ( (class_exists( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' )) AND ($chosen_shipping == 'international_delivery') ) {
    		$woo = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
    		remove_filter( 'woocommerce_email_classes', array( $woo, 'add_email_class_to_woocommerce' ) );
    		add_action( 'woocommerce_email_after_order_table', array( $woo, 'add_tickets_msg_to_email' ) );
    	}
    }

    It works in the frontend, but I can´t load my backend anymore. It only shows a white page.
    Do you see an error I can´t find?

    #1125880
    Brian
    Member

    Hi,

    I do not see any errors in the coding. Do you have double <?php tags?

    What error do you get when you turn on WordPress debug:

    Setup a href=”https://codex.wordpress.org/Debugging_in_WordPress#Example_wp-config.php_for_Debugging”>WordPress Debug to see what errors are showing when you try to recreate the issue a couple times in this file: /wp-content/debug.log

    #1128363
    Vivianne
    Participant

    I get an Error 500 – Server Error.
    The debug file doesn´t say anything about my function.

    If I delete this part from my function, I don´t get the backend error.

    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0]; 

    But without it, I cannot define, which shipping method I mean.

    Any idea?

    #1128647
    Brian
    Member

    Hi,

    I am not sure why that coding is needed maybe there is another way to include it?

    It is hard to say with customizations what the issue is.

    Is this all the coding:

    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0];

    or is it wrapping in something else?

    #1129163
    Vivianne
    Participant

    Hi Brian

    I posted my complete coding on June 11th.
    Here again:

    add_action( 'init', 'wootickets_stop_sending_email' );
     
    function wootickets_stop_sending_email() {
        $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
        $chosen_shipping = $chosen_methods[0]; 
     
        if ( (class_exists( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' )) AND ($chosen_shipping == 'international_delivery') ) {
            $woo = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
            remove_filter( 'woocommerce_email_classes', array( $woo, 'add_email_class_to_woocommerce' ) );
            add_action( 'woocommerce_email_after_order_table', array( $woo, 'add_tickets_msg_to_email' ) );
        }
    }
    

    If I delete this part, which I need to define which emails shouldn´t be sent, I get the error:

    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0];

    Do you have the whole picture now?
    You pointed me in the direction with these two code snippets (your first answer in this thread).
    Any idea why I get an error?

    #1129195
    Brian
    Member

    Oh my bad sorry about that.

    I added your coding and get this error:

    Fatal error: Call to a member function get() on null which is in reference to this line:

    $chosen_methods = WC()->session->get( ‘chosen_shipping_methods’ );

    This is in WooCommerce 2.6.1.

    This WC()->session is for getting information from the visitor as they are on the site.

    You would want to find out an orders shipping method and not the users.

    I do not know of a way to do that with the original snippet I provided.

    Maybe this snippet can help point you in the right direction:

    https://wordpress.org/support/topic/disable-some-mail-notifications-in-woocommerce#post-4544829

    Beyond that I do not have any resources to provide.

    Thanks

    #1135502
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Disable Ticket Emails’ is closed to new replies.