public function getQuote($address)
 {
     $quote = parent::getQuote($address);
     $this->getLoader()->language('shipping/emsDiscounted');
     //        $this->log->write(print_r($quote, true));
     if (empty($quote['quote'])) {
         return null;
     }
     $quote['code'] = 'emsDiscounted';
     $quote['title'] = $this->language->get('HEADING_TITLE');
     $quote['sort_order'] = $this->getConfig()->get('emsDiscounted_sortOrder');
     $quote['error'] = false;
     foreach ($quote['quote'] as $key => $value) {
         $quote['quote'][$key]['code'] = "emsDiscounted.{$key}";
         $quote['quote'][$key]['cost'] *= (100 - $this->getConfig()->get('emsDiscounted_discountAmount')) / 100;
         $quote['quote'][$key]['text'] = $this->currency->format($quote['quote'][$key]['cost']);
         $quote['quote'][$key]['title'] .= " Discounted";
     }
     //        $this->log->write(print_r($quote, true));
     return $quote;
 }
Exemple #2
0
 public function getQuotes($address)
 {
     $quotes = array();
     $total = $this->cart->getSubTotal();
     $title = empty($langdata['name']) ? $this->language->get('text_title') : $langdata['name'];
     $free_shipping = (double) $this->config->get('shoputils_ems_free_shipping');
     if (!empty($free_shipping) && $total > $free_shipping) {
         $total = $total > $free_shipping ? 0 : $total;
         $text = $this->language->get('text_free_shipping');
         $quotes['shoputils_ems'] = array('code' => 'shoputils_ems.shoputils_ems_free', 'title' => $title, 'cost' => $total, 'tax_class_id' => 0, 'text' => $text);
     } else {
         $rates = array();
         if (isset($this->session->data['ems_item_id'])) {
             $amount = number_format($this->currency->format($total, '', $this->currency->getValue(self::EMS_CURRENCY_CODE), FALSE), 0, '', '');
             $weight = number_format($this->getWeight() + $this->getAdvancedWeight(), 2, '.', '');
             $this->load->library('ems');
             $ems = new Ems($this->registry);
             $rates = $ems->getShippingRates(array('from_city_id' => $this->config->get('shoputils_ems_city_id'), 'to_item_id' => $this->session->data['ems_item_id'], 'weight' => $weight, 'amount' => $amount, 'shipping_rate' => (int) $this->config->get('shoputils_ems_shipping_rate'), 'international' => $address['country_id'] != $this->config->get('shoputils_ems_country'), 'advanced_price' => (double) $this->config->get('shoputils_ems_advanced_price')));
         }
         foreach ($rates as $rate) {
             $cost = $this->currency->convert($rate['total_total'], self::EMS_CURRENCY_CODE, $this->currency->getCode());
             $quotes['shoputils_ems'] = array('code' => 'shoputils_ems.shoputils_ems', 'title' => $this->language->get('text_ems_rate_title'), 'description' => $this->getRateDescription($rate, $address), 'cost' => $cost, 'tax_class_id' => 0, 'text' => $this->currency->format($cost));
         }
     }
     return $quotes;
 }