Skip to content

Instantly share code, notes, and snippets.

@wtmujeebu
Created June 29, 2021 11:05
Show Gist options
  • Save wtmujeebu/4f3b5e924a53a2cbb3334d7e0b2643b5 to your computer and use it in GitHub Desktop.
Save wtmujeebu/4f3b5e924a53a2cbb3334d7e0b2643b5 to your computer and use it in GitHub Desktop.
WC Booking product compatibility
<?php
add_action('wt_woocommerce_product_import_inserted_product_object', 'wt_woocommerce_product_import_inserted_product_object', 10, 2);
function wt_woocommerce_product_import_inserted_product_object($product, $data) {
if (isset($data['meta_data'])) {
foreach ($data['meta_data'] as $meta) {
if (strpos($meta['key'], '_wc_booking') !== false) {
// booking metas
if (!empty($meta['value'])) {
if (strpos($meta['key'], '_wc_booking_availability') !== false) {
$meta['value'] = json_decode($meta['value'], true);
//continue;
}
if (strpos($meta['key'], '_wc_booking_pricing') !== false) {
$meta['value'] = json_decode($meta['value'], true);
//continue;
}
update_post_meta($product->get_id(), $meta['key'], $meta['value']);
}
continue;
}
}
}
}
add_filter('wt_iew_importer_skip_from_evaluation', 'wt_iew_importer_skip_from_evaluation');
function wt_iew_importer_skip_from_evaluation($evl_arra) {
$new_element_evl_arra = array('meta:_wc_booking_availability', 'meta:_wc_booking_pricing');
$evl_arra = array_merge($evl_arra,$new_element_evl_arra);
return $evl_arra;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment