From b802c3c0eaf8392da196425b3306d063b3da73b0 Mon Sep 17 00:00:00 2001 From: Pascal Sopacua Date: Tue, 13 Dec 2016 15:39:05 +0100 Subject: [PATCH 1/3] Added support for Woocommerce 2.6+ --- wc-api-custom-meta.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wc-api-custom-meta.php b/wc-api-custom-meta.php index 71b0fa4..f9ad7cc 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', + ['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') + ]; + + Wc_Api_Custom_Meta::updateCustomMeta($post->ID, $metaData); + } } Academe_Wc_Api_Custom_Meta::initialize(); From a275377ae10c58ee7fec8ae9f2d13084a63b1627 Mon Sep 17 00:00:00 2001 From: Pascal Sopacua Date: Wed, 14 Dec 2016 13:44:40 +0100 Subject: [PATCH 2/3] add action classname fix --- wc-api-custom-meta.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wc-api-custom-meta.php b/wc-api-custom-meta.php index f9ad7cc..466279b 100644 --- a/wc-api-custom-meta.php +++ b/wc-api-custom-meta.php @@ -98,7 +98,7 @@ public static function initialize() // WooCommerce 2.6+ support add_action('woocommerce_rest_insert_product', - ['Wc_Api_Custom_Meta', 'updateProductMetaAfter'], + ['Academe_Wc_Api_Custom_Meta', 'updateProductMetaAfter'], 10, 3 ); From a30be8de35f5d8b42fc1ac58c6c0499a4a3b2a7c Mon Sep 17 00:00:00 2001 From: Pascal Sopacua Date: Wed, 14 Dec 2016 13:47:13 +0100 Subject: [PATCH 3/3] [FIX] class name in function --- wc-api-custom-meta.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wc-api-custom-meta.php b/wc-api-custom-meta.php index 466279b..5d8e0d3 100644 --- a/wc-api-custom-meta.php +++ b/wc-api-custom-meta.php @@ -215,7 +215,7 @@ public static function updateProductMetaAfter($post, $request, $new) 'remove_custom_meta' => $request->get_param('remove_custom_meta') ]; - Wc_Api_Custom_Meta::updateCustomMeta($post->ID, $metaData); + Academe_Wc_Api_Custom_Meta::updateCustomMeta($post->ID, $metaData); } }