public static function generateDeliveryPoints($country = false, $city = false) { $response = true; $helper = new API(); $deliverypoints = DynamicParcelDistribution::objectToarray($helper->getDeliveryPoints($country, $city)); if (!isset($deliverypoints['errlog'])) { $table_name = DpdDeliveryPoints::getPointsTableName(''); Db::getInstance()->execute('TRUNCATE `' . _DB_PREFIX_ . $table_name . '`'); foreach ($deliverypoints as $deliverypoint) { $deliverypoint['created_time'] = date('Y-m-d H:i:s'); $deliverypoint['update_time'] = date('Y-m-d H:i:s'); $response &= Db::getInstance()->insert($table_name, $deliverypoint); } } else { $response = $deliverypoints; } return $response; }
public function getDeliveryTimeAvailable($deliveryShippinCity) { $deliverySettings = Configuration::get(self::CONST_PREFIX . 'DELIVERY_TIME') === false ? array_values(BalticodeDpdData::fliparrayList(unserialize(self::$defaultValues['DELIVERY_TIME']))) : array_values(unserialize(Configuration::get(self::CONST_PREFIX . 'DELIVERY_TIME'))); if ($deliverySettings === false) { //Not set any times return self::$delivery_time; } $line = BalticodeDpdData::recursiveArraySearch(trim(Tools::strtolower($deliveryShippinCity)), $this->arrayChangeValueCase($deliverySettings)); if ($line !== false) { self::$delivery_time = array_intersect_key(self::$delivery_time, array_flip($deliverySettings[$line]['time'])); } else { self::$delivery_time = array(); } return $this; }
/** * Override for Prestashop 16 */ private function initToolbar16() { if ($this->display == 'view') { /** @var Order $order */ $order = $this->loadObject(); $customer = $this->context->customer; if (!Validate::isLoadedObject($order)) { Tools::redirectAdmin($this->context->link->getAdminLink('AdminOrders')); } $this->toolbar_title[] = sprintf($this->l('Order %1$s from %2$s %3$s'), $order->reference, $customer->firstname, $customer->lastname); $this->addMetaTitle($this->toolbar_title[count($this->toolbar_title) - 1]); if ($order->hasBeenShipped()) { $type = $this->l('Return products'); } elseif ($order->hasBeenPaid()) { $type = $this->l('Standard refund'); } else { $type = $this->l('Cancel products'); } if (!$order->hasBeenShipped() && !$this->lite_display) { $this->toolbar_btn['new'] = array('short' => 'Create', 'href' => '#', 'desc' => $this->l('Add a product'), 'class' => 'add_product'); } if (Configuration::get('PS_ORDER_RETURN') && !$this->lite_display) { $this->toolbar_btn['standard_refund'] = array('short' => 'Create', 'href' => '', 'desc' => $type, 'class' => 'process-icon-standardRefund'); } if ($order->hasInvoice() && !$this->lite_display) { $this->toolbar_btn['partial_refund'] = array('short' => 'Create', 'href' => '', 'desc' => $this->l('Partial refund'), 'class' => 'process-icon-partialRefund'); } } if (class_exists('DynamicParcelDistribution')) { if (DynamicParcelDistribution::isEnabled('dynamicparceldistribution') && Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'ALLOW_COURIER_PICKUP')) { $this->toolbar_btn['call_carrier'] = array('short' => 'Create', 'href' => '#', 'desc' => $this->l('Call DPD Carrier'), 'class' => 'process-icon-callCarrier', 'js' => 'showCarrierWindow()'); } } $res = parent::initToolbar(); if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP && isset($this->toolbar_btn['new']) && Shop::isFeatureActive()) { unset($this->toolbar_btn['new']); } return $res; }
/** * Calculate carrier price by restrictions * * @param array $product Product dimensions array * @param array $rescriction rescriction who need to be apply * @param float $cartPrice Total cart price is for free shipping * @return mix boolean false if price shipping not allowed * float price of shipping */ public static function getRescrictionPrice($product, $rescriction, $cartPrice = 0) { $price = array('regular' => (double) 0, 'additional' => (double) 0); if ($rescriction['free_from_price'] >= 0) { //free shipping is enabled if ($cartPrice >= $rescriction['free_from_price']) { $price['regular'] = (double) 0.0; //Return free shipping return $price; } } if ($product['height'] <= $rescriction['dimensions']['height'] && $product['width'] <= $rescriction['dimensions']['width'] && $product['depth'] <= $rescriction['dimensions']['depth']) { //Package size is small $price['regular'] = (double) $rescriction['base_price']; //Return base shipping price return $price; } else { //Package size is to high if ($rescriction['oversized_price'] == '-1') { //Oversize is not disallowed? return false; //Cannot ship this product } else { //Oversize is allowed if ($rescriction['oversized_price'] >= 0) { //Oversize price is correct? $price = array('regular' => (double) $rescriction['base_price'], 'additional' => (double) ($rescriction['oversized_price'] * $product['quantity'])); return $price; } else { DynamicParcelDistribution::log('getRescrictionPrice -> Oversize price is not correct given: ' . $rescriction['oversized_price']); return false; } } } return false; }