Beispiel #1
0
 private function getModulePrice($prices)
 {
     $iso_code = $this->currency->iso_code;
     if (array_key_exists($iso_code, $prices)) {
         $prices['displayPrice'] = $this->priceFormatter->convertAndFormat($prices[$iso_code]);
         $prices['raw'] = $prices[$iso_code];
     } else {
         $prices['displayPrice'] = '$' . $prices['USD'];
         $prices['raw'] = $prices['USD'];
     }
     return $prices;
 }
 public function getGiftCostForLabel()
 {
     if ($this->getGiftCost() != 0) {
         $taxLabel = '';
         $priceFormatter = new PriceFormatter();
         if ($this->getIncludeTaxes() && $this->getDisplayTaxesLabel()) {
             $taxLabel .= ' tax incl.';
         } elseif ($this->getDisplayTaxesLabel()) {
             $taxLabel .= ' tax excl.';
         }
         return sprintf($this->getTranslator()->trans(' (additional cost of %giftcost% %taxlabel%)', array('%giftcost%' => $priceFormatter->convertAndFormat($this->getGiftCost()), '%taxlabel%' => $taxLabel), 'Shop.Theme.Checkout'));
     }
     return '';
 }
Beispiel #3
0
 protected function formatQuantityDiscounts($specific_prices, $price, $tax_rate, $ecotax_amount)
 {
     $priceFormatter = new PriceFormatter();
     foreach ($specific_prices as $key => &$row) {
         $row['quantity'] =& $row['from_quantity'];
         if ($row['price'] >= 0) {
             // The price may be directly set
             $cur_price = (!$row['reduction_tax'] ? $row['price'] : $row['price'] * (1 + $tax_rate / 100)) + (double) $ecotax_amount;
             if ($row['reduction_type'] == 'amount') {
                 $cur_price -= $row['reduction_tax'] ? $row['reduction'] : $row['reduction'] / (1 + $tax_rate / 100);
                 $row['reduction_with_tax'] = $row['reduction_tax'] ? $row['reduction'] : $row['reduction'] / (1 + $tax_rate / 100);
             } else {
                 $cur_price *= 1 - $row['reduction'];
             }
             $row['real_value'] = $price > 0 ? $price - $cur_price : $cur_price;
             $discountPrice = $price - $row['real_value'];
             if (Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')) {
                 if ($row['reduction_tax'] == 0 && !$row['price']) {
                     $row['discount'] = $priceFormatter->convertAndFormat($price - $price * $row['reduction_with_tax']);
                 } else {
                     $row['discount'] = $priceFormatter->convertAndFormat($price - $row['real_value']);
                 }
             } else {
                 $row['discount'] = $priceFormatter->convertAndFormat($row['real_value']);
             }
         } else {
             if ($row['reduction_type'] == 'amount') {
                 if (Product::$_taxCalculationMethod == PS_TAX_INC) {
                     $row['real_value'] = $row['reduction_tax'] == 1 ? $row['reduction'] : $row['reduction'] * (1 + $tax_rate / 100);
                 } else {
                     $row['real_value'] = $row['reduction_tax'] == 0 ? $row['reduction'] : $row['reduction'] / (1 + $tax_rate / 100);
                 }
                 $row['reduction_with_tax'] = $row['reduction_tax'] ? $row['reduction'] : $row['reduction'] + $row['reduction'] * $tax_rate / 100;
                 $discountPrice = $price - $row['real_value'];
                 if (Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')) {
                     if ($row['reduction_tax'] == 0 && !$row['price']) {
                         $row['discount'] = $priceFormatter->convertAndFormat($price - $price * $row['reduction_with_tax']);
                     } else {
                         $row['discount'] = $priceFormatter->convertAndFormat($price - $row['real_value']);
                     }
                 } else {
                     $row['discount'] = $priceFormatter->convertAndFormat($row['real_value']);
                 }
             } else {
                 $row['real_value'] = $row['reduction'] * 100;
                 $discountPrice = $price - $price * $row['reduction'];
                 if (Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')) {
                     if ($row['reduction_tax'] == 0) {
                         $row['discount'] = $priceFormatter->convertAndFormat($price - $price * $row['reduction_with_tax']);
                     } else {
                         $row['discount'] = $priceFormatter->convertAndFormat($price - $price * $row['reduction']);
                     }
                 } else {
                     $row['discount'] = $row['real_value'] . '%';
                 }
             }
         }
         $row['save'] = $priceFormatter->convertAndFormat($price * $row['quantity'] - $discountPrice * $row['quantity']);
         $row['nextQuantity'] = isset($specific_prices[$key + 1]) ? (int) $specific_prices[$key + 1]['from_quantity'] : -1;
     }
     return $specific_prices;
 }