judgej / wc-api-custom-meta

WordPress/WooCommerce plugin to support custom meta fields through the product API
32 stars 12 forks source link

Plugin does no longer work since Woocommerce 2.6 using new api endpoint "/wp-json/wc/v1" #16

Open adoerler opened 8 years ago

adoerler commented 8 years ago

Hi,

I lilke you plugin - its very usefull. After upgrading to woocommerce 2.6.x and switching to new Wordpress-WC-API endpoint /wp-json/wc/v1/ the plugin stopped working. After digging and debugging around for a while I've found out, that they have renamed the actions and they also missed to add one action which is needed by your plugin.

So the first change in your wc-api-custom-meta.php is to replace:

As for the missing do_action call: Please compare:

So, what I did, is to patch woocommerce as follows:

--- /public/wp-content/plugins/woocommerce/includes/api/class-wc-rest-products-controller.php   Di Jun 14 22:40:48 2016
+++ /public/wp-content/plugins/woocommerce/includes/api/class-wc-rest-products-controller.php   Di Jun 14 22:44:49 2016
@@ -1270,6 +1270,9 @@ class WC_REST_Products_Controller extends WC_REST_
            }
        }

+       // Do action for product type => needed for des-wc-api-custom-meta to save custom meta data via rest api
+       do_action( 'woocommerce_rest_process_product_meta_' . $product_type, $product, $request );
+
        return true;
    }

Now everything is working again.

I'm not sure what is the best way to update your plugin, as the calls depend on the api version used. On the woocommerce side it would be great if the would readd the action, but as far as I've read, the are not very happy with updating meta through api anyway, so that I'm not sure if the will add the missing action. But why not try at least, I've just filed an issue about this case, see https://github.com/woothemes/woocommerce/issues/11495

Kind regards Andreas

judgej commented 8 years ago

Sorry - been crazy busy over the last few days and not had a chance to look at this. Will soon.

psopacua commented 7 years ago

Hi, @adoerler thanx for the fix.

@judgej are you going to update the plugin in the future or ?

Kindly regards,

Pascal

judgej commented 7 years ago

At some point, yes. Other projects seem to take over and time flies though :-(

If there is a fix I can apply to this plugin, I'll get it pushed through quickly.

psopacua commented 7 years ago

Thanks for the response, well at this moment im trying to make a fix in the plugin, if i manage to fix it with the new hooks i will let you known