Created
July 23, 2019 06:36
-
-
Save rafsuntaskin/18ea17ec63531ab89bb3e54abdf3561f to your computer and use it in GitHub Desktop.
Disable tax for Event Tickets WooCommerce products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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