Remove address as required in booking/order flow
This commit is contained in:
@@ -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)) {
|
||||
@@ -463,15 +460,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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,11 +416,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2065,8 +2065,8 @@ abstract class ModuleCore
|
||||
public static function getPaymentModules()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
if (isset($context->cart)) {
|
||||
$billing = new Address((int)$context->cart->id_address_invoice);
|
||||
if (Validate::isLoadedObject($context->country)) {
|
||||
$id_country = (int)$context->country->id;
|
||||
}
|
||||
|
||||
$use_groups = Group::isFeatureActive();
|
||||
@@ -2097,7 +2097,7 @@ 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 : '').'
|
||||
'.(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).'))' : '').'
|
||||
|
||||
@@ -735,9 +735,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
|
||||
|
||||
Reference in New Issue
Block a user