removed multiple address option

This commit is contained in:
shreesh arora
2022-01-14 00:40:41 +05:30
committed by Shreesh Arora
parent b57126874c
commit 776d72a0a2
7 changed files with 53 additions and 10 deletions

View File

@@ -1152,6 +1152,7 @@
else
{
$('#addresses_err').hide();
$("#new_address").hide();
$('#address_delivery, #address_invoice').show();
//by webkul
@@ -1159,8 +1160,8 @@
}
/*Changed by webkul to make delivery and invoice addresses same*/
$('#id_address_delivery').html(addresses_delivery_options);
$('#id_address_invoice').html(addresses_delivery_options);
$('#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);

View File

@@ -178,6 +178,12 @@ class AddressCore extends ObjectModel
*/
public function add($autodate = true, $null_values = false)
{
// for customer address we need to check of customer address already exists.
if ($this->id_customer) {
if ($id_address = Customer::getCustomerIdAddress($this->id_customer)) {
return false;
}
}
if (!parent::add($autodate, $null_values)) {
return false;
}
@@ -243,6 +249,15 @@ class AddressCore extends ObjectModel
public function validateController($htmlentities = true)
{
$errors = parent::validateController($htmlentities);
// for customer address we need to check of customer address already exists.
if ($idCustomer = Tools::getValue('id_customer')) {
if ($id_address = Customer::getCustomerIdAddress($idCustomer)) {
$errors[] = sprintf(Tools::displayError('Customer address already exists. Id address: #%d'), $id_address);
}
}
return $errors;
}
/**

View File

@@ -465,6 +465,21 @@ class CustomerCore extends ObjectModel
return Cache::retrieve($cache_id);
}
public static function getCustomerIdAddress($id_customer)
{
$cache_id = 'Customer::getCustomerIdAddress'.(int)$id_customer;
if (!Cache::isStored($cache_id)) {
$sql = 'SELECT id_address
FROM `'._DB_PREFIX_.'address` a
WHERE `id_customer` = '.(int)$id_customer.' AND a.`deleted` = 0';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
Cache::store($cache_id, $result);
return $result;
}
return Cache::retrieve($cache_id);
}
/**
* Count the number of addresses for a customer
*

View File

@@ -344,12 +344,24 @@ class AdminAddressesControllerCore extends AdminController
return parent::renderForm();
}
// public function postProcess()
// {
// $address = new Address();
// $this->errors = $address->validateController();
// return parent::postProcess();
// }
public function processSave()
{
if (Tools::getValue('submitFormAjax')) {
$this->redirect_after = false;
}
$address = new Address();
$this->errors = $address->validateController();
// Transform e-mail in id_customer for parent processing
if (Validate::isEmail(Tools::getValue('email'))) {
$customer = new Customer();

View File

@@ -68,7 +68,7 @@ class AddressControllerCore extends FrontController
$id_address = (int)$this->context->cart->id_address_invoice;
}
} else {
$id_address = (int)Tools::getValue('id_address', 0);
$id_address = Customer::getCustomerIdAddress($this->context->customer->id);
}
// Initialize address
@@ -91,7 +91,7 @@ class AddressControllerCore extends FrontController
} elseif ($this->ajax) {
exit;
} else {
Tools::redirect('index.php?controller=addresses');
// Tools::redirect('index.php?controller=addresses');
}
}
}
@@ -241,7 +241,7 @@ class AddressControllerCore extends FrontController
$mod = Tools::getValue('mod');
Tools::redirect('index.php?controller='.$back.($mod ? '&back='.$mod : ''));
} else {
Tools::redirect('index.php?controller=addresses');
Tools::redirect('index.php?controller=address');
}
}
$this->errors[] = Tools::displayError('An error occurred while updating your address.');

View File

@@ -34,7 +34,7 @@
{if isset($address->alias)}"{$address->alias|escape:'html':'UTF-8'}"{/if}
{/if}
{else}
{l s='To add a new address, please fill out the form below.'}
{l s='To add an address, please fill out the form below.'}
{/if}
</p>
{include file="$tpl_dir./errors.tpl"}

View File

@@ -35,15 +35,15 @@
<div class="row addresses-lists">
<div class="col-xs-12 col-sm-6 col-lg-4">
<ul class="myaccount-link-list">
{if $has_customer_an_address}
<li><a href="{$link->getPageLink('address', true)|escape:'html':'UTF-8'}" title="{l s='Add my first address'}"><i class="icon-building"></i><span>{l s='Add my first address'}</span></a></li>
{/if}
{* {if $has_customer_an_address} *}
<li><a href="{$link->getPageLink('address', true)|escape:'html':'UTF-8'}" title="{l s='My address'}"><i class="icon-building"></i><span>{l s='My address'}</span></a></li>
{* {/if} *}
<li><a href="{$link->getPageLink('history', true)|escape:'html':'UTF-8'}" title="{l s='Orders'}"><i class="icon-list-ol"></i><span>{l s='Order history and details'}</span></a></li>
{if $refundAllowed}
<li><a href="{$link->getPageLink('order-follow', true)|escape:'html':'UTF-8'}" title="{l s='Booking Refund Requests'}"><i class="icon-refresh"></i><span>{l s='Booking Refund Requests'}</span></a></li>
{/if}
<li><a href="{$link->getPageLink('order-slip', true)|escape:'html':'UTF-8'}" title="{l s='Credit slips'}"><i class="icon-file-o"></i><span>{l s='My credit slips'}</span></a></li>
<li><a href="{$link->getPageLink('addresses', true)|escape:'html':'UTF-8'}" title="{l s='Addresses'}"><i class="icon-building"></i><span>{l s='My addresses'}</span></a></li>
{* <li><a href="{$link->getPageLink('addresses', true)|escape:'html':'UTF-8'}" title="{l s='Addresses'}"><i class="icon-building"></i><span>{l s='My addresses'}</span></a></li> *}
<li><a href="{$link->getPageLink('identity', true)|escape:'html':'UTF-8'}" title="{l s='Information'}"><i class="icon-user"></i><span>{l s='My personal information'}</span></a></li>
</ul>
</div>