Support » Plugin: WooCommerce » create customer via API fails

  • Resolved carolinekiel

    (@carolinekiel)


    Hi,
    I have a problem creating a new customer using the wc API.
    Running GET commands works fine, so authentication is not the problem. But when trying a post command, I get the following error in the debug log:

    *****
    [17-Oct-2019 22:46:18 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_error_code() on null in C:\Websites\Docks\wp-content\plugins\woocommerce\includes\wc-user-functions.php:82
    Stack trace:
    #0 C:\Websites\Docks\wp-content\plugins\woocommerce\includes\data-stores\class-wc-customer-data-store.php(107): wc_create_new_customer(‘test1@pingus.de’, ‘Test.Doe’, ‘EZMyVO48&960’)
    #1 C:\Websites\Docks\wp-content\plugins\woocommerce\includes\class-wc-data-store.php(169): WC_Customer_Data_Store->create(Object(WC_Customer))
    #2 C:\Websites\Docks\wp-content\plugins\woocommerce\includes\abstracts\abstract-wc-data.php(218): WC_Data_Store->create(Object(WC_Customer))
    #3 C:\Websites\Docks\wp-content\plugins\woocommerce\packages\woocommerce-rest-api\src\Controllers\Version1\class-wc-rest-customers-v1-controller.php(342): WC_Data->save()
    #4 C:\Websites\Docks\wp-includes\rest-api\class-wp-rest-server.php(946): WC_REST_Customers_V1_Controller->create_item(Object(WP_REST_Request))
    #5 C:\Websites\Docks\wp-includes\rest-api\class-wp-rest-server.php(329): WP_RE in C:\Websites\Docks\wp-content\plugins\woocommerce\includes\wc-user-functions.php on line 82
    *****

    Can anyone assist me here?

    Best regards,
    Caroline

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • carolinekiel

    (@carolinekiel)

    Updates:
    – disabling all plugins didn’t help.
    – creating a new product via API POST works fine.
    – editing a product via PUT works fine.
    – editing a customer via PUT works fine.

    The issue seems to exist only in creating a new customer.

    Plugin Support RK

    (@riaanknoetze)

    Hi there,

    When looking at the error, two interesting things show up:

    carolinekiel

    (@carolinekiel)

    Hi,
    Thank you for your hint. Will try this later. One question upfront: how can I define, which version of the API will be used?
    I used the example code from the API‘s documentation:
    curl -X POST https://example.com/wp-json/wc/v3/customers \
    -u consumer_key:consumer_secret \
    -H “Content-Type: application/json” \
    -d ‘{…
    So, I thought, it would use version 3?

    Best regards,
    Caroline

    carolinekiel

    (@carolinekiel)

    Hi,
    I found the failing function and was able to correct it.
    Thank you very much for the instant support.

    All the best,
    Caroline

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.