Last active
November 28, 2022 11:11
-
-
Save techies23/e540cfb04af1a52271a9669a2bfdfbd4 to your computer and use it in GitHub Desktop.
Override WooCommerce email order template for admin to show start link
This file contains 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 | |
add_filter( 'woocommerce_email_order_details', 'email_order_details_20221128', 1, 4 ); | |
function email_order_details_20221128( $order, $sent_to_admin, $plain_text, $email ) { | |
$GLOBALS['zoom_sent_to_admin'] = $sent_to_admin; | |
} | |
add_action( 'vczapi_woocommerce_order_item_meta', 'custom_order_meta_20221128', 99, 4 ); | |
function custom_order_meta_20221128( $content, $item_id, $item, $order ) { | |
$sent_to_admin = ! empty( $GLOBALS['zoom_sent_to_admin'] ) ? $GLOBALS['zoom_sent_to_admin'] : false; | |
if ( $order->get_status() === "completed" || $order->get_status() === "processing" ) { | |
$product_id = $item['product_id']; | |
$post_id = get_post_meta( $product_id, '_vczapi_zoom_post_id', true ); | |
if ( ! empty( $post_id ) ) { | |
$fields = get_post_meta( $post_id, '_meeting_fields_woocommerce', true ); | |
$meeting_details = get_post_meta( $post_id, '_meeting_zoom_details', true ); | |
if ( ! empty( $meeting_details ) && ! empty( $fields['enable_woocommerce'] ) ) { | |
$tz_for_check = new DateTimeZone( 'UTC' ); | |
$dateTimeTomorrow = new DateTime( 'NOW', $tz_for_check ); | |
if ( ( true == apply_filters( 'vczapi_woocommerce_show_past_meetings_in_account_details', ( ! empty( get_option( 'vczapi_wc_hide_completed_meetings' ) ) ) ) ) && $meeting_details->type != 8 && $meeting_details->type != 9 && $meeting_details->type != 3 ) { | |
$meeting_date_to_check = vczapi_dateConverter( $meeting_details->start_time, 'UTC', false ); | |
if ( $dateTimeTomorrow >= $meeting_date_to_check ) { | |
return; | |
} | |
} elseif ( ( true == apply_filters( 'vczapi_woocommerce_show_past_meetings_in_account_details', ( ! empty( get_option( 'vczapi_wc_hide_completed_meetings' ) ) ) ) ) && ( $meeting_details->type == 8 || $meeting_details->type == 9 ) ) { | |
if ( class_exists( 'Codemanas\ZoomPro\Helpers' ) ) { | |
$last_occurrence = end( $meeting_details->occurrences ); | |
$meeting_date_to_check = vczapi_dateConverter( $last_occurrence->start_time, 'UTC', false ); | |
if ( $dateTimeTomorrow >= $meeting_date_to_check ) { | |
return; | |
} | |
} | |
} | |
ob_start(); | |
?> | |
<ul class="vczapi-woocommerce-email-mtg-details"> | |
<li class="vczapi-woocommerce-email-mtg-details--list1"> | |
<strong><?php _e( 'Meeting Detailsssss', 'vczapi-woocommerce-addon' ); ?> | |
:</strong></li> | |
<li class="vczapi-woocommerce-email-mtg-details--list2"> | |
<strong><?php _e( 'Topic', 'vczapi-woocommerce-addon' ); ?> | |
:</strong> <?php echo $meeting_details->topic; ?></li> | |
<li class="vczapi-woocommerce-email-mtg-details--list3"> | |
<strong><?php _e( 'Start Time', 'vczapi-woocommerce-addon' ); ?> | |
:</strong> | |
<?php | |
echo vczapi_dateConverter( $meeting_details->start_time, $meeting_details->timezone, 'F j, Y @ g:i a' ); | |
?></li> | |
<li class="vczapi-woocommerce-email-mtg-details--list3"> | |
<strong><?php _e( 'Timezone', 'vczapi-woocommerce-addon' ); ?> | |
:</strong> | |
<?php | |
echo $meeting_details->timezone; | |
?></li> | |
<li class="vczapi-woocommerce-email-mtg-details--list4"> | |
<?php if ( $sent_to_admin ) { ?> | |
<a target="_blank" rel="nofollow" | |
href="<?php echo esc_url( $meeting_details->start_url ); ?>"><?php echo apply_filters( 'vczapi_woocommerce_start_via_app_text', __( 'Start via App', 'vczapi-woocommerce-addon' ) ); ?></a> | |
<?php } else { ?> | |
<a target="_blank" rel="nofollow" | |
href="<?php echo esc_url( $meeting_details->join_url ); ?>"><?php echo apply_filters( 'vczapi_woocommerce_join_via_app_text', __( 'Join via App', 'vczapi-woocommerce-addon' ) ); ?></a> | |
<?php } ?> | |
</li> | |
<?php if ( empty( $disabled ) && ! empty( $meeting_details->password ) ) { ?> | |
<li class="vczapi-woocommerce-email-mtg-details--list5"> | |
<?php echo \Codemanas\ZoomWooCommerceAddon\DataStore::get_browser_join_link( $post_id, $meeting_details->password, $meeting_details->id ); ?> | |
</li> | |
<?php } ?> | |
</ul> | |
<?php | |
return ob_get_clean(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment