remove customer address restrictions in payment and also removed auto address creating during account creation from order page

This commit is contained in:
Shreesh Arora
2023-12-07 14:10:55 +05:30
parent 8cff333d57
commit c84adf5bf7
8 changed files with 13 additions and 51 deletions

View File

@@ -326,9 +326,9 @@ class HookCore extends ObjectModel
}
// For payment modules, we check that they are available in the contextual country
elseif ($frontend) {
if (Validate::isLoadedObject($context->country)) {
$sql->where('((h.`name` = "displayPayment" OR h.`name` = "displayPaymentEU") AND (SELECT `id_country` FROM `'._DB_PREFIX_.'module_country` mc WHERE mc.`id_module` = m.`id_module` AND `id_country` = '.(int)$context->country->id.' AND `id_shop` = '.(int)$context->shop->id.' LIMIT 1) = '.(int)$context->country->id.')');
}
// if (Validate::isLoadedObject($context->country)) {
// $sql->where('((h.`name` = "displayPayment" OR h.`name` = "displayPaymentEU") AND (SELECT `id_country` FROM `'._DB_PREFIX_.'module_country` mc WHERE mc.`id_module` = m.`id_module` AND `id_country` = '.(int)$context->country->id.' AND `id_shop` = '.(int)$context->shop->id.' LIMIT 1) = '.(int)$context->country->id.')');
// }
if (Validate::isLoadedObject($context->currency)) {
$sql->where('((h.`name` = "displayPayment" OR h.`name` = "displayPaymentEU") AND (SELECT `id_currency` FROM `'._DB_PREFIX_.'module_currency` mcr WHERE mcr.`id_module` = m.`id_module` AND `id_currency` IN ('.(int)$context->currency->id.', -1, -2) LIMIT 1) IN ('.(int)$context->currency->id.', -1, -2))');
}

View File

@@ -2065,9 +2065,6 @@ abstract class ModuleCore
public static function getPaymentModules()
{
$context = Context::getContext();
if (Validate::isLoadedObject($context->country)) {
$id_country = (int)$context->country->id;
}
$use_groups = Group::isFeatureActive();
@@ -2097,7 +2094,6 @@ abstract class ModuleCore
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \''.pSQL($hook_payment).'\'
'.(isset($id_country) && $frontend ? 'AND mc.id_country = '.(int)$id_country : '').'
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).')
'.((count($groups) && $frontend && $use_groups) ? 'AND (mg.`id_group` IN ('.implode(', ', $groups).'))' : '').'

View File

@@ -113,13 +113,6 @@ class AdminCustomerPreferencesControllerCore extends AdminController
'cast' => 'intval',
'type' => 'bool'
),
'PS_CUSTOMER_ADDRESS_CREATION' => array(
'title' => $this->l('Address creation during checkout'),
'hint' => $this->l('If disabled, Address form will not appear to user during checkout process. So by default hotel address, which rooms guest has in his cart will be considered as user address. Else user has to fill adress details.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
),
'submit' => array('title' => $this->l('Save')),
),

View File

@@ -398,7 +398,10 @@ class AuthControllerCore extends FrontController
$firstnameAddress = Tools::getValue('firstname');
$_POST['lastname'] = Tools::getValue('customer_lastname', $lastnameAddress);
$_POST['firstname'] = Tools::getValue('customer_firstname', $firstnameAddress);
$addresses_types = array('address');
$addresses_types = [];
if (Configuration::get('PS_REGISTRATION_PROCESS_TYPE')) {
$addresses_types[] = 'address';
}
if (!Configuration::get('PS_ORDER_PROCESS_TYPE') && Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('invoice_address')) {
$addresses_types[] = 'address_invoice';
@@ -422,36 +425,6 @@ class AuthControllerCore extends FrontController
$this->errors[] = Tools::displayError('You must register at least one phone number.');
}
// if PS_CUSTOMER_ADDRESS_CREATION is disabled And customer has no addresses then create customer address
// with the details of first hotel which rooms he has in cart
if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')
&& isset($this->context->cart->id)
&& $this->context->cart->id
) {
if (Module::isInstalled('hotelreservationsystem')) {
include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
$objHtlCart = new HotelCartBookingData();
if ($htlCartInfo = $objHtlCart->getCartCurrentDataByCartId($this->context->cart->id)) {
if (isset($htlCartInfo[0]['id_hotel']) && ($idHotel = $htlCartInfo[0]['id_hotel'])) {
if ($address_info = HotelBranchInformation::getAddress($idHotel)) {
$_POST['lastname'] = Tools::getValue('customer_lastname');
$_POST['firstname'] = Tools::getValue('customer_firstname');
$_POST['address1'] = $address_info['address1'];
$_POST['city'] = $address_info['city'];
$_POST['postcode'] = $address_info['postcode'];
$_POST['alias'] = 'My address';
$_POST['id_country'] = $address_info['id_country'];
$_POST['id_state'] = $address_info['id_state'];
$_POST['auto_generated'] = true;
// if form is shorter then address name will be customer name
$lastnameAddress = $_POST['lastname'];
$firstnameAddress = $_POST['firstname'];
}
}
}
}
}
// End
$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
// Check the requires fields which are settings in the BO
@@ -561,7 +534,7 @@ class AuthControllerCore extends FrontController
}
if ($country->need_identification_number) {
if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')) {
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE')) {
$$addresses_type->dni = null;
} elseif (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))) {
$this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');

View File

@@ -465,7 +465,7 @@ class OrderOpcControllerCore extends ParentOrderController
// 'allDemands' => $allDemands,
// 'defaultcurrencySign' => $objCurrency->sign,
'THEME_DIR' => _THEME_DIR_,
'PS_CUSTOMER_ADDRESS_CREATION' => Configuration::get('PS_CUSTOMER_ADDRESS_CREATION'),
'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'),
'PS_ROOM_PRICE_AUTO_ADD_BREAKDOWN' => Configuration::get('PS_ROOM_PRICE_AUTO_ADD_BREAKDOWN'),
'free_shipping' => $free_shipping,
'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0,

View File

@@ -346,7 +346,7 @@ $(document).ready(function()
static_token = jsonData.token;
// It's not a new customer
if (PS_CUSTOMER_ADDRESS_CREATION && $('#opc_id_customer').val() !== '0') {
if (PS_REGISTRATION_PROCESS_TYPE && $('#opc_id_customer').val() !== '0') {
saveAddress('delivery', function() {
location.reload();
});

View File

@@ -106,7 +106,7 @@
</div>
</div>
</div>
{if $PS_CUSTOMER_ADDRESS_CREATION}
{if isset($PS_REGISTRATION_PROCESS_TYPE) && $PS_REGISTRATION_PROCESS_TYPE}
<div class="row">
<div class="select form-group date-select col-sm-12">
<label>{l s='Date of Birth'}</label>
@@ -316,5 +316,5 @@
{if isset($countries)}
{addJsDef countries=$countries}
{/if}
{addJsDef PS_CUSTOMER_ADDRESS_CREATION=$PS_CUSTOMER_ADDRESS_CREATION|intval}
{addJsDef PS_REGISTRATION_PROCESS_TYPE=$PS_REGISTRATION_PROCESS_TYPE|intval}
{/strip}

View File

@@ -103,7 +103,7 @@
<input type="text" class="text form-control validate" name="phone_mobile" id="phone_mobile" data-validate="isPhoneNumber" value="{if isset($guestInformations) && isset($guestInformations.phone_mobile) && $guestInformations.phone_mobile}{$guestInformations.phone_mobile}{/if}" />
</div>
</div>
{if $PS_CUSTOMER_ADDRESS_CREATION}
{if isset($PS_REGISTRATION_PROCESS_TYPE) && $PS_REGISTRATION_PROCESS_TYPE}
<div class="row">
<div class="select form-group date-select col-sm-12">
<label>{l s='Date of Birth'}</label>