コード例 #1
0
ファイル: Tax.php プロジェクト: kingsj/core
 /**
  * Calculate shipping net price
  * 
  * @param \XLite\Model\Shipping\Rate $rate  Rate
  * @param float                      $price Price
  *  
  * @return float
  */
 public function deductTaxFromPrice(\XLite\Model\Shipping\Rate $rate, $price)
 {
     $classes = $rate->getMethod() ? $rate->getMethod()->getClasses() : null;
     foreach ($this->getTaxes() as $tax) {
         $includedZones = $tax->getVATZone() ? array($tax->getVATZone()->getZoneId()) : array();
         $included = $tax->getFilteredRate($includedZones, $tax->getVATMembership(), $classes);
         if ($included) {
             $price -= $included->calculateValueExcludingTax($price);
         }
     }
     return $price;
 }
コード例 #2
0
ファイル: Shipping.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Shipping rates sorting callback
  *
  * @param \XLite\Model\Shipping\Rate $a First shipping rate
  * @param \XLite\Model\Shipping\Rate $b Second shipping rate
  *
  * @return integer
  */
 protected function compareRates(\XLite\Model\Shipping\Rate $a, \XLite\Model\Shipping\Rate $b)
 {
     $aMethod = $a->getMethod();
     $bMethod = $b->getMethod();
     $aRate = $a->getTotalRate();
     $bRate = $b->getTotalRate();
     return 'auctionInc' === $aMethod->getProcessor() && 'auctionInc' === $bMethod->getProcessor() ? $aRate === $bRate ? 0 : ($aRate < $bRate ? -1 : 1) : parent::compareRates($a, $b);
 }
コード例 #3
0
ファイル: Shipping.php プロジェクト: kingsj/core
 /**
  * Set shipping rate and shipping method id
  *
  * @param \XLite\Model\Shipping\Rate $rate Shipping rate object OPTIONAL
  *
  * @return void
  */
 public function setSelectedRate(\XLite\Model\Shipping\Rate $rate = null)
 {
     $newShippingId = $this->order->getShippingId();
     $this->selectedRate = $rate;
     $newShippingId = $rate ? $rate->getMethodId() : 0;
     if ($this->order->getShippingId() != $newShippingId) {
         $this->order->setShippingId($newShippingId);
         $this->order->setShippingMethodName($rate ? $rate->getMethod()->getName() : null);
         \XLite\Core\Database::getEM()->flush();
     }
 }
コード例 #4
0
ファイル: ShipMethod.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Get rate method name
  *
  * @param \XLite\Model\Shipping\Rate $rate Shipping rate
  *
  * @return string
  */
 protected function getMethodName(\XLite\Model\Shipping\Rate $rate)
 {
     return $rate->getMethod()->getName();
 }
コード例 #5
0
ファイル: Shipping.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Shipping rates sorting callback
  *
  * @param \XLite\Model\Shipping\Rate $a First shipping rate
  * @param \XLite\Model\Shipping\Rate $b Second shipping rate
  *
  * @return integer
  */
 protected function compareRates(\XLite\Model\Shipping\Rate $a, \XLite\Model\Shipping\Rate $b)
 {
     $aMethod = $a->getMethod();
     $bMethod = $b->getMethod();
     $aPosition = $aMethod->getPosition();
     $bPosition = $bMethod->getPosition();
     if ('offline' !== $aMethod->getProcessor() && 'offline' !== $bMethod->getProcessor()) {
         if ($aMethod->getProcessor() !== $bMethod->getProcessor()) {
             $aPosition = $aMethod->getParentMethod()->getPosition();
             $bPosition = $bMethod->getParentMethod()->getPosition();
         }
     } elseif ('offline' !== $aMethod->getProcessor()) {
         $aPosition = $aMethod->getParentMethod()->getPosition();
     } elseif ('offline' !== $bMethod->getProcessor()) {
         $bPosition = $bMethod->getParentMethod()->getPosition();
     }
     return $aPosition === $bPosition ? 0 : ($aPosition < $bPosition ? -1 : 1);
 }
コード例 #6
0
ファイル: ShippingList.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Returns delivery time for method
  *
  * @param \XLite\Model\Shipping\Rate $rate Shipping rate
  *
  * @return string
  */
 protected function getMethodDeliveryTime(\XLite\Model\Shipping\Rate $rate)
 {
     return $rate->getMethod() && 'offline' === $rate->getMethod()->getProcessor() ? $rate->getMethod()->getDeliveryTime() : '';
 }
コード例 #7
0
ファイル: Shipping.php プロジェクト: kewaunited/xcart
 /**
  * Shipping rates sorting callback
  *
  * @param \XLite\Model\Shipping\Rate $a First shipping rate
  * @param \XLite\Model\Shipping\Rate $b Second shipping rate
  *
  * @return integer
  */
 protected function compareRates(\XLite\Model\Shipping\Rate $a, \XLite\Model\Shipping\Rate $b)
 {
     $result = 0;
     $sa = $a->getMethod();
     $sb = $b->getMethod();
     if (isset($sa) && isset($sb)) {
         if ($sa->getPosition() > $sb->getPosition()) {
             $result = 1;
         } elseif ($sa->getPosition() < $sb->getPosition()) {
             $result = -1;
         }
     }
     return $result;
 }
コード例 #8
0
ファイル: Tax.php プロジェクト: kingsj/core
 /**
  * Get shipping tax rates 
  * 
  * @param \XLite\Model\Shipping\Rate $rate       Shipping rate
  * @param array                      $zones      Zones list
  * @param \XLite\Model\Membership    $membership Membership OPTIONAL
  *  
  * @return void
  */
 protected function getShippingTaxRates(\XLite\Model\Shipping\Rate $rate, array $zones, \XLite\Model\Membership $membership = null)
 {
     $method = $rate->getMethod();
     $taxes = array();
     $price = $rate->getTaxableBasis();
     foreach ($this->getTaxes() as $tax) {
         $includedZones = $tax->getVATZone() ? array($tax->getVATZone()->getZoneId()) : array();
         $included = $tax->getFilteredRate($includedZones, $tax->getVATMembership(), $method->getClasses());
         $r = $tax->getFilteredRate($zones, $membership, $method->getClasses());
         if ($included) {
             $price -= $included->calculateValueExcludingTax($price);
         }
         if ($r) {
             $taxes[$tax->getId()] = array('rate' => $r, 'base' => $price);
         }
     }
     return $taxes;
 }