コード例 #1
0
 public function testGetDeliveryAmountCalcBySizePerOrderProduct()
 {
     /** @var oxDelivery $oDelivery delivery by size. */
     $oDelivery = oxNew('oxDelivery');
     $oDelivery->oxdelivery__oxdeltype = new oxField('s', oxField::T_RAW);
     $oDelivery->oxdelivery__oxfixed = new oxField('2', oxField::T_RAW);
     /** @var oxOrderArticle|PHPUnit_Framework_MockObject_MockObject $oOrderArticle */
     $oOrderArticle = $this->getMock('oxOrderArticle', array(), array(), '', false);
     $oOrderArticle->expects($this->any())->method('getArticle')->will($this->returnValue($this->_oBasketItem->getArticle()));
     $oOrderArticle->expects($this->any())->method('isOrderArticle')->will($this->returnValue(true));
     /** @var oxBasketItem $oBasketItem|PHPUnit_Framework_MockObject_MockObject */
     $oBasketItem = $this->getMock('oxBasketItem', array(), array(), '', false);
     $oBasketItem->expects($this->any())->method('getArticle')->will($this->returnValue($oOrderArticle));
     $this->assertEquals(48, $oDelivery->getDeliveryAmount($oBasketItem));
 }
コード例 #2
0
ファイル: oxdelivery.php プロジェクト: ioanok/symfoxid
 /**
  * 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;
 }
 /**
  * Checks if Article params equals with current items params.
  *
  * @param oxBasketItem $oBasketItem
  *
  * @return bool
  */
 protected function _isArticleParamsEqual($oBasketItem)
 {
     return $oBasketItem->getProductId() == $this->getItemToValidate()->getArticleId() && $oBasketItem->getPersParams() == $this->getItemToValidate()->getPersistParam() && $oBasketItem->getSelList() == $this->getItemToValidate()->getSelectList();
 }
コード例 #4
0
ファイル: Delivery.php プロジェクト: Alpha-Sys/oxideshop_ce
 /**
  * Update total count of product items are covered by current delivery.
  *
  * @param oxBasketItem $content
  */
 protected function updateItemCount($content)
 {
     $this->_iItemCnt += $content->getAmount();
 }
コード例 #5
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);
     // 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;
 }