@@ -399,56 +399,54 @@ protected function _assignAddress()
399
399
Tools::redirect ('' );
400
400
} elseif (!Customer::getAddressesTotalById ($ this ->context ->customer ->id )) {
401
401
$ multi = (int )Tools::getValue ('multi-shipping ' );
402
- Tools::redirect ('index.php?controller=address&back= ' .urlencode ('order.php?step=1 ' .($ multi ? '&multi-shipping= ' .$ multi : '' )));
403
402
}
404
403
405
404
$ customer = $ this ->context ->customer ;
406
405
if (Validate::isLoadedObject ($ customer )) {
407
406
/* Getting customer addresses */
408
- $ customerAddresses = $ customer ->getAddresses ($ this ->context ->language ->id );
407
+ if ($ customerAddresses = $ customer ->getAddresses ($ this ->context ->language ->id )) {
408
+ // Getting a list of formated address fields with associated values
409
+ $ formatedAddressFieldsValuesList = array ();
409
410
410
- // Getting a list of formated address fields with associated values
411
- $ formatedAddressFieldsValuesList = array ();
411
+ foreach ($ customerAddresses as $ i => $ address ) {
412
+ if (!Address::isCountryActiveById ((int )$ address ['id_address ' ])) {
413
+ unset($ customerAddresses [$ i ]);
414
+ }
415
+ $ tmpAddress = new Address ($ address ['id_address ' ]);
416
+ $ formatedAddressFieldsValuesList [$ address ['id_address ' ]]['ordered_fields ' ] = AddressFormat::getOrderedAddressFields ($ address ['id_country ' ]);
417
+ $ formatedAddressFieldsValuesList [$ address ['id_address ' ]]['formated_fields_values ' ] = AddressFormat::getFormattedAddressFieldsValues (
418
+ $ tmpAddress ,
419
+ $ formatedAddressFieldsValuesList [$ address ['id_address ' ]]['ordered_fields ' ]);
412
420
413
- foreach ($ customerAddresses as $ i => $ address ) {
414
- if (!Address::isCountryActiveById ((int )$ address ['id_address ' ])) {
415
- unset($ customerAddresses [$ i ]);
421
+ unset($ tmpAddress );
416
422
}
417
- $ tmpAddress = new Address ($ address ['id_address ' ]);
418
- $ formatedAddressFieldsValuesList [$ address ['id_address ' ]]['ordered_fields ' ] = AddressFormat::getOrderedAddressFields ($ address ['id_country ' ]);
419
- $ formatedAddressFieldsValuesList [$ address ['id_address ' ]]['formated_fields_values ' ] = AddressFormat::getFormattedAddressFieldsValues (
420
- $ tmpAddress ,
421
- $ formatedAddressFieldsValuesList [$ address ['id_address ' ]]['ordered_fields ' ]);
422
423
423
- unset($ tmpAddress );
424
- }
424
+ $ customerAddresses = array_values ($ customerAddresses );
425
425
426
- $ customerAddresses = array_values ($ customerAddresses );
426
+ if (!count ($ customerAddresses ) && !Tools::isSubmit ('ajax ' )) {
427
+ $ bad_delivery = false ;
428
+ if (($ bad_delivery = (bool )!Address::isCountryActiveById ((int )$ this ->context ->cart ->id_address_delivery )) || !Address::isCountryActiveById ((int )$ this ->context ->cart ->id_address_invoice )) {
429
+ $ params = array ();
430
+ if ($ this ->step ) {
431
+ $ params ['step ' ] = (int )$ this ->step ;
432
+ }
433
+ if ($ multi = (int )Tools::getValue ('multi-shipping ' )) {
434
+ $ params ['multi-shipping ' ] = $ multi ;
435
+ }
436
+ $ back_url = $ this ->context ->link ->getPageLink ('order ' , true , (int )$ this ->context ->language ->id , $ params );
427
437
428
- if (!count ($ customerAddresses ) && !Tools::isSubmit ('ajax ' )) {
429
- $ bad_delivery = false ;
430
- if (($ bad_delivery = (bool )!Address::isCountryActiveById ((int )$ this ->context ->cart ->id_address_delivery )) || !Address::isCountryActiveById ((int )$ this ->context ->cart ->id_address_invoice )) {
431
- $ params = array ();
432
- if ($ this ->step ) {
433
- $ params ['step ' ] = (int )$ this ->step ;
434
- }
435
- if ($ multi = (int )Tools::getValue ('multi-shipping ' )) {
436
- $ params ['multi-shipping ' ] = $ multi ;
437
- }
438
- $ back_url = $ this ->context ->link ->getPageLink ('order ' , true , (int )$ this ->context ->language ->id , $ params );
438
+ $ params = array ('back ' => $ back_url , 'id_address ' => ($ bad_delivery ? (int )$ this ->context ->cart ->id_address_delivery : (int )$ this ->context ->cart ->id_address_invoice ));
439
+ if ($ multi ) {
440
+ $ params ['multi-shipping ' ] = $ multi ;
441
+ }
439
442
440
- $ params = array ('back ' => $ back_url , 'id_address ' => ($ bad_delivery ? (int )$ this ->context ->cart ->id_address_delivery : (int )$ this ->context ->cart ->id_address_invoice ));
441
- if ($ multi ) {
442
- $ params ['multi-shipping ' ] = $ multi ;
443
443
}
444
-
445
- Tools::redirect ($ this ->context ->link ->getPageLink ('address ' , true , (int )$ this ->context ->language ->id , $ params ));
446
444
}
445
+ $ this ->context ->smarty ->assign (array (
446
+ 'addresses ' => $ customerAddresses ,
447
+ 'formatedAddressFieldsValuesList ' => $ formatedAddressFieldsValuesList )
448
+ );
447
449
}
448
- $ this ->context ->smarty ->assign (array (
449
- 'addresses ' => $ customerAddresses ,
450
- 'formatedAddressFieldsValuesList ' => $ formatedAddressFieldsValuesList )
451
- );
452
450
453
451
/* Setting default addresses for cart */
454
452
if (count ($ customerAddresses )) {
0 commit comments