Updated: id_address_delivery is now set as 0 by default

This commit is contained in:
Shreesh Arora
2024-07-23 14:58:20 +05:30
parent 05964925a9
commit 28996df417
8 changed files with 47 additions and 72 deletions

View File

@@ -1458,21 +1458,21 @@
}
/*Changed by webkul to make delivery and invoice addresses same*/
$('#id_address_delivery').html(addresses_delivery_options).hide();
$('#id_address_invoice').html(addresses_delivery_options).hide();
$('#address_delivery_detail').html(address_delivery_detail);
$('#address_invoice_detail').html(address_delivery_detail);
$('#edit_delivery_address').attr('href', delivery_address_edit_link);
$('#edit_invoice_address').attr('href', delivery_address_edit_link);
// $('#id_address_delivery').html(addresses_delivery_options).hide();
// $('#id_address_invoice').html(addresses_delivery_options).hide();
// $('#address_delivery_detail').html(address_delivery_detail);
// $('#address_invoice_detail').html(address_delivery_detail);
// $('#edit_delivery_address').attr('href', delivery_address_edit_link);
// $('#edit_invoice_address').attr('href', delivery_address_edit_link);
/*END*/
/*Original*/
/*$('#id_address_delivery').html(addresses_delivery_options);
$('#id_address_invoice').html(addresses_invoice_options);
$('#id_address_delivery').html(addresses_delivery_options).hide();
$('#id_address_invoice').html(addresses_invoice_options).hide();
$('#address_delivery_detail').html(address_delivery_detail);
$('#address_invoice_detail').html(address_invoice_detail);
$('#edit_delivery_address').attr('href', delivery_address_edit_link);
$('#edit_invoice_address').attr('href', invoice_address_edit_link);*/
$('#edit_invoice_address').attr('href', invoice_address_edit_link);
}
function updateAddresses()
@@ -2002,7 +2002,7 @@
<div id="addresses_err" class="alert alert-warning" style="display:none;"></div>
<div class="row">
<div id="address_delivery" class="col-xs-6 col-sm-6">
<div id="address_delivery" class="col-xs-6 col-sm-6 hidden">
<h4>
<i class="icon-map-marker"></i>
{l s='Customer Address'}
@@ -2015,7 +2015,7 @@
<div id="address_delivery_detail"></div>
</div>
</div>
<div id="address_invoice" class="col-lg-6 hidden">
<div id="address_invoice" class="col-lg-6">
<h4>
<i class="icon-file-text"></i>
{l s='Invoice'}

View File

@@ -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;

View File

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

View File

@@ -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;
}

View File

@@ -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*/

View File

@@ -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;

View File

@@ -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;

View File

@@ -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()) {