Esempio n. 1
0
 /**
  * Returns amount (total net price/weight/volume/Amount) on which delivery price is applied
  *
  * @param oxBasketItem $oBasketItem basket item object
  *
  * @return double
  */
 public function getDeliveryAmount($oBasketItem)
 {
     $dAmount = 0;
     $oProduct = $oBasketItem->getArticle(false);
     if ($oProduct->isOrderArticle()) {
         $oProduct = $oProduct->getArticle();
     }
     $blExclNonMaterial = $this->getConfig()->getConfigParam('blExclNonMaterialFromDelivery');
     // mark free shipping products
     if ($oProduct->oxarticles__oxfreeshipping->value || $oProduct->oxarticles__oxnonmaterial->value && $blExclNonMaterial) {
         if ($this->_blFreeShipping !== false) {
             $this->_blFreeShipping = true;
         }
     } else {
         $this->_blFreeShipping = false;
         switch ($this->getConditionType()) {
             case self::CONDITION_TYPE_PRICE:
                 // price
                 if ($this->getCalculationRule() == self::CALCULATION_RULE_FOR_EACH_PRODUCT) {
                     $dAmount += $oProduct->getPrice()->getPrice();
                 } else {
                     $dAmount += $oBasketItem->getPrice()->getPrice();
                     // price// currency conversion must allready be done in price class / $oCur->rate; // $oBasketItem->oPrice->getPrice() / $oCur->rate;
                 }
                 break;
             case self::CONDITION_TYPE_WEIGHT:
                 // weight
                 if ($this->getCalculationRule() == self::CALCULATION_RULE_FOR_EACH_PRODUCT) {
                     $dAmount += $oProduct->getWeight();
                 } else {
                     $dAmount += $oBasketItem->getWeight();
                 }
                 break;
             case self::CONDITION_TYPE_SIZE:
                 // size
                 $dAmount += $oProduct->getSize();
                 if ($this->getCalculationRule() != self::CALCULATION_RULE_FOR_EACH_PRODUCT) {
                     $dAmount *= $oBasketItem->getAmount();
                 }
                 break;
             case self::CONDITION_TYPE_AMOUNT:
                 // amount
                 $dAmount += $oBasketItem->getAmount();
                 break;
         }
         if ($oBasketItem->getPrice()) {
             $this->_dPrice += $oBasketItem->getPrice()->getPrice();
         }
     }
     return $dAmount;
 }
 /**
  * Returns amount (total net price/weight/volume/Amount) on which delivery price is applied
  *
  * @param oxBasketItem $oBasketItem basket item object
  *
  * @return double
  */
 public function getDeliveryAmount($oBasketItem)
 {
     $dAmount = 0;
     $oProduct = $oBasketItem->getArticle(false);
     // mark free shipping products
     if ($oProduct->oxarticles__oxfreeshipping->value) {
         if ($this->_blFreeShipping !== false) {
             $this->_blFreeShipping = true;
         }
     } else {
         $blExclNonMaterial = $this->getConfig()->getConfigParam('blExclNonMaterialFromDelivery');
         if (!($oProduct->oxarticles__oxnonmaterial->value && $blExclNonMaterial)) {
             $this->_blFreeShipping = false;
         }
         switch ($this->oxdelivery__oxdeltype->value) {
             case 'p':
                 // price
                 if ($this->oxdelivery__oxfixed->value == 2) {
                     $dAmount += $oProduct->getPrice()->getBruttoPrice();
                 } else {
                     $dAmount += $oBasketItem->getPrice()->getBruttoPrice();
                     // price// currency conversion must allready be done in price class / $oCur->rate; // $oBasketItem->oPrice->getPrice() / $oCur->rate;
                 }
                 break;
             case 'w':
                 // weight
                 if ($this->oxdelivery__oxfixed->value == 2) {
                     $dAmount += $oProduct->oxarticles__oxweight->value;
                 } else {
                     $dAmount += $oBasketItem->getWeight();
                 }
                 break;
             case 's':
                 // size
                 $dAmount += $oProduct->oxarticles__oxlength->value * $oProduct->oxarticles__oxwidth->value * $oProduct->oxarticles__oxheight->value;
                 if ($this->oxdelivery__oxfixed->value < 2) {
                     $dAmount *= $oBasketItem->getAmount();
                 }
                 break;
             case 'a':
                 // amount
                 $dAmount += $oBasketItem->getAmount();
                 break;
         }
         if ($oBasketItem->getPrice()) {
             $this->_dPrice += $oBasketItem->getPrice()->getBruttoPrice();
         }
     }
     return $dAmount;
 }