Jump to content

Prestashop 1.7.6.3 - Checkout carrier - redirect to Address


Recommended Posts

Hello! 

i'm running presta 1.7.6.3 and i work on module where on checkout (Carrier tab) open popup where customer can select delivery destination-address (for example - post office) - that work as i expected. 

- customer select delivery destination (address) we change delivery address over ajax call:

            $id_of_carrier = Context::getContext()->cart->id_carrier;
            $id_address_delivery = Context::getContext()->cart->id_address_delivery;
            $id_address_invoice = Context::getContext()->cart->id_address_invoice;
            $addressBilling = new Address($id_address_invoice);
            $address = new Address($id_address_delivery);

            $newaddress = new Address();
            $newaddress->id_customer = $address->id_customer;
            $newaddress->id_manufacturer = $address->id_manufacturer;
            $newaddress->id_supplier = $address->id_supplier;
            $newaddress->id_warehouse = $address->id_warehouse;
            $newaddress->id_country = $address->id_country;
            $newaddress->id_state = $address->id_state;
            $newaddress->country = $address->country;
            $newaddress->alias = $_POST['in'];
            $newaddress->company = $address->company;
            $newaddress->lastname =  $address->lastname;
            $newaddress->firstname =  $address->firstname;
            $newaddress->address1 = $_POST['it'];
            $newaddress->address2 = $_POST['ipn'];
            $newaddress->postcode = $_POST['ipi'];
            $newaddress->city = $_POST['ip'];
            $newaddress->phone = $address->phone;
            $newaddress->phone_mobile = $address->phone_mobile;
            $newaddress->vat_number = $address->vat_number;
            $newaddress->deleted = 0;
            $newaddress->force_id = true;
            $newaddress->other = $_POST['xx']. ":" .$_POST['xxx'];

            if ($newaddress->add() == true)
            {
                //update cart
                $cart = Context::getContext()->cart;
                $cart->id_address_delivery = $newaddress->id;
                $cart->update();
                $cart->save();
                $cart->setNoMultishipping();

                $delivery_option = $cart->getDeliveryOption();
                $delivery_option[(int)$newaddress->id] = $id_of_carrier.',';
                $cart->setDeliveryOption($delivery_option);
                $cart->save();
            }

- when proceed (click on continue button) to next step (billing information) presta make redirect to Address tab - that mean we go two steps back. I don't have idea why?

Can anyone help me how to prevent redirect to address tab after address is changed over code? Theme and checkout is default - no customizations.

 

Thank you!

Share this post


Link to post
Share on other sites
  • 1 month later...

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More