Skip to content

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

Open
@adoerler

Description

@adoerler

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions