Skip to content

Instantly share code, notes, and snippets.

@GeoffEW
Last active May 26, 2017 02:18
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 GeoffEW/dc504166ac629c226fa9b1f8988bf082 to your computer and use it in GitHub Desktop.
Save GeoffEW/dc504166ac629c226fa9b1f8988bf082 to your computer and use it in GitHub Desktop.
WooCommerce Tickets - Set Catalog visibility to Hidden for all Tickets Raw
<?php
/*
* The Events Calendar - WooCommerce Tickets - Set Catalog visibility to Hidden for all Tickets
* Alternative Hooks:
* wootickets_after_update_ticket
* wootickets_after_create_ticke
* @version 3.12
*/
add_action( 'wootickets_after_save_ticket', 'tribe_events_woo_change_visibility' );
function tribe_events_woo_change_visibility( $ticket_ID ) {
if ($product = wc_get_product($ticket_ID)) {
$product->set_catalog_visibility('hidden');
$product->save();
}
}
Copy link

ghost commented Apr 21, 2017

This doesn't work for WooCommerce 3.0 (they switched from post meta to terms). Try this instead.

add_action( 'wootickets_after_save_ticket', 'tribe_events_woo_change_visibility' );
function tribe_events_woo_change_visibility( $ticket_ID ) {
	if ($product = wc_get_product($ticket_ID)) {
		$product->set_catalog_visibility('hidden');
		$product->save();
	}	
}

@GeoffEW
Copy link
Author

GeoffEW commented May 17, 2017

Thank you so much @f4w-pwharton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment