Replies: 4 comments 4 replies
-
Hi @rynpsc Thank you for the suggestion. This is something we will take into consideration. In the meantime, you could add something similar to the following code to a custom module to get your desired behaviour. In the example below I have made the assumption that you would create a custom field on the order that will be storing whether the customer would like to save their addresses at the end of the checkout process. Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, static function(Event $event) {
/** @var Order $order */
$order = $event->sender;
// Custom logic here to determine if to save the addresses or not
if ($order->mySaveAddressesCustomField) {
if ($billingAddress = $order->getBillingAddress()) {
Craft::$app->getElements()->duplicateElement($billingAddress, ['ownerId' => $order->getCustomerId()]);
}
if ($shippingAddress = $order->getShippingAddress()) {
Craft::$app->getElements()->duplicateElement($shippingAddress, ['ownerId' => $order->getCustomerId()]);
}
}
}); Hope this helps, thanks! |
Beta Was this translation helpful? Give feedback.
-
Just to add to this, the sample templates are quite confusing, as they include fields like |
Beta Was this translation helpful? Give feedback.
-
We use this feature to save an address for future use pretty heavily in our 3.x Commerce installation. It would be nice if this feature came back. |
Beta Was this translation helpful? Give feedback.
-
This is possible with the There is also an example of this in the options page of the checkout flow in the example templates. |
Beta Was this translation helpful? Give feedback.
-
With the address updates in Craft 4 addresses are no longer saved during checkout. It would be nice if during checkout when a logged in user is adding a new shipping or billing address they could chose to save that address for future use in the same way you can save a payment source during checkout via
savePaymentSource
, e.g.saveShippingAddress
andsaveBillingAddress
.Beta Was this translation helpful? Give feedback.
All reactions