Last active
February 24, 2019 01:20
-
-
Save sumnermic/a98060b88f17f12eef5222694bb1df7e to your computer and use it in GitHub Desktop.
Set Modern Tribe Event Tickets Plus custom SKU on ticket save
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
<?php | |
/* | |
* Set Modern Tribe Event Tickets Plus custom SKU as: | |
* Title - StartDate | |
* @link https://smnr.co/2NqELpA | |
*/ | |
add_action( 'event_tickets_after_save_ticket', 'tribe_events_set_sku', 10, 4 ); | |
function tribe_events_set_sku( $event_id, $ticket, $raw_data, $classname ) { | |
if ( ! empty( $ticket ) && isset( $ticket->ID ) ) { | |
$event_start_date = str_replace(" ", "-", tribe_get_start_date( $event_id, false )); | |
$sku = sprintf( '%s - %s', get_the_title($event_id), $event_start_date ); | |
update_post_meta( $ticket->ID, '_sku', $sku ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment