Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adoerler opened this issue Jul 21, 2016 · 4 comments

Comments

@adoerler
Copy link

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:

  • woocommerce_api_product_response => woocommerce_rest_prepare_product
  • woocommerce_api_process_product_ => woocommerce_rest_process_product_
  • woocommerce_api_save_product_variation => woocommerce_rest_save_product_variation

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 woocommerce/woocommerce#11495

Kind regards
Andreas

@judgej
Copy link
Owner

judgej commented Jul 23, 2016

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

@psopacua
Copy link

Hi,
@adoerler thanx for the fix.

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

Kindly regards,

Pascal

@judgej
Copy link
Owner

judgej commented Dec 13, 2016

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants