diff --git a/wc-api-custom-meta.php b/wc-api-custom-meta.php index 71b0fa4..5d8e0d3 100644 --- a/wc-api-custom-meta.php +++ b/wc-api-custom-meta.php @@ -95,6 +95,13 @@ public static function initialize() 10, 3 ); + + // WooCommerce 2.6+ support + add_action('woocommerce_rest_insert_product', + ['Academe_Wc_Api_Custom_Meta', 'updateProductMetaAfter'], + 10, + 3 + ); } /** @@ -193,6 +200,23 @@ public static function updateCustomMeta($id, $data) { public static function updateVariationCustomMeta($id, $menu_order, $data) { Academe_Wc_Api_Custom_Meta::updateCustomMeta($id, $data); } + + + + + /** + * Support for WooCommerce 2.6+ + */ + public static function updateProductMetaAfter($post, $request, $new) + { + // Setup meta data + $metaData = [ + 'custom_meta' => $request->get_param('custom_meta'), + 'remove_custom_meta' => $request->get_param('remove_custom_meta') + ]; + + Academe_Wc_Api_Custom_Meta::updateCustomMeta($post->ID, $metaData); + } } Academe_Wc_Api_Custom_Meta::initialize();