Created
February 8, 2021 05:07
-
-
Save digamber89/4aec25954256936936b2323b5088b3ce to your computer and use it in GitHub Desktop.
Zoom Integration for WooCommerce - remove Host from Cart Details
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 | |
if ( class_exists( '\Codemanas\ZoomWooCommerceAddon\Cart' ) ) { | |
remove_filter( 'woocommerce_cart_item_name', [ \Codemanas\ZoomWooCommerceAddon\Cart::get_instance(), 'cart_meeting_details' ], 10 ); | |
add_filter( 'woocommerce_cart_item_name', 'cm_zoom_cart_meeting_details', 10, 3 ); | |
function cm_zoom_cart_meeting_details( $name, $cart_item, $cart_item_key ) { | |
$product_id = $cart_item['product_id']; | |
$post_id = get_post_meta( $product_id, '_vczapi_zoom_post_id', true ); | |
if ( ! empty( $post_id ) ) { | |
$meeting_details = get_post_meta( $post_id, '_meeting_fields', true ); | |
$zoom_details = get_post_meta( $post_id, '_meeting_zoom_details', true ); | |
$users = video_conferencing_zoom_api_get_user_transients(); | |
$host_name = false; | |
if ( ! empty( $zoom_details ) && is_object( $zoom_details ) ) { | |
if ( ! empty( $users ) ) { | |
foreach ( $users as $user ) { | |
if ( $zoom_details->host_id === $user->id ) { | |
$host_name = esc_html( $user->first_name . ' ' . $user->last_name ); | |
$host_name = ! empty( $host_name ) ? $host_name : $user->email; | |
break; | |
} | |
} | |
} | |
$add_name = sprintf( | |
'<p style="margin-top:10px;"><strong>' . __( 'Time', 'vczapi-woocommerce-addon' ) . ':</strong><br>%s</p><p><strong>' . __( 'Timezone', 'vczapi-woocommerce-addon' ) . ':</strong><br>%s</p>', | |
vczapi_dateConverter( $zoom_details->start_time, $zoom_details->timezone, 'F j, Y, g:i a', true ), | |
esc_html( $meeting_details['timezone'] ) | |
); | |
$name .= apply_filters( 'vczapi_woocommerce_cart_meeting_details', $add_name, $cart_item, $cart_item_key ); | |
} | |
} | |
return $name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment