fix unable to create order from backoffice when address is not available

This commit is contained in:
Shreesh Arora
2024-01-19 12:15:59 +05:30
parent c84adf5bf7
commit 6a5ddd5003
3 changed files with 21 additions and 46 deletions

View File

@@ -1386,21 +1386,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*/

View File

@@ -271,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) {
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);

View File

@@ -960,39 +960,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.');