Merge pull request #881 from shreesh-webkul/gli-1078
Improvement: Address is not required in booking/order flow
This commit is contained in:
@@ -1425,21 +1425,14 @@
|
||||
});
|
||||
if (addresses.length == 0)
|
||||
{
|
||||
$('#addresses_err').show().html('{l s='You must add at least one address to process the order.'}');
|
||||
$('#address_delivery, #address_invoice').hide();
|
||||
$("#new_address").show();
|
||||
|
||||
//by webkul (if there is no address then order can not be created)
|
||||
$("button[name=\"submitAddOrder\"]").attr("disabled", "disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#addresses_err').hide();
|
||||
$("#new_address").hide();
|
||||
$('#address_delivery, #address_invoice').show();
|
||||
|
||||
//by webkul
|
||||
$("button[name=\"submitAddOrder\"]").removeAttr("disabled");
|
||||
}
|
||||
|
||||
/*Changed by webkul to make delivery and invoice addresses same*/
|
||||
|
||||
@@ -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))');
|
||||
}
|
||||
|
||||
@@ -181,9 +181,6 @@ abstract class PaymentModuleCore extends Module
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int)$currency_special : (int)$this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int)$id_currency, null, (int)$this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int)$id_order_state, (int)$this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
@@ -274,14 +271,6 @@ abstract class PaymentModuleCore extends Module
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int)$id_address);
|
||||
$this->context->country = new Country((int)$address->id_country, (int)$this->context->cart->id_lang);
|
||||
if (!$this->context->country->active && $this->name != 'wsorder') {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int)$package['id_carrier'], (int)$this->context->cart->id_lang);
|
||||
@@ -463,15 +452,6 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active && $this->name != 'wsorder') {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int)$id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int)$id_cart, true);
|
||||
|
||||
@@ -33,13 +33,9 @@ class CheckoutCustomerDetailsStepCore extends AbstractCheckoutStepCore
|
||||
if (Tools::getValue('proceed_to_customer_dtl')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
if ($idAddressDelivery) {
|
||||
if (!Validate::isLoadedObject($objAddress)) {
|
||||
if ($this->context->cookie->__get('customer_details_proceeded')) {
|
||||
$this->step_is_current = 0;
|
||||
$this->step_is_complete = 1;
|
||||
}
|
||||
}
|
||||
if ($this->context->cookie->__get('customer_details_proceeded')) {
|
||||
$this->step_is_current = 0;
|
||||
$this->step_is_complete = 1;
|
||||
}
|
||||
} elseif (Tools::getValue('proceed_to_payment')) {
|
||||
$guestInfoComplete = true;
|
||||
@@ -52,34 +48,20 @@ class CheckoutCustomerDetailsStepCore extends AbstractCheckoutStepCore
|
||||
}
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
if ($idAddressDelivery && $guestInfoComplete) {
|
||||
if (Validate::isLoadedObject($objAddress)) {
|
||||
$this->step_is_current = 0;
|
||||
$this->step_is_complete = 1;
|
||||
$this->context->cookie->__set('customer_details_proceeded', 1);
|
||||
}
|
||||
if ($guestInfoComplete) {
|
||||
$this->step_is_current = 0;
|
||||
$this->step_is_complete = 1;
|
||||
$this->context->cookie->__set('customer_details_proceeded', 1);
|
||||
}
|
||||
} elseif ($this->context->cookie->__get('customer_details_proceeded')
|
||||
|| $this->context->cookie->__get('cart_summary_proceeded')
|
||||
) {
|
||||
if ($idAddressDelivery) {
|
||||
if (!Validate::isLoadedObject($objAddress)) {
|
||||
$this->context->cookie->__set('customer_details_proceeded', 0);
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
}
|
||||
} else {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
$this->context->cookie->__set('customer_details_proceeded', 0);
|
||||
}
|
||||
} elseif ($this->context->customer->logged) {
|
||||
$this->step_is_reachable = 1;
|
||||
if ($idAddressDelivery) {
|
||||
$this->step_is_complete = 1;
|
||||
} else {
|
||||
$this->step_is_complete = 0;
|
||||
$this->step_is_current = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,11 +417,12 @@ class FrontControllerCore extends Controller
|
||||
|
||||
$display_tax_label = $this->context->country->display_tax_label;
|
||||
if (isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) {
|
||||
$infos = Address::getCountryAndState((int)$cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$country = new Country((int)$infos['id_country']);
|
||||
$this->context->country = $country;
|
||||
if (Validate::isLoadedObject($country)) {
|
||||
$display_tax_label = $country->display_tax_label;
|
||||
if ($infos = Address::getCountryAndState((int)$cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})) {
|
||||
$country = new Country((int)$infos['id_country']);
|
||||
$this->context->country = $country;
|
||||
if (Validate::isLoadedObject($country)) {
|
||||
$display_tax_label = $country->display_tax_label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2069,9 +2069,6 @@ abstract class ModuleCore
|
||||
public static function getPaymentModules()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
if (isset($context->cart)) {
|
||||
$billing = new Address((int)$context->cart->id_address_invoice);
|
||||
}
|
||||
|
||||
$use_groups = Group::isFeatureActive();
|
||||
|
||||
@@ -2101,7 +2098,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($billing) && $frontend ? 'AND mc.id_country = '.(int)$billing->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).'))' : '').'
|
||||
|
||||
@@ -120,13 +120,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')),
|
||||
),
|
||||
|
||||
@@ -1173,39 +1173,29 @@ class AdminOrdersControllerCore extends AdminController
|
||||
Context::getContext()->currency = new Currency((int)$cart->id_currency);
|
||||
Context::getContext()->customer = new Customer((int)$cart->id_customer);
|
||||
|
||||
$bad_delivery = false;
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$cart->id_address_delivery))
|
||||
|| !Address::isCountryActiveById((int)$cart->id_address_invoice)) {
|
||||
if ($bad_delivery) {
|
||||
$this->errors[] = Tools::displayError('This booking address country is not active.');
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This invoice address country is not active.');
|
||||
}
|
||||
} else {
|
||||
$employee = new Employee((int)Context::getContext()->cookie->id_employee);
|
||||
$payment_module->validateOrder(
|
||||
(int)$cart->id,
|
||||
(int)$id_order_state,
|
||||
$cart->getOrderTotal(true, Cart::BOTH),
|
||||
$payment_module->displayName,
|
||||
$this->l('Manual order -- Employee:').' '.
|
||||
substr($employee->firstname, 0, 1).'. '.$employee->lastname,
|
||||
array(),
|
||||
null,
|
||||
false,
|
||||
$cart->secure_key
|
||||
);
|
||||
$employee = new Employee((int)Context::getContext()->cookie->id_employee);
|
||||
$payment_module->validateOrder(
|
||||
(int)$cart->id,
|
||||
(int)$id_order_state,
|
||||
$cart->getOrderTotal(true, Cart::BOTH),
|
||||
$payment_module->displayName,
|
||||
$this->l('Manual order -- Employee:').' '.
|
||||
substr($employee->firstname, 0, 1).'. '.$employee->lastname,
|
||||
array(),
|
||||
null,
|
||||
false,
|
||||
$cart->secure_key
|
||||
);
|
||||
|
||||
if (isset($this->context->cookie->id_cart)) {
|
||||
unset($this->context->cookie->id_cart);
|
||||
}
|
||||
if (isset($this->context->cookie->id_guest)) {
|
||||
unset($this->context->cookie->id_guest);
|
||||
}
|
||||
if (isset($this->context->cookie->id_cart)) {
|
||||
unset($this->context->cookie->id_cart);
|
||||
}
|
||||
if (isset($this->context->cookie->id_guest)) {
|
||||
unset($this->context->cookie->id_guest);
|
||||
}
|
||||
|
||||
if ($payment_module->currentOrder) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3');
|
||||
}
|
||||
if ($payment_module->currentOrder) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to add this.');
|
||||
|
||||
@@ -205,13 +205,13 @@ class AdminPaymentControllerCore extends AdminController
|
||||
'identifier' => 'id_group',
|
||||
'icon' => 'icon-group',
|
||||
),
|
||||
array('items' =>Country::getCountries($this->context->language->id),
|
||||
'title' => $this->l('Country restrictions'),
|
||||
'desc' => $this->l('Please mark each checkbox for the country, or countries, in which you want the payment module(s) to be available.'),
|
||||
'name_id' => 'country',
|
||||
'identifier' => 'id_country',
|
||||
'icon' => 'icon-globe',
|
||||
)
|
||||
// array('items' =>Country::getCountries($this->context->language->id),
|
||||
// 'title' => $this->l('Country restrictions'),
|
||||
// 'desc' => $this->l('Please mark each checkbox for the country, or countries, in which you want the payment module(s) to be available.'),
|
||||
// 'name_id' => 'country',
|
||||
// 'identifier' => 'id_country',
|
||||
// 'icon' => 'icon-globe',
|
||||
// )
|
||||
);
|
||||
|
||||
foreach ($lists as $key_list => $list) {
|
||||
@@ -243,13 +243,13 @@ class AdminPaymentControllerCore extends AdminController
|
||||
}
|
||||
|
||||
// If is a country list and the country is limited, remove it from list
|
||||
if ($name_id == 'country'
|
||||
&& isset($module->limited_countries)
|
||||
&& !empty($module->limited_countries)
|
||||
&& is_array($module->limited_countries)
|
||||
&& !(in_array(strtoupper($item['iso_code']), array_map('strtoupper', $module->limited_countries)))) {
|
||||
$list['items'][$key_item]['check_list'][$key_module] = null;
|
||||
}
|
||||
// if ($name_id == 'country'
|
||||
// && isset($module->limited_countries)
|
||||
// && !empty($module->limited_countries)
|
||||
// && is_array($module->limited_countries)
|
||||
// && !(in_array(strtoupper($item['iso_code']), array_map('strtoupper', $module->limited_countries)))) {
|
||||
// $list['items'][$key_item]['check_list'][$key_module] = null;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// update list
|
||||
|
||||
@@ -411,7 +411,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';
|
||||
@@ -435,36 +438,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
|
||||
@@ -576,7 +549,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.');
|
||||
|
||||
@@ -496,7 +496,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,
|
||||
@@ -767,9 +767,6 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
$address_delivery = new Address($this->context->cart->id_address_delivery);
|
||||
$address_invoice = ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice));
|
||||
if (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice || !Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) {
|
||||
return '<p class="warning">'.Tools::displayError('Error: Please select an address.').'</p>';
|
||||
}
|
||||
if (count($this->context->cart->getDeliveryOptionList()) == 0 && !$this->context->cart->isVirtualCart()) {
|
||||
if ($this->context->cart->isMultiAddressDelivery()) {
|
||||
return '<p class="warning">'.Tools::displayError('Error: None of your chosen carriers deliver to some of the addresses you have selected.').'</p>';
|
||||
|
||||
@@ -399,56 +399,54 @@ class ParentOrderControllerCore extends FrontController
|
||||
Tools::redirect('');
|
||||
} elseif (!Customer::getAddressesTotalById($this->context->customer->id)) {
|
||||
$multi = (int)Tools::getValue('multi-shipping');
|
||||
Tools::redirect('index.php?controller=address&back='.urlencode('order.php?step=1'.($multi ? '&multi-shipping='.$multi : '')));
|
||||
}
|
||||
|
||||
$customer = $this->context->customer;
|
||||
if (Validate::isLoadedObject($customer)) {
|
||||
/* Getting customer addresses */
|
||||
$customerAddresses = $customer->getAddresses($this->context->language->id);
|
||||
if ($customerAddresses = $customer->getAddresses($this->context->language->id)) {
|
||||
// Getting a list of formated address fields with associated values
|
||||
$formatedAddressFieldsValuesList = array();
|
||||
|
||||
// Getting a list of formated address fields with associated values
|
||||
$formatedAddressFieldsValuesList = array();
|
||||
foreach ($customerAddresses as $i => $address) {
|
||||
if (!Address::isCountryActiveById((int)$address['id_address'])) {
|
||||
unset($customerAddresses[$i]);
|
||||
}
|
||||
$tmpAddress = new Address($address['id_address']);
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues(
|
||||
$tmpAddress,
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
|
||||
|
||||
foreach ($customerAddresses as $i => $address) {
|
||||
if (!Address::isCountryActiveById((int)$address['id_address'])) {
|
||||
unset($customerAddresses[$i]);
|
||||
unset($tmpAddress);
|
||||
}
|
||||
$tmpAddress = new Address($address['id_address']);
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues(
|
||||
$tmpAddress,
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
|
||||
|
||||
unset($tmpAddress);
|
||||
}
|
||||
$customerAddresses = array_values($customerAddresses);
|
||||
|
||||
$customerAddresses = array_values($customerAddresses);
|
||||
if (!count($customerAddresses) && !Tools::isSubmit('ajax')) {
|
||||
$bad_delivery = false;
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || !Address::isCountryActiveById((int)$this->context->cart->id_address_invoice)) {
|
||||
$params = array();
|
||||
if ($this->step) {
|
||||
$params['step'] = (int)$this->step;
|
||||
}
|
||||
if ($multi = (int)Tools::getValue('multi-shipping')) {
|
||||
$params['multi-shipping'] = $multi;
|
||||
}
|
||||
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, $params);
|
||||
|
||||
$params = array('back' => $back_url, 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice));
|
||||
if ($multi) {
|
||||
$params['multi-shipping'] = $multi;
|
||||
}
|
||||
|
||||
if (!count($customerAddresses) && !Tools::isSubmit('ajax')) {
|
||||
$bad_delivery = false;
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || !Address::isCountryActiveById((int)$this->context->cart->id_address_invoice)) {
|
||||
$params = array();
|
||||
if ($this->step) {
|
||||
$params['step'] = (int)$this->step;
|
||||
}
|
||||
if ($multi = (int)Tools::getValue('multi-shipping')) {
|
||||
$params['multi-shipping'] = $multi;
|
||||
}
|
||||
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, $params);
|
||||
|
||||
$params = array('back' => $back_url, 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice));
|
||||
if ($multi) {
|
||||
$params['multi-shipping'] = $multi;
|
||||
}
|
||||
|
||||
Tools::redirect($this->context->link->getPageLink('address', true, (int)$this->context->language->id, $params));
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'addresses' => $customerAddresses,
|
||||
'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList)
|
||||
);
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'addresses' => $customerAddresses,
|
||||
'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList)
|
||||
);
|
||||
|
||||
/* Setting default addresses for cart */
|
||||
if (count($customerAddresses)) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class BankwireValidationModuleFrontController extends ModuleFrontController
|
||||
public function postProcess()
|
||||
{
|
||||
$cart = $this->context->cart;
|
||||
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active)
|
||||
if ($cart->id_customer == 0 || !$this->module->active)
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
|
||||
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
|
||||
|
||||
@@ -33,7 +33,7 @@ class ChequeValidationModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
$cart = $this->context->cart;
|
||||
|
||||
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active)
|
||||
if ($cart->id_customer == 0 || !$this->module->active)
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
|
||||
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
|
||||
|
||||
@@ -325,12 +325,7 @@ class WkPaypalCommerceHelper
|
||||
$sql .= ' AND a.`id_address` = ' . (int) $idAddress;
|
||||
}
|
||||
|
||||
$res = Db::getInstance()->executeS($sql);
|
||||
if (count($res) === 1) {
|
||||
return $res[0];
|
||||
} else {
|
||||
return $res;
|
||||
}
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public static function getOrdersByCartId($idCart)
|
||||
|
||||
@@ -278,10 +278,6 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
$customer = new Customer((int)$cart->id_customer);
|
||||
|
||||
$ppHelper = new WkPaypalCommerceHelper();
|
||||
$bilAddr = $ppHelper->getSimpleAddress(
|
||||
(int)$cart->id_customer,
|
||||
(int)$cart->id_address_invoice
|
||||
);
|
||||
|
||||
$orderData['payer'] = array(
|
||||
'name' => array(
|
||||
@@ -291,14 +287,20 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
'email_address' => $customer->email
|
||||
);
|
||||
|
||||
$orderData['payer']['address'] = array(
|
||||
'address_line_1' => $bilAddr['address1'],
|
||||
'address_line_2' => $bilAddr['address2'],
|
||||
'admin_area_2' => $bilAddr['city'],
|
||||
'admin_area_1' => $bilAddr['state_iso'],
|
||||
'postal_code' => $bilAddr['postcode'],
|
||||
'country_code' => $bilAddr['country_iso'],
|
||||
);
|
||||
// address is not required in paypal payment, if customer has added an address then we add tha address to paypal payer object
|
||||
if ($bilAddr = $ppHelper->getSimpleAddress(
|
||||
(int)$cart->id_customer,
|
||||
(int)$cart->id_address_invoice
|
||||
)) {
|
||||
$orderData['payer']['address'] = array(
|
||||
'address_line_1' => $bilAddr['address1'],
|
||||
'address_line_2' => $bilAddr['address2'],
|
||||
'admin_area_2' => $bilAddr['city'],
|
||||
'admin_area_1' => $bilAddr['state_iso'],
|
||||
'postal_code' => $bilAddr['postcode'],
|
||||
'country_code' => $bilAddr['country_iso'],
|
||||
);
|
||||
}
|
||||
|
||||
$timestamp = time().rand(100, 999);
|
||||
$currency = Currency::getCurrency((int) $cart->id_currency);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
{if $invoice_address}
|
||||
<table id="addresses-tab" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<!-- <td width="33%"><span class="bold"> </span><br/><br/>
|
||||
@@ -38,3 +39,4 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/if}
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
{if isset($birthday) && $birthday}
|
||||
<div class="row">
|
||||
<div class="select form-group date-select col-sm-12">
|
||||
@@ -137,7 +137,6 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($newsletter) && $newsletter}
|
||||
<div class="checkbox">
|
||||
<label for="newsletter">
|
||||
|
||||
Reference in New Issue
Block a user