Jump to content

Programmatically set delivery address on cart [1.7]

Boris Le Meec

Recommended Posts


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;

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 by Boris Le Meec (see edit history)
Link to comment
Share on other sites

  • 1 year later...


i have the same issue when updating id_address_delivery in my module. 

I managed to do this in Prestashop

private function updateOrderAddress($new_address_id) {
    global $context;


    $context->cart->id_address_invoice = $new_address_id;









Link to comment
Share on other sites

  • 1 year later...


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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...