Order creation deletes wholesale customer shipping address

When I create a new order via the API and specify the customer_id and deliver_to_id correctly for a wholesale customer, the order is created but the customer’s shipping address is deleted. This is unexpected - am I doing something wrong?

This is the API body I’m sending (minus the real IDs):

    {
      "order": {
        "channel_id": 77777,
        "customer_id": 66666666,
        "deliver_to_id": 111111111,
        "created_at": "2020-03-22T13:08:43.000Z",
        "due_date": "22/03/2020",
        "number": "TEST1",
        "send_notification_email": false,
        "line_items_attributes": [
          {
            "price_per_unit": "77.000",
            "taxless_discount_per_unit": "0.00",
            "quantity": "1",
            "tax_rate": 0,
            "sellable_id": 44444444
          }
        ],
        "additional_order_level_taxless_discount": "00.00",
        "delivery_method_id": 222222,
        "delivery_cost": "0.00",
        "total_tax": "0.00",
        "total_discounts": "0",
        "payment_attributes": {
          "payment_type": "online_finance",
          "reference_number": "PAYMENTJLTEST1"
        },
        "employee_notes_attributes": [
          {
            "text": "Test Sale"
          }
        ]
      }
    }

Just to add, I’ve tried the same call now with a “Retail” type customer and that works as expected - the order is created and the customer retains the shipping address, so this appears to be related to the “Wholesale” customer type.

Hi @crb03

This looks to be the correct request (and obviously not intended behaviour!) so I’m just in the process of investigating this and will attempt to recreate on my own account.

Can you send an email to helpme@veeqo.com and request Sam for API support and we can communicate on there.

Thanks,
Sam
Technical Support Manager

Thanks Sam, I have just emailed the helpme address as requested.

Colin.

I know this is an old issue… But we have come across the exact same issue…
Sending json (Pretty much the same fields in the payload)…
The order is created (and seems to have the correct Billing and Shipping address)

However the Retail Customer no longer has that Delivery address in its record.

Did you find a solution? And Ideally how to create an order so it appears in the Wholesale section of Veeqo given that its a customer with a customer_type of business.

Thanks in advance.

1 Like

Hello @DanHalpin, In this case this is related to a system limitation with the business customers in which in this specific case this type of behavior would be expected.
For this please create the deliver_to by sending the deliver_to_attributes instead of sending the customer shipping address as the deliver_to_id, here I’ll be leaving an example:

{
    "order": {
        "delivery_method_id": 1234,
        "channel_id": "1234",
        "customer_id": "1234",
        "deliver_to_attributes": {
            "first_name": "Samwise",
            "last_name": "Gamgee",
            "company": "The Fellowship",
            "address1": "Bag End",
            "address2": "Hobbiton",
            "city": "Shire",
            "state": "Middle Earth",
            "zip": "SH1 1BG",
            "country": "GB",
            "phone": "07891234567",
            "email": "Gamgee@fellowship.net",
            "id": ""
        },
        "line_items_attributes": [
            {
                "price_per_unit": "0.0",
                "taxless_discount_per_unit": "0.00",
                "quantity": "1",
                "taxRate": null,
                "sellable_id": 1234
            }
        ],
        "payment_attributes": {
            "payment_type": "credit_card",
            "reference_number": ""
        }
    }
}

Thanks Esmadri…

That works nicely (And the Order appears in the Wholesale section of Veeqo which is ideal.

However now there is a further issue…

As part of the payload I am sending
payment_attributes : {
‘payment_type’: ‘bank_transfer’,
‘reference_number’: ‘INVOICE’
}

But the order remains in a status of awaiting_payment.
I have also tried a payment_type of ‘paypal’ given most examples (including yours) seem to use this… But same result.

If I use the ID from the result and immediately try a PUT with a payload of just

“payment_attributes” : {
“payment_type”: “bank_transfer”,
“reference_number”: “INVOICE”
}

This works… However is there a way I can do away with the additional call and have the order marked as paid when sent through?

Thanks in advance.

Hey @DanHalpin, I am glad to hear that it worked, regarding the other issue, can you share the whole payload and maybe an ID of an order just to verify cause I used the next payload and it worked as expected:

{
  "order": {
    "channel_id": 157882,
    "customer_id": 237650663,
    "deliver_to_attributes": {
        "first_name": "Samwise",
        "last_name": "Gamgee",
        "company": "The Fellowship",
        "address1": "Bag End",
        "address2": "Hobbiton",
        "city": "Shire",
        "state": "Middle Earth",
        "zip": "SH1 1BG",
        "country": "GB",
        "phone": "07891234567",
        "email": "Gamgee@fellowship.net",
        "id": ""
    },
    "number": "rdr1237",
    "line_items_attributes": [
      {
        "price_per_unit": "75.000",
        "taxless_discount_per_unit": "0.00",
        "quantity": "1",
        "tax_rate": 0.2,
        "sellable_id": 136699977,
        "additional_options": "This thing is a thing"
      }
    ],
    "delivery_method_id": 5116089,
    "delivery_cost": "2.00",
    "total_tax": "35.54",
    "total_discounts": "49.5",
    "payment_attributes": {
      "payment_type": "bank_transfer",
      "reference_number": "INVOICE"
    }
  }
}