Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19938
    Shazaan Ali
    Participant

    Hello

    I have been using the FREE version for a while. But I was having issues with creating orders via API.

    When a coupon has restrictions by shipping method, and you try and place the order via API. It throws a internal_server_error.

    I noticed that the PRO version said it has API Developer features, so I purchased it thinking you may have added this restriction to FREE version. But to my disappointment it still did not work..

    This is what I am attempting to do:

    POST: https://DOMAIN/wp-json/wc/v3/orders

    BODY:

    {
    “customer_id”: 13784,
    “status”: “processing”,
    “payment_method”: “cod”,
    “payment_method_title”: “Cash on Delivery”,
    “set_paid”: false,
    “coupon_lines”: [
    {
    “code”: “col20restricted”
    }
    ],
    “shipping_lines”: [
    {
    “method_title”: “Collection”,
    “method_id”: “local_pickup”
    }
    ],
    “customer_note”: “”,
    “billing”: {
    “first_name”: “Test”,
    “last_name”: “test”,
    “address_1”: “1 London Road”,
    “city”: “London”,
    “state”: “England”,
    “postcode”: “L1 1AB”,
    “country”: “United Kingdom”,
    “email”: “abc@abc.com”,
    “phone”: “+123”,
    “customer_id”: 13784
    },
    “shipping”: {
    “first_name”: “Test”,
    “last_name”: “test”,
    “address_1”: “1 London Road”,
    “city”: “London”,
    “state”: “England”,
    “postcode”: “L1 1AB”,
    “phone”: “+123”,
    “country”: “United Kingdom”,
    “customer_id”: 13784
    },
    “line_items”: [
    {
    “product_id”: 15865,
    “quantity”: 10,
    “total”: “27”,
    “meta_data”: [
    ]
    }
    ]

    }

    The error that is getting thrown (using POSTMAN) is:
    {
    “code”: “internal_server_error”,
    “message”: “<p>There has been a critical error on this website.</p><p>Learn more about troubleshooting WordPress.</p>”,
    “data”: {
    “status”: 500
    },
    “additional_errors”: []
    }

    If I REMOVE the restriction on the coupon (the “Checkout” section -> “Shipping methods”), then the coupon works fine.

    Can you please help?

    Thank You

    #19939
    Soft79
    Keymaster

    What is the error? You can see this if you enable WP_DEBUG_LOG.

    #19941
    Shazaan Ali
    Participant

    Hi
    We are placing the order via REST API. therefore how will the debugging on wp-end help?

    #19942
    Soft79
    Keymaster

    The API request is handled by WP, so any errors can be logged by WP. If you have a PHP log enabled you can also check that PHP log.

    #19944
    Shazaan Ali
    Participant

    Oh ok.

    But what is the “API” description that you mentioned in the PRO version about?

    #19946
    Soft79
    Keymaster

    Functions, hooks and filters to extend functionality of the plugin through PHP.

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