• Resolved mookie4a4

    (@mookie4a4)


    PHP Fatal error: Uncaught Error: Cannot use object of type WC_Product_Variation as array in /wp-content/plugins/wc-api-custom-meta/wc-api-custom-meta.php:156\nStack trace:\n#0 /wp-content/plugins/wc-api-custom-meta/wc-api-custom-meta.php(194): Academe_Wc_Api_Custom_Meta::updateCustomMeta(9127, Object(WC_Product_Variation))\n#1 /wp-includes/class-wp-hook.php(298): Academe_Wc_Api_Custom_Meta::updateVariationCustomMeta(9127, 0, Object(WC_Product_Variation))\n#2 /wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(”, Array)\n#3 /wp-includes/plugin.php(453): WP_Hook->do_action(Array)\n#4 /wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-products.php(1432): do_action(‘woocommerce_api…’, 9127, 0, Object(WC_Product_Variation))\n#5 /wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-products. in /wp-content/plugins/wc-api-custom-meta/wc-api-custom-meta.php on line 156

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter mookie4a4

    (@mookie4a4)

    array keys need to be objects:
    $data->custom_meta

    I think i have the same issue. Setting custom_meta, but does not get stored.

    Maybe you can provide a full solution here:
    https://github.com/judgej/wc-api-custom-meta/issues/22

    Thread Starter mookie4a4

    (@mookie4a4)

    So it looks like the latest Woocommerce API supports Meta data.
    Going to convert my code to use the new version.

    line 109:

    replace
    $product_id = $product->id;

    with:
    $product_id = $product->get_id();

    In WC 3.0 you need to call an other method to get the ID

    Kudos to Jason Judge for this exellent plugin!

    Robert

    Plugin Author Jason Judge

    (@judgej)

    Thanks Robert, I’ll try to get that into a release today.

    Plugin Author Jason Judge

    (@judgej)

    Release 0.7.1 just made with this quick fix. I’ve not had time to test it properly, so I’ll try to fix any consequential issues quickly with enough information.

    I have the same issue, with Woocommerce 3.1.1. I have applied the fix but it still doesn’t work. When I try to create a product with more than one variation, only one is created and I get the error ‘Fatal error: Uncaught Error: Cannot use object of type WC_Product_Variation as array…’

    Any ideas?

    Thanks in advance!

    Plugin Author Jason Judge

    (@judgej)

    Please use the new v2 REST API (WC 3.x) instead of this plugin. It now does everything this plugin does out of the box. The github README gives some examples of how you would manage the metadata fields:

    https://github.com/judgej/wc-api-custom-meta

    WC 3.1.x has a very different API (v2 REST) and you should be using that now.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Does not work for woo 3.0’ is closed to new replies.