Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- This function will set a default category to an event product when it is saved. Note that this sets the category each time the event is saved.
- For installation functions see http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
- */
- /**
- * @param bool $result
- * @param EM_Event $EM_Event
- * @return bool
- */
- function em_woocommerce_default_category( $result, $EM_Event ){
- if( $result && $EM_Event->event_rsvp ) {
- // update event product
- $sku = 'EM-' . $EM_Event->event_id;
- $product_id = wc_get_product_id_by_sku($sku);
- if( !empty($product_id) ) {
- wp_set_object_terms( $product_id, 'custom tag goes here', 'product_tag' );
- }
- }
- return $result;
- }
- add_filter('em_event_save', 'em_woocommerce_default_category', 99999, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement