예제 #1
0
 /**
  * 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);
 }
예제 #2
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;
 }
예제 #3
0
파일: Rate.php 프로젝트: kingsj/core
 /**
  * Get total rate
  *
  * @return float
  */
 public function getTotalRate()
 {
     $total = parent::getTotalRate();
     if (!\XLite::isAdminZone() && $this->getMethod()) {
         $total = \XLite\Module\CDev\VAT\Logic\Shipping\Tax::getInstance()->calculateRateCost($this, $total);
     }
     return $total;
 }
예제 #4
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();
     }
 }
예제 #5
0
 /**
  * Get rate markup
  *
  * @param \XLite\Model\Shipping\Rate $rate Shipping rate
  *
  * @return float
  */
 protected function getTotalRate(\XLite\Model\Shipping\Rate $rate)
 {
     return $rate->getTotalRate();
 }
예제 #6
0
 /**
  * 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();
 }
예제 #7
0
 /**
  * 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)
 {
     $aRate = $a->getTotalRate();
     $bRate = $b->getTotalRate();
     return $aRate == $bRate ? 0 : ($aRate < $bRate ? -1 : 1);
 }
예제 #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;
 }