0

In the commerce order checkout page, if you use "Save to my address book" checkbox in the billing address section, the address is getting saved to the user's address book. But if I am doing this using JSON request, how can I save the address to the user's address book and how can I load the saved addresses.

1 Answer 1

0

How you save depends somewhat on your desired UX. If you look at the code in the BillingInformation checkout pane (in the checkout module) or the CustomerProfile inline form plugin (in the order module), you'll see some properties used to instruct Commerce how and when to copy addresses to the addressbook.

If it's fine for your addresses to be copied when the order is placed (i.e. not immediately upon them being entered on a checkout form), then you can simply get by with setting copy_to_address_book in the profile's data array to TRUE. This will get picked up by the AddressBookSubscriber (in the order module), resulting in the address being copied to the user's addressbook upon order placement.

Other options would be discoverable through the way the checkout pane functions. There is no way, as far as I know, to trigger an immediate copy merely by the save of the profile, but I haven't looked deeply at Commerce API to confirm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.