Home › Forums › Ticket Products › Event Tickets Plus › Disable Ticket Emails
- This topic has 9 replies, 4 voices, and was last updated 9 years, 9 months ago by
Vivianne.
-
AuthorPosts
-
May 30, 2016 at 2:33 am #1120299
Vivianne
ParticipantIs 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.May 30, 2016 at 9:08 am #1120396Brian
MemberHi,
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
June 11, 2016 at 3:39 am #1125538Vivianne
ParticipantThanks 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?June 12, 2016 at 1:32 pm #1125880Brian
MemberHi,
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
June 17, 2016 at 6:22 am #1128363Vivianne
ParticipantI 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?
June 17, 2016 at 12:55 pm #1128647Brian
MemberHi,
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?June 20, 2016 at 3:45 am #1129163Vivianne
ParticipantHi 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?June 20, 2016 at 5:37 am #1129195Brian
MemberOh 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
July 5, 2016 at 9:35 am #1135502Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Disable Ticket Emails’ is closed to new replies.
