Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Zoom Integration for WooCommerce - remove Host from Cart Details
<?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