/**
  * Return calculated price for this shipping method
  * @param IsotopeProductCollection
  * @return float
  */
 public function getPrice(IsotopeProductCollection $objCollection = null)
 {
     if (null === $objCollection) {
         $objCollection = Isotope::getCart();
     }
     $strPrice = $this->arrData['price'];
     if ($this->isPercentage()) {
         $fltSurcharge = (double) substr($strPrice, 0, -1);
         $fltPrice = $objCollection->subTotal / 100 * $fltSurcharge;
     } else {
         $fltPrice = (double) $strPrice;
     }
     //Make Call to UPS API to retrieve pricing
     $fltPrice += $this->getLiveRateQuote($objCollection);
     return Isotope::calculatePrice($fltPrice, $this, 'fedex', $this->arrData['tax_class']);
 }
Beispiel #2
0
 /**
  * Return calculated price for this shipping method
  * @return float
  */
 public function getPrice(IsotopeProductCollection $objCollection = null)
 {
     if (null === $objCollection) {
         $objCollection = Isotope::getCart();
     }
     if ($this->isPercentage()) {
         $fltPrice = $objCollection->getSubtotal() / 100 * $this->getPercentage();
     } else {
         $fltPrice = (double) $this->arrData['price'];
     }
     if ($this->flatCalculation == 'perProduct' || $this->flatCalculation == 'perItem') {
         $arrItems = $objCollection->getItems();
         $intMultiplier = 0;
         foreach ($arrItems as $objItem) {
             if (!$objItem->hasProduct() || $objItem->getProduct()->isExemptFromShipping()) {
                 continue;
             }
             $intMultiplier += $this->flatCalculation == 'perProduct' ? 1 : $objItem->quantity;
         }
         $fltPrice = $fltPrice * $intMultiplier;
     }
     return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']);
 }
 /**
  * Return calculated price for this shipping method
  * @return float
  */
 public function getPrice(IsotopeProductCollection $objCollection = null)
 {
     if (null === $objCollection) {
         $objCollection = Isotope::getCart();
     }
     if ($this->or_pricing == '1') {
         $fltAltPrice = $objCollection->subTotal - $objCollection->subTotal / (1 + floatval($this->alternative_price) / 100);
         switch ($this->alternative_price_logic) {
             case '1':
                 //less
                 $fltPrice = $this->arrData['price'] < $fltAltPrice ? $this->arrData['price'] : $fltAltPrice;
                 break;
             case '2':
                 //greater
                 $fltPrice = $this->arrData['price'] > $fltAltPrice ? $this->arrData['price'] : $fltAltPrice;
                 break;
         }
         return $fltPrice;
     } else {
         return $this->arrData['price'];
     }
     return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']);
 }
Beispiel #4
0
    /**
     * Generate HTML table for associative array values
     * @param   array
     * @param   IsotopeProduct
     * @return  string
     */
    protected function generateTable(array $arrValues, IsotopeProduct $objProduct)
    {
        $arrFormat = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$this->field_name]['tableformat'];
        $last = count($arrValues[0]) - 1;
        $strBuffer = '
<table class="' . $this->field_name . '">
  <thead>
    <tr>';
        foreach (array_keys($arrValues[0]) as $i => $name) {
            if ($arrFormat[$name]['doNotShow']) {
                continue;
            }
            $label = $arrFormat[$name]['label'] ? $arrFormat[$name]['label'] : $name;
            $strBuffer .= '
      <th class="head_' . $i . ($i == 0 ? ' head_first' : '') . ($i == $last ? ' head_last' : '') . (!is_numeric($name) ? ' ' . standardize($name) : '') . '">' . $label . '</th>';
        }
        $strBuffer .= '
    </tr>
  </thead>
  <tbody>';
        foreach ($arrValues as $r => $row) {
            $strBuffer .= '
    <tr class="row_' . $r . ($r == 0 ? ' row_first' : '') . ($r == $last ? ' row_last' : '') . ' ' . ($r % 2 ? 'odd' : 'even') . '">';
            $c = -1;
            foreach ($row as $name => $value) {
                if ($arrFormat[$name]['doNotShow']) {
                    continue;
                }
                if ($arrFormat[$name]['rgxp'] == 'price') {
                    $intTax = (int) $row['tax_class'];
                    $value = Isotope::formatPriceWithCurrency(Isotope::calculatePrice($value, $objProduct, $this->field_name, $intTax));
                } else {
                    $value = $arrFormat[$name]['format'] ? sprintf($arrFormat[$name]['format'], $value) : $value;
                }
                $strBuffer .= '
      <td class="col_' . ++$c . ($c == 0 ? ' col_first' : '') . ($c == $i ? ' col_last' : '') . ' ' . standardize($name) . '">' . $value . '</td>';
            }
            $strBuffer .= '
    </tr>';
        }
        $strBuffer .= '
  </tbody>
</table>';
        return $strBuffer;
    }
 /**
  * Get lowest amount of all tiers
  *
  * @param array $arrOptions
  *
  * @return float
  */
 public function getLowestAmount(array $arrOptions = array())
 {
     if (!$this->hasTiers()) {
         return $this->getAmount();
     }
     return Isotope::calculatePrice(min($this->arrTiers), $this, 'price', $this->tax_class, null, $arrOptions);
 }
Beispiel #6
0
 /**
  * Return calculated price for this shipping method
  * @return float
  */
 public function getPrice(IsotopeProductCollection $objCollection = null)
 {
     if (null === $objCollection) {
         $objCollection = Isotope::getCart();
     }
     if ($this->isPercentage()) {
         $fltPrice = $objCollection->getSubtotal() / 100 * $this->getPercentage();
     } else {
         $fltPrice = (double) $this->arrData['price'];
     }
     return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']);
 }
 /**
  * Return calculated price for this attribute option
  *
  * @param float $fltPrice    The product base price
  * @param int   $intTaxClass Tax ID of the product
  *
  * @return float
  */
 public function getAmount($fltPrice, $intTaxClass)
 {
     if ($this->isPercentage()) {
         return $fltPrice / 100 * $this->getPercentage();
     }
     return Isotope::calculatePrice($this->price, $this, 'price', $intTaxClass);
 }
Beispiel #8
0
 /**
  * Return calculated price for this attribute option
  *
  * @param IsotopeProduct $objProduct
  *
  * @return float
  */
 public function getPrice(IsotopeProduct $objProduct = null)
 {
     if ($this->isPercentage() && null !== $objProduct) {
         /** @type ProductPrice|ProductPrice[] $objPrice */
         $objPrice = $objProduct->getPrice();
         if (null !== $objPrice) {
             if ($objPrice instanceof ProductPriceCollection) {
                 $fltPrice = null;
                 foreach ($objPrice as $objPriceModel) {
                     $fltAmount = $objPriceModel->getAmount();
                     if (null === $fltPrice || $fltAmount < $fltPrice) {
                         $fltPrice = $fltAmount;
                     }
                 }
             } else {
                 $fltPrice = $objPrice->getAmount();
             }
             return $fltPrice / 100 * $this->getPercentage();
         }
     } else {
         /** @type ProductPrice|ProductPrice[] $objPrice */
         if (null !== $objProduct && ($objPrice = $objProduct->getPrice()) !== null) {
             return Isotope::calculatePrice($this->price, $this, 'price', $objPrice->tax_class);
         } else {
             return Isotope::calculatePrice($this->price, $this, 'price');
         }
     }
     return $this->price;
 }