Last active
January 12, 2016 20:22
-
-
Save ni-le/c21ae79a40f3098f8477 to your computer and use it in GitHub Desktop.
Events Tickets Pro - Link events to existing ticket product
This file contains hidden or 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
/* | |
* Add or remove event ids to an existing ticket product | |
*/ | |
function tribe_link_product_event ( $product_id, $event_id ) { | |
if ( !in_array($event_id, get_post_meta( $product_id, '_tribe_wooticket_for_event') ) ) { | |
add_post_meta( $product_id, '_tribe_wooticket_for_event', $event_id ); | |
} | |
} | |
function tribe_unlink_product_event ( $product_id, $event_id ) { | |
delete_post_meta( $product_id, '_tribe_wooticket_for_event', $event_id ); | |
} | |
/* | |
* Replace start_event_id and end_event_id with respective values | |
* and uncomment function for events imported via csv | |
* or add individual lines for each linking: | |
* tribe_link_product_event(<product_id>,<event_id>); | |
* for removing rename function to ***_unlink_*** | |
/* | |
function link_multiple_events_to_tickets() { | |
$product_ids = array(); // insert product id | |
$start_event_id = Null; // replace with actual event ids | |
$end_event_id = Null; | |
for( $add_event_id = $start_event_id; $add_event_id <= $end_event_id; $add_event_id++ ) { | |
for( $prod_iter = 0, $products = count($product_ids); $prod_iter < $products; ++$prod_iter ) { | |
tribe_link_product_event( $product_ids[$prod_iter], $add_event_id ); | |
} | |
} | |
} | |
link_multiple_events_to_tickets(); //comment out when linkages made |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment