Skip to content

Instantly share code, notes, and snippets.

@vicskf
Last active October 19, 2017 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicskf/d588dd6d3c0f117ede547995be249ca7 to your computer and use it in GitHub Desktop.
Save vicskf/d588dd6d3c0f117ede547995be249ca7 to your computer and use it in GitHub Desktop.
Event Tickets Plus > Adds different custom message to order emails depending on order items
<?php
/**
* Adds different custom message to order emails depending on order items
* @author Victor Zarranz
*/
add_action( 'woocommerce_email_order_details', 'add_custom_message', 10, 1 );
function add_custom_message( $order ) {
$wootix = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$items = $order->get_items();
$has_ticket = false;
$has_product = false;
foreach ( $items as $item ) {
$event = '';
$item_data = $item->get_data();
$event = $wootix->get_event_for_ticket( $item_data['product_id'] );
if ( ! empty( $event ) ) {
$has_ticket = true;
} else {
$has_product = true;
}
}
if ( $has_product && $has_ticket ) {
// has both products and tickets in the order
printf(
'<p>%1$s</p>',
'Thank you for signing up for an event. See shipping details for your products below.'
);
} elseif ( $has_ticket ) {
// only has ticket/s in the order
printf(
'<p>%1$s</p>',
'Thank you for signing up for an event.'
);
} else {
// only has products
printf(
'<p>%1$s</p>',
'Thank you for your purchase. See shipping details for your products below.'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment