diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index 6e0df784a..51f8d4b3d 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -174,16 +174,21 @@ class AddressControllerCore extends FrontController $address->dni = null; } // Check if the alias exists - if (!$this->context->customer->is_guest && !empty($_POST['alias']) - && (int)$this->context->customer->id > 0 - && Db::getInstance()->getValue(' + if (!$this->context->customer->is_guest && !empty($_POST['alias']) && (int)$this->context->customer->id > 0) + { + $id_address = Tools::getValue('id_address'); + if(Configuration::get('PS_ORDER_PROCESS_TYPE') && (int)Tools::getValue('opc_id_address_'.Tools::getValue('type')) > 0) + $id_address = Tools::getValue('opc_id_address_'.Tools::getValue('type')); + + if (Db::getInstance()->getValue(' SELECT count(*) FROM '._DB_PREFIX_.'address WHERE `alias` = \''.pSql($_POST['alias']).'\' - AND id_address != '.(int)Tools::getValue('id_address').' + AND id_address != '.(int)$id_address.' AND id_customer = '.(int)$this->context->customer->id.' AND deleted = 0') > 0) - $this->errors[] = sprintf(Tools::displayError('The alias "%s" is already used, please chose another one.'), Tools::safeOutput($_POST['alias'])); + $this->errors[] = sprintf(Tools::displayError('The alias "%s" is already used, please chose another one.'), Tools::safeOutput($_POST['alias'])); + } // Check the requires fields which are settings in the BO $this->errors = array_merge($this->errors, $address->validateFieldsRequiredDatabase()); diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 9a1cc10a1..c8d71561b 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -400,7 +400,6 @@ class AuthControllerCore extends FrontController if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) { - if (!count($this->errors)) { if (Tools::isSubmit('newsletter')) diff --git a/themes/default/js/order-opc.js b/themes/default/js/order-opc.js index e125ec157..6218c4019 100644 --- a/themes/default/js/order-opc.js +++ b/themes/default/js/order-opc.js @@ -92,19 +92,22 @@ function updateAddressSelection() $(this).find('[name='+name+']').attr('name', name.replace(/_\d+_hidden$/, '_'+idAddress_delivery+'_hidden')); } - if ($(this).find('.cart_quantity_delete').length > 0 && $(this).find('.cart_quantity_delete').attr('id').length > 0) { + if ($(this).find('.cart_quantity_delete').length > 0 && $(this).find('.cart_quantity_delete').attr('id').length > 0) + { $(this).find('.cart_quantity_delete') .attr('id', $(this).find('.cart_quantity_delete').attr('id').replace(/_\d+$/, '_'+idAddress_delivery)) .attr('href', $(this).find('.cart_quantity_delete').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&')); } - if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0) { + if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0) + { $(this).find('.cart_quantity_down') .attr('id', $(this).find('.cart_quantity_down').attr('id').replace(/_\d+$/, '_'+idAddress_delivery)) .attr('href', $(this).find('.cart_quantity_down').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&')); } - if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0) { + if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0) + { $(this).find('.cart_quantity_up') .attr('id', $(this).find('.cart_quantity_up').attr('id').replace(/_\d+$/, '_'+idAddress_delivery)) .attr('href', $(this).find('.cart_quantity_up').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&')); @@ -122,17 +125,13 @@ function updateAddressSelection() updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); if ($('#gift-price').length === 1) $('#gift-price').html(jsonData.gift_price); - $('#opc_account-overlay').fadeOut('slow'); - $('#opc_delivery_methods-overlay').fadeOut('slow'); - $('#opc_payment_methods-overlay').fadeOut('slow'); + $('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { if (textStatus !== 'abort') alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); - $('#opc_account-overlay').fadeOut('slow'); - $('#opc_delivery_methods-overlay').fadeOut('slow'); - $('#opc_payment_methods-overlay').fadeOut('slow'); + $('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); } }); } @@ -188,8 +187,7 @@ function updateCarrierSelectionAndGift() giftMessage = encodeURIComponent($('#gift_message').val()); } - $('#opc_payment_methods-overlay').fadeIn('slow'); - $('#opc_delivery_methods-overlay').fadeIn('slow'); + $('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); $.ajax({ type: 'POST', url: orderOpcUrl, @@ -215,16 +213,14 @@ function updateCarrierSelectionAndGift() updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART); updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA); updateCarrierList(jsonData.carrier_data); - $('#opc_payment_methods-overlay').fadeOut('slow'); - $('#opc_delivery_methods-overlay').fadeOut('slow'); + $('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); refreshDeliveryOptions(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { if (textStatus !== 'abort') alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); - $('#opc_payment_methods-overlay').fadeOut('slow'); - $('#opc_delivery_methods-overlay').fadeOut('slow'); + $('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); } }); } @@ -235,8 +231,7 @@ function confirmFreeOrder() $('#opc_new_account-overlay').fadeIn('slow'); else $('#opc_account-overlay').fadeIn('slow'); - $('#opc_delivery_methods-overlay').fadeIn('slow'); - $('#opc_payment_methods-overlay').fadeIn('slow'); + $('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); $.ajax({ type: 'POST', url: orderOpcUrl, @@ -277,13 +272,15 @@ function saveAddress(type) params += 'city='+encodeURIComponent($('#city'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'id_country='+encodeURIComponent($('#id_country').val())+'&'; if ($('#id_state'+(type === 'invoice' ? '_invoice' : '')).val()) - { - params += 'id_state='+encodeURIComponent($('#id_state'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; - } + params += 'id_state='+encodeURIComponent($('#id_state'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'other='+encodeURIComponent($('#other'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'phone='+encodeURIComponent($('#phone'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'phone_mobile='+encodeURIComponent($('#phone_mobile'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'alias='+encodeURIComponent($('#alias'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; + if (type === 'delivery' && $('#opc_id_address_delivery').val() != 'undefined' && parseInt($('#opc_id_address_delivery').val()) > 0) + params += 'opc_id_address_delivery='+encodeURIComponent($('#opc_id_address_delivery').val())+'&'; + if (type === 'invoice' && $('#opc_id_address_invoice').val() != 'undefined' && parseInt($('#opc_id_address_invoice').val()) > 0) + params += 'opc_id_address_invoice='+encodeURIComponent($('#opc_id_address_invoice').val())+'&'; // Clean the last & params = params.substr(0, params.length-1); @@ -311,11 +308,12 @@ function saveAddress(type) } tmp += ''; var errors = ''+txtThereis+' '+i+' '+txtErrors+':