+
{l s='Invoice'}
diff --git a/classes/Cart.php b/classes/Cart.php
index 8401a36b9..d61996498 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -262,25 +262,10 @@ class CartCore extends ObjectModel
$to_update = true;
$this->id_address_invoice = $id_address_new;
}
- if (!isset($this->id_address_delivery) || $this->id_address_delivery == $id_address) {
- $to_update = true;
- $this->id_address_delivery = $id_address_new;
- }
if ($to_update) {
$this->update();
}
- $sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
- SET `id_address_delivery` = '.(int)$id_address_new.'
- WHERE `id_cart` = '.(int)$this->id.'
- AND `id_address_delivery` = '.(int)$id_address;
- Db::getInstance()->execute($sql);
-
- $sql = 'UPDATE `'._DB_PREFIX_.'customization`
- SET `id_address_delivery` = '.(int)$id_address_new.'
- WHERE `id_cart` = '.(int)$this->id.'
- AND `id_address_delivery` = '.(int)$id_address;
- Db::getInstance()->execute($sql);
}
public function delete()
@@ -1076,13 +1061,13 @@ class CartCore extends ObjectModel
}
if (Context::getContext()->customer->id) {
- if ($id_address_delivery == 0 && (int)$this->id_address_delivery) { // The $id_address_delivery is null, use the cart delivery address
- $id_address_delivery = $this->id_address_delivery;
- } elseif ($id_address_delivery == 0) { // The $id_address_delivery is null, get the default customer address
- $id_address_delivery = (int)Address::getFirstCustomerAddressId((int)Context::getContext()->customer->id);
- } elseif (!Customer::customerHasAddress(Context::getContext()->customer->id, $id_address_delivery)) { // The $id_address_delivery must be linked with customer
- $id_address_delivery = 0;
- }
+ // if ($id_address_delivery == 0 && (int)$this->id_address_delivery) { // The $id_address_delivery is null, use the cart delivery address
+ // $id_address_delivery = $this->id_address_delivery;
+ // } elseif ($id_address_delivery == 0) { // The $id_address_delivery is null, get the default customer address
+ // $id_address_delivery = (int)Address::getFirstCustomerAddressId((int)Context::getContext()->customer->id);
+ // } elseif (!Customer::customerHasAddress(Context::getContext()->customer->id, $id_address_delivery)) { // The $id_address_delivery must be linked with customer
+ // $id_address_delivery = 0;
+ // }
}
$quantity = (int)$quantity;
@@ -2518,6 +2503,8 @@ class CartCore extends ObjectModel
$final_package_list = $hotelWisePackageList;
// END $package_list hotel wise
$cache[$cache_key] = $final_package_list;
+ // ddd($this);
+ // ddd($final_package_list);
return $final_package_list;
}
@@ -4108,9 +4095,9 @@ class CartCore extends ObjectModel
$cart->id_shop = $this->id_shop;
$cart->id_shop_group = $this->id_shop_group;
- if (!Customer::customerHasAddress((int)$cart->id_customer, (int)$cart->id_address_delivery)) {
- $cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$cart->id_customer);
- }
+ // if (!Customer::customerHasAddress((int)$cart->id_customer, (int)$cart->id_address_delivery)) {
+ // $cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$cart->id_customer);
+ // }
if (!Customer::customerHasAddress((int)$cart->id_customer, (int)$cart->id_address_invoice)) {
$cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$cart->id_customer);
@@ -4136,7 +4123,7 @@ class CartCore extends ObjectModel
foreach ($products as $product) {
if ($id_address_delivery) {
if (Customer::customerHasAddress((int)$cart->id_customer, $product['id_address_delivery'])) {
- $id_address_delivery = $product['id_address_delivery'];
+ // $id_address_delivery = $product['id_address_delivery'];
}
}
@@ -4502,11 +4489,11 @@ class CartCore extends ObjectModel
{
$id_address_delivery = 0;
// Get the main address of the customer
- if ((int)$this->id_address_delivery > 0) {
- $id_address_delivery = (int)$this->id_address_delivery;
- } else {
- $id_address_delivery = (int)Address::getFirstCustomerAddressId(Context::getContext()->customer->id);
- }
+ // if ((int)$this->id_address_delivery > 0) {
+ // $id_address_delivery = (int)$this->id_address_delivery;
+ // } else {
+ // $id_address_delivery = (int)Address::getFirstCustomerAddressId(Context::getContext()->customer->id);
+ // }
if (!$id_address_delivery) {
return;
diff --git a/classes/Context.php b/classes/Context.php
index fa672b884..4fa780c95 100644
--- a/classes/Context.php
+++ b/classes/Context.php
@@ -327,7 +327,6 @@ class ContextCore
}
$this->cart->id_customer = (int) $customer->id;
$this->cart->updateAddressId($this->cart->id_address_delivery, (int) Address::getFirstCustomerAddressId((int) ($customer->id)));
- $this->cart->id_address_delivery = (int) Address::getFirstCustomerAddressId((int) ($customer->id));
$this->cart->id_address_invoice = (int) Address::getFirstCustomerAddressId((int) ($customer->id));
// update id guest in htl_cart_booking_data for bookings added to the cart as a visitor
diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php
index f7ba791f7..dff427b34 100644
--- a/classes/controller/FrontController.php
+++ b/classes/controller/FrontController.php
@@ -365,13 +365,13 @@ class FrontControllerCore extends Controller
$cart->update();
}
/* Select an address if not set */
- if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 ||
- !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) {
+ if (isset($cart)
+ && (!isset($cart->id_address_invoice)
+ || $cart->id_address_invoice == 0
+ )
+ && $this->context->cookie->id_customer
+ ) {
$to_update = false;
- if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
- $to_update = true;
- $cart->id_address_delivery = (int)Address::getFirstCustomerAddressId($cart->id_customer);
- }
if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
$to_update = true;
$cart->id_address_invoice = (int)Address::getFirstCustomerAddressId($cart->id_customer);
@@ -391,10 +391,8 @@ class FrontControllerCore extends Controller
$cart->id_shop = $this->context->shop->id;
if ($this->context->cookie->id_customer) {
$cart->id_customer = (int)$this->context->cookie->id_customer;
- $cart->id_address_delivery = (int)Address::getFirstCustomerAddressId($cart->id_customer);
$cart->id_address_invoice = (int)$cart->id_address_delivery;
} else {
- $cart->id_address_delivery = 0;
$cart->id_address_invoice = 0;
}
diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php
index 3f3798675..6fcf728e4 100644
--- a/controllers/admin/AdminCartsController.php
+++ b/controllers/admin/AdminCartsController.php
@@ -395,19 +395,19 @@ class AdminCartsControllerCore extends AdminController
$this->context->cart->id_currency = (($id_currency = (int)Tools::getValue('id_currency')) ? $id_currency : Configuration::get('PS_CURRENCY_DEFAULT'));
}
- $addresses = $customer->getAddresses((int)$this->context->cart->id_lang);
- $id_address_delivery = (int)Tools::getValue('id_address_delivery');
- $id_address_invoice = (int)Tools::getValue('id_address_invoice');
+ if (Validate::isLoadedObject($customer)) {
+ $addresses = $customer->getAddresses((int)$this->context->cart->id_lang);
+ $id_address_delivery = (int)Tools::getValue('id_address_delivery');
+ $id_address_invoice = (int)Tools::getValue('id_address_invoice');
- if (!$this->context->cart->id_address_invoice && isset($addresses[0])) {
- $this->context->cart->id_address_invoice = (int)$addresses[0]['id_address'];
- } elseif ($id_address_invoice) {
- $this->context->cart->id_address_invoice = (int)$id_address_delivery;
- }
- if (!$this->context->cart->id_address_delivery && isset($addresses[0])) {
- $this->context->cart->id_address_delivery = $addresses[0]['id_address'];
- } elseif ($id_address_delivery) {
- $this->context->cart->id_address_delivery = (int)$id_address_delivery;
+ if (!$this->context->cart->id_address_invoice && isset($addresses[0])) {
+ $this->context->cart->id_address_invoice = (int)$addresses[0]['id_address'];
+ } elseif ($id_address_invoice) {
+ $this->context->cart->id_address_invoice = (int)$id_address_delivery;
+ }
+ if ($id_address_delivery) {
+ $this->context->cart->id_address_delivery = (int)$id_address_delivery;
+ }
}
$this->context->cart->setNoMultishipping();
@@ -417,7 +417,6 @@ class AdminCartsControllerCore extends AdminController
$this->context->cart->secure_key = $this->context->customer->secure_key;
$addresses = $customer->getAddresses((int)$this->context->cart->id_lang);
$this->context->cart->id_address_invoice = (int)$addresses[0]['id_address'];
- $this->context->cart->id_address_delivery = (int)$addresses[0]['id_address'];
$this->context->cart->setNoMultishipping();
}
/*END*/
diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php
index a706b5ede..b05274edd 100644
--- a/controllers/front/AuthController.php
+++ b/controllers/front/AuthController.php
@@ -648,7 +648,6 @@ class AuthControllerCore extends FrontController
$customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP')));
}
- $this->context->cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$customer->id);
$this->context->cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$customer->id);
if (isset($address_invoice) && Validate::isLoadedObject($address_invoice)) {
$this->context->cart->id_address_invoice = (int)$address_invoice->id;
diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php
index 7bac1b5d9..cfa67eb05 100644
--- a/controllers/front/ParentOrderController.php
+++ b/controllers/front/ParentOrderController.php
@@ -450,10 +450,6 @@ class ParentOrderControllerCore extends FrontController
/* Setting default addresses for cart */
if (count($customerAddresses)) {
- if ((!isset($this->context->cart->id_address_delivery) || empty($this->context->cart->id_address_delivery)) || !Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) {
- $this->context->cart->id_address_delivery = (int)$customerAddresses[0]['id_address'];
- $update = 1;
- }
if ((!isset($this->context->cart->id_address_invoice) || empty($this->context->cart->id_address_invoice)) || !Address::isCountryActiveById((int)$this->context->cart->id_address_invoice)) {
$this->context->cart->id_address_invoice = (int)$customerAddresses[0]['id_address'];
$update = 1;
diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
index 8cf13738b..81659b934 100644
--- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php
+++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
@@ -2723,9 +2723,6 @@ class HotelBookingDetail extends ObjectModel
if (!$this->context->cart->id_address_invoice && isset($addresses[0])) {
$this->context->cart->id_address_invoice = (int)$addresses[0]['id_address'];
}
- if (!$this->context->cart->id_address_delivery && isset($addresses[0])) {
- $this->context->cart->id_address_delivery = $addresses[0]['id_address'];
- }
$this->context->cart->setNoMultishipping();
if ($this->context->cart->save()) {