Update customer in an order

I want to update customer in an order via API but i could not find any solution for that. There is an option for removing customer from an order via update order api but I could not find any api for updating customer in api. Any clues regarding that?

Hi @rajat31

You can do that the same way as you would remove the customer. Instead of setting the id to null you would set the id to the id of the customer that you want to be associated with the order.

Regards,

Hello, just to confirm – you’re saying that instead of assigning the customer object to null, we can assign it a valid customer id and that should update the Order resource with another Customer resource? I’ve come across other threads such as this one and another that states it isn’t possible – was the API updated to support updating the Customer on the Order rather than only supporting removal? Thanks!

# put /admin/api/2022-04/orders/450789469.json

test_session = ShopifyAPI::Utils::SessionUtils.load_current_session(

  auth_header: request.auth_header,

  cookies: request.cookies,

  is_online: true

)

order = ShopifyAPI::Order.new(session: test_session)

order.id = 450789469

# order.customer = nil
order.customer = CUSTOMER_ID

order.save()