Skip to content

Instantly share code, notes, and snippets.

@rafsuntaskin
Created July 23, 2019 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafsuntaskin/18ea17ec63531ab89bb3e54abdf3561f to your computer and use it in GitHub Desktop.
Save rafsuntaskin/18ea17ec63531ab89bb3e54abdf3561f to your computer and use it in GitHub Desktop.
Disable tax for Event Tickets WooCommerce products
<?php
add_action( 'event_tickets_after_save_ticket', 'rt_disable_tax_for_event_tickets', 10, 4 );
function rt_disable_tax_for_event_tickets( $post_id, $ticket, $raw_data, $class_name ) {
//hardcoded for WooCommerce only
if ( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' != $class_name ) {
return;
}
$product = wc_get_product( $ticket->ID );
if ( ! is_object( $product ) || ! ($product instanceof WC_Product) ) {
return;
}
//set tax status to none
$product->set_tax_status( 'none' );
$product->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment