Google calender sync addons bug with solution
Issue #1027
new
The function sync_to_gcal uses an addons loop with the wrong metadata
in file woocommerce-appointments/includes/class-wc-appointments-gcal.php
Here is the modded addons code, would be nice to adopt it into the next plugin update:
// Addons and other order items.
if ( is_a( $order, 'WC_Order' ) ) {
foreach ( $order->get_items() as $order_item_id => $order_item ) {
if ( $order_item_id !== WC_Appointment_Data_Store::get_appointment_order_item_id( $appointment_id ) ) {
continue;
}
/* wrong loop
foreach ( $order_item->get_meta_data() as $order_meta_data ) {
$the_meta_data = $order_meta_data->get_data();
if ( is_serialized( $the_meta_data['value'] ) ) {
continue;
}
if ( is_array( $the_meta_data['key'] ) ) {
continue;
}
if ( is_array( $the_meta_data['value'] ) && ! empty( $the_meta_data['value'] ) ) {
$onedimensional_arr = [];
foreach ( $the_meta_data['value'] as $meta_data_value ) {
// Skip deep arrays.
if ( is_array( $meta_data_value ) ) {
continue;
}
$onedimensional_arr[] = $meta_data_value;
}
$the_meta_data['value'] = implode( ', ', $onedimensional_arr );
}
// Fix for WooCommerce TM Extra Product Options plugin.
if ( '_tmcartepo_data' === $the_meta_data['key'] || '_tm_epo_product_original_price' === $the_meta_data['key'] || '_tm_epo' === $the_meta_data['key'] ) {
continue;
}
$description .= apply_filters( 'woocommerce_appointments_gcal_sync_order_meta', sprintf( '%s: %s', rawurldecode( html_entity_decode( $the_meta_data['key'] ) ), rawurldecode( html_entity_decode( $the_meta_data['value'] ) ) ), $the_meta_data, $order ) . PHP_EOL;
}
*/
foreach ( $order_item->get_all_formatted_meta_data() as $meta_id => $meta ) {
$description .= apply_filters( 'woocommerce_appointments_gcal_sync_order_meta', sprintf( '%s: %s', rawurldecode( html_entity_decode( $meta->display_key ) ), rawurldecode( html_entity_decode( $meta->display_value ) ) ), $meta, $order ) . PHP_EOL;
}
}
}
Comments (1)
-
reporter - Log in to comment
Reported here.