update
This commit is contained in:
@@ -4964,6 +4964,8 @@ class OnePageCheckoutPS extends OnePageCheckoutPSCore
|
||||
}
|
||||
}
|
||||
|
||||
$this->validateDpdPickupPointSelection();
|
||||
|
||||
return array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
@@ -5063,6 +5065,8 @@ class OnePageCheckoutPS extends OnePageCheckoutPSCore
|
||||
}
|
||||
}
|
||||
|
||||
$this->validateDpdPickupPointSelection();
|
||||
|
||||
return array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'hasWarning' => !empty($this->warnings),
|
||||
@@ -5075,6 +5079,68 @@ class OnePageCheckoutPS extends OnePageCheckoutPSCore
|
||||
}
|
||||
}
|
||||
|
||||
private function validateDpdPickupPointSelection()
|
||||
{
|
||||
if (!Validate::isLoadedObject($this->context->cart) || !(int) $this->context->cart->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((int) $this->context->cart->id_carrier <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$carrier = new Carrier((int) $this->context->cart->id_carrier);
|
||||
if (!Validate::isLoadedObject($carrier)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$id_shop = (int) $this->context->cart->id_shop;
|
||||
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||
if (!empty($id_shop)) {
|
||||
$shop = new Shop($id_shop);
|
||||
if (Validate::isLoadedObject($shop)) {
|
||||
$id_shop_group = (int) $shop->id_shop_group;
|
||||
}
|
||||
} else {
|
||||
$id_shop = Shop::getContextShopID(true);
|
||||
}
|
||||
|
||||
$dpd_pickup_references = array(
|
||||
(int) Configuration::get('DPDPOLAND_PUDO_ID', null, $id_shop_group, $id_shop),
|
||||
(int) Configuration::get('DPDPOLAND_PUDO_COD_ID', null, $id_shop_group, $id_shop),
|
||||
(int) Configuration::get('CARRIER_SWIPBOX_ID', null, $id_shop_group, $id_shop),
|
||||
);
|
||||
|
||||
$is_dpd_pickup_carrier = false;
|
||||
foreach ($dpd_pickup_references as $reference) {
|
||||
if ($reference > 0 && (int) $carrier->id_reference === $reference) {
|
||||
$is_dpd_pickup_carrier = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$is_dpd_pickup_carrier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$pudo_code = Db::getInstance()->getValue('
|
||||
SELECT `pudo_code`
|
||||
FROM `' . _DB_PREFIX_ . 'dpdpoland_pudo_cart`
|
||||
WHERE `id_cart` = ' . (int) $this->context->cart->id
|
||||
);
|
||||
|
||||
if (trim((string) $pudo_code) !== '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$error = $this->l('Wybierz punkt DPD Pickup przed złożeniem zamówienia.');
|
||||
if (!in_array($error, $this->errors)) {
|
||||
$this->errors[] = $error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteEmptyAddressesOPC()
|
||||
{
|
||||
$query = 'DELETE FROM '._DB_PREFIX_.'address WHERE id_customer = '.(int)$this->config_vars['OPC_ID_CUSTOMER'];
|
||||
@@ -5422,4 +5488,4 @@ class OnePageCheckoutPS extends OnePageCheckoutPSCore
|
||||
$this->smarty->assign($params);
|
||||
echo $this->smarty->fetch(_PS_MODULE_DIR_.$this->name.'/views/templates/front/'.$tpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user