Example #1
0
 /**
  *
  * @param float $price
  * @param bool $priceDiscount [optional]
  * @param mixed float|bool $useRate [optional]
  * @param string $code [optional]
  * @return string
  */
 public function price($price, $priceDiscount = false, $code = '')
 {
     if (!is_array($price)) {
         // product page
         if (false !== $priceDiscount && !empty($priceDiscount) && $price != $priceDiscount) {
             $priceSave = $this->_currency->toCurrency($price - $priceDiscount);
             $price = $this->_currency->toCurrency($price, $code);
             $priceDiscount = $this->_currency->toCurrency($priceDiscount, $code);
             return '<div class="price-box"><p class="old-price">' . '<span class="label">' . $this->_translate->__('Regular price') . ':</span> ' . '<span class="price">' . $price . '</span></p>' . '<p class="special-price">' . '<span class="label">' . $this->_translate->__('Special price') . ':</span> ' . '<span class="price">' . $priceDiscount . '</span></p>' . '<p class="save-price">' . '<span class="label">' . $this->_translate->__('You save') . ':</span> ' . '<span class="price">' . $priceSave . '</span></p></div>';
         }
         $price = $this->_currency->toCurrency($price, $code);
         return '<div class="price-box"><p class="regular-price">' . '<span class="label">' . $this->_translate->__('Price') . ':</span> ' . '<span class="price">' . $price . '</span></p></div>';
     }
     // product listing
     $minPrice = $this->_currency->toCurrency($price['min_price'], $code);
     $maxPrice = $this->_currency->toCurrency($price['max_price'], $code);
     $finalMinPrice = $this->_currency->toCurrency($price['final_min_price'], $code);
     $finalMaxPrice = $this->_currency->toCurrency($price['final_max_price'], $code);
     $finalPrice = 0;
     $savePrice = 0;
     $regularPrice = $minPrice;
     if ($price['min_price'] != $price['max_price']) {
         $regularPrice .= ' &mdash; ' . $maxPrice;
     }
     if ($price['final_min_price'] != $price['min_price'] || $price['final_max_price'] != $price['max_price']) {
         $finalPrice = $finalMinPrice;
         if ($price['final_min_price'] != $price['final_max_price']) {
             $finalPrice .= ' &mdash; ' . $finalMaxPrice;
         }
         $minSave = $price['min_price'] - $price['final_min_price'];
         $maxSave = $price['max_price'] - $price['final_max_price'];
         $minSavePrice = $this->_currency->toCurrency($minSave, $code);
         $maxSavePrice = $this->_currency->toCurrency($maxSave, $code);
         $savePrice = $minSavePrice;
         if ($minSave != $maxSave) {
             $savePrice = $this->_translate->__("up to %s", $minSave > $maxSave ? $minSavePrice : $maxSavePrice);
             // $savePrice .= ' &mdash; ' . $maxSavePrice;
         }
     }
     if ($savePrice) {
         return '<div class="price-box"><p class="old-price">' . '<span class="label">' . $this->_translate->__('Regular price') . ':</span> ' . '<span class="price">' . $regularPrice . '</span></p>' . '<p class="special-price">' . '<span class="label">' . $this->_translate->__('Special price') . ':</span> ' . '<span class="price">' . $finalPrice . '</span></p>' . '<p class="save-price">' . '<span class="label">' . $this->_translate->__('You save') . ':</span> ' . '<span class="price">' . $savePrice . '</span></p></div>';
     }
     return '<div class="price-box"><p class="regular-price">' . '<span class="label">' . $this->_translate->__('Price') . ':</span> ' . '<span class="price">' . $regularPrice . '</span></p></div>';
 }
Example #2
0
 /**
  * @param string $text
  * @param array $args
  * @return string
  */
 public function __()
 {
     return $this->_translate->translate(func_get_args());
 }
Example #3
0
 /**
  *
  * @param string $name
  * @return Axis_Translate
  */
 public static function translate($module = 'Axis_Core')
 {
     if (false === strpos($module, '_')) {
         $module = 'Axis' . '_' . ucfirst($module);
     }
     $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
     return Axis_Translate::getInstance($module);
 }