示例#1
0
文件: Rate.php 项目: kingsj/core
 /**
  * Check if rate is applied by specified zones and membership
  *
  * @param array                                   $zones          Zone id list
  * @param \XLite\Model\Membership                 $membership     Membership OPTIONAL
  * @param \Doctrine\Common\Collections\Collection $productClasses Product classes OPTIONAL
  *
  * @return boolean
  */
 public function isApplied(array $zones, \XLite\Model\Membership $membership = null, \Doctrine\Common\Collections\Collection $productClasses = null)
 {
     $result = !$this->getZone() || in_array($this->getZone()->getZoneId(), $zones);
     if ($result && $this->getMembership()) {
         $result = $membership && $this->getMembership()->getMembershipId() == $membership->getMembershipId();
     }
     if ($result && 2 < func_num_args()) {
         $result = !$this->getProductClass() || $productClasses && $productClasses->contains($this->getProductClass());
     }
     return $result;
 }
示例#2
0
 /**
  * Check if rate is applied by specified zones and membership
  *
  * @param array                   $zones      Zone id list
  * @param \XLite\Model\Membership $membership Membership OPTIONAL
  * @param \XLite\Model\TaxClass   $taxClass   Tax class OPTIONAL
  *
  * @return boolean
  */
 public function isApplied(array $zones, \XLite\Model\Membership $membership = null, \XLite\Model\TaxClass $taxClass = null)
 {
     $result = $this->getZone() && in_array($this->getZone()->getZoneId(), $zones);
     if ($result && !\XLite\Core\Config::getInstance()->CDev->SalesTax->ignore_memberships && $this->getMembership()) {
         $result = $membership && $this->getMembership()->getMembershipId() == $membership->getMembershipId();
     }
     return $result;
 }
示例#3
0
 /**
  * Get next discount suitable for specified subtotal 
  * 
  * @param float                   $subtotal   Subtotal
  * @param \XLite\Model\Membership $membership Membership object
  *  
  * @return \XLite\Module\CDev\VolumeDiscounts\Model\VolumeDiscount
  */
 public function getNextDiscount($subtotal, $membership)
 {
     $cnd = new \XLite\Core\CommonCell();
     $cnd->{self::P_SUBTOTAL_ADV} = $subtotal;
     $cnd->{self::P_MIN_VALUE} = 0;
     $cnd->{self::P_MEMBERSHIP} = $membership ? $membership->getMembershipId() : null;
     $cnd->{self::P_ORDER_BY_SUBTOTAL} = array('v.subtotalRangeBegin', 'ASC');
     $cnd->{self::P_ORDER_BY_MEMBERSHIP} = array('membership.membership_id', 'DESC');
     $discounts = $this->search($cnd);
     if ($discounts) {
         $discounts = array_shift($discounts);
     } else {
         $discounts = null;
     }
     return $discounts;
 }
示例#4
0
 /**
  * Check membership item id equal
  *
  * @param \XLite\Model\Membership $item
  * @param type $membershipId
  *
  * @return boolean
  */
 public function checkMembershipId(\XLite\Model\Membership $item, $membershipId)
 {
     return $item->getMembershipId() === $membershipId;
 }
示例#5
0
 /**
  * Format membership model
  *
  * @param \XLite\Model\Membership $membership Membership
  *
  * @return string
  */
 protected function formatMembershipModel(\XLite\Model\Membership $membership = null)
 {
     return $membership ? $membership->getName() : '';
 }
示例#6
0
 /**
  * Check - specified memerbship is selected or not
  * 
  * @param \XLite\Model\Membership $current Membership
  *
  * @return boolean
  */
 protected function isSelectedMembership(\XLite\Model\Membership $current)
 {
     return $this->getParam(self::PARAM_VALUE) && $current->getMembershipId() == $this->getParam(self::PARAM_VALUE)->getMembershipId();
 }
 /**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }
示例#8
0
文件: Rate.php 项目: kingsj/core
 /**
  * Check if rate is applied for specified zones and membership
  *
  * @param array                   $zones      Zone id list
  * @param \XLite\Model\Membership $membership Membership OPTIONAL
  *
  * @return boolean
  */
 public function isApplied(array $zones, \XLite\Model\Membership $membership = null)
 {
     return (!$this->getZone() || in_array($this->getZone()->getZoneId(), $zones)) && (!$this->getMembership() || $membership && $this->getMembership()->getMembershipId() == $membership->getMembershipId());
 }
示例#9
0
 /**
  * Get first discount suitable for specified subtotal
  * @deprecated
  *
  * @param float                   $subtotal   Subtotal
  * @param \XLite\Model\Membership $membership Membership object
  *
  * @return \XLite\Module\CDev\VolumeDiscounts\Model\VolumeDiscount
  */
 public function getFirstDiscountBySubtotal($subtotal, $membership)
 {
     $cnd = new \XLite\Core\CommonCell();
     $cnd->{self::P_SUBTOTAL} = $subtotal;
     $cnd->{self::P_MEMBERSHIP} = $membership ? $membership->getMembershipId() : null;
     if ($membership) {
         $cnd->{self::P_ORDER_BY_MEMBERSHIP} = array('membership.membership_id', 'DESC');
     }
     $cnd->{self::P_ORDER_BY_SUBTOTAL} = array('v.subtotalRangeBegin', 'ASC');
     $discounts = $this->search($cnd);
     return $discounts ? array_shift($discounts) : null;
 }