wordpresswoocommercewoocommerce-rest-apiserver-error

Woocomerce API internal server error when adding order


I am developing a online store with React-Native, which allows customers to purchase products. I am using the woocomerce API, a Wordpress plugin.

When I try to create an order from the API, it gives me an internal server error.

Here is my API call to create an order :

const data = {
        payment_method: "mollie_wc_gateway_creditcard",
        payment_method_title: "Mollie - Carte de crédit",
        set_paid: false,
        billing: {
          first_name: "John",
          last_name: "Doe",
          address_1: "1 rue des champs",
          address_2: "",
          city: "Paris",
          state: "FR",
          postcode: "75000",
          country: "FR",
          email: "john.doe@example.com",
          phone: "0636......"
        },
        shipping: {
            first_name: "John",
            last_name: "Doe",
            address_1: "1 rue des champs",
            address_2: "",
            city: "Paris",
            state: "FR",
            postcode: "75000",
            country: "FR",
            email: "john.doe@example.com",
            phone: "0636......"
        },
        line_items: [
          {
            product_id: 3884,
            quantity: 2
          },
          {
            product_id: 3198,
            variation_id: 3375,
            quantity: 1
          }
        ],
        shipping_lines: [
          {
            method_id: "lpc_sign",
            method_title: "Colissimo avec signature",
            total: "6.70"
          }
        ]
      };

    return await api.post('orders', data).then((response)=>response);

I want to create an order with two products and with "Colisimo avec signature" delivery method.

And here is the response :

{
   "additional_errors": [], 
   "code": "internal_server_error", 
   "data": {
      "status": 500
   }, 
   "message": "<p>There was a critical error on this site.</p><p><a 
               href=\"https://fr.wordpress.org/support/article/debugging-in-wordpress/\">Learn
               more on debugging WordPress.</a></p>"
}

I checked in the woocommerce logs and found this error :

2021-02-09T01:21:04-08:00 CRITICAL Uncaught Error: Call to a member function __isset() on null in /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-content/plugins/tshirtecommerce/tshirtecommerce.php:1114
Stack trace:
#0 /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-includes/class-wp-hook.php(287): tshirt_order_meta_handler(64, NULL, NULL)
#1 /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array)
#2 /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
#3 /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-content/plugins/woocommerce/includes/class-wc-deprecated-action-hooks.php(159): do_action('woocommerce_add...', 64, NULL, NULL)
#4 /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-content/plugins/woocommerce/includes/class-wc-deprecated-action-hooks.php(107): WC_Deprecated_Action_Hooks->trigger_hook('woocommerce_add...', Arr dans /homepages/17/d837071568/htdocs/clickandbuilds/LyoncapsEcommerce/wp-content/plugins/tshirtecommerce/tshirtecommerce.php at line 1114

Note that the order has been created but information such as the 2nd product and the delivery method are missing.

Created order Sorry but it's in french. Im french, so sorry for my english ^^

I noticed that the products with variations (color, size ...) are missing. Even if I don't choose a product with variations, I get the same error.

I don't know how to fix this problem. I absolutely need to solve this problem quickly because my deadline is in 1 month.

Thank you in advance for your help !


Solution

  • It was just another Wordpress plugin (Woocommerce Custom Product Designer) that interferes whith the API. I disabled this plugin and now it work!