Boris Le Meec Posted March 6, 2019 Share Posted March 6, 2019 (edited) Hi, Since yesterday I try to programmatically change the delivery address of a cart, without any kind of even far success.. This is my code : Context::getContext()->cart->updateAddressId(Context::getContext()->cart->id_address_delivery, $address->id); Context::getContext()->cart->id_address_delivery = $address->id; Context::getContext()->cart->id_address_invoice = $address->id; Context::getContext()->cart->update(); I know for sure that the $cart from Context is the good one, I already add some products to it, and I also know for sure that $address is the good one. The problem is that every time I try to set the address_delivery, when I try to get it after, it displays the address_id of the "default" customer address. (The first registered I think) Do you have any idea of what am I doing wrong ? Thanks a lot Edited March 6, 2019 by Boris Le Meec (see edit history) Link to comment Share on other sites More sharing options...
streletsky Posted August 20, 2020 Share Posted August 20, 2020 hi, i have the same issue when updating id_address_delivery in my module. I managed to do this in Prestashop 1.7.6.5: private function updateOrderAddress($new_address_id) { global $context; $context->cart->updateAddressId( $context->cart->id_address_delivery, $new_address_id ); $context->cart->id_address_invoice = $new_address_id; $context->cart->save(); } Link to comment Share on other sites More sharing options...
Ginidev Posted October 27, 2021 Share Posted October 27, 2021 Hi, I think you should override classes/checkout/CheckoutAddressesStep.php to do this. You can check particulary on use_same_address attribute from this class. For my use I need to rewrite handleRequest method to keep the default invoice address when only delivery address change. Good luck Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now