コード例 #1
0
ファイル: Tooltip.php プロジェクト: jpbender/mage_virtual
 /**
  * Set various template variables
  */
 protected function _prepareTemplateData()
 {
     if ($this->_actionInstance) {
         $this->addData(array('reward_points' => $this->_rewardInstance->estimateRewardPoints($this->_actionInstance), 'landing_page_url' => Mage::helper('enterprise_reward')->getLandingPageUrl()));
         if ($this->_rewardInstance->getId()) {
             // estimate qty limitations (actually can be used without customer reward record)
             $qtyLimit = $this->_actionInstance->estimateRewardsQtyLimit();
             if (null !== $qtyLimit) {
                 $this->setData('qty_limit', $qtyLimit);
             }
             if ($this->hasGuestNote()) {
                 $this->unsGuestNote();
             }
             $this->addData(array('points_balance' => $this->_rewardInstance->getPointsBalance(), 'currency_balance' => $this->_rewardInstance->getCurrencyAmount()));
             // estimate monetary reward
             $amount = $this->_rewardInstance->estimateRewardAmount($this->_actionInstance);
             if (null !== $amount) {
                 $this->setData('reward_amount', $amount);
             }
         } else {
             if ($this->hasIsGuestNote() && !$this->hasGuestNote()) {
                 $this->setGuestNote(Mage::helper('enterprise_reward')->__('Applies only to registered customers, may vary when logged in.'));
             }
         }
     }
 }
コード例 #2
0
 /**
  * Setter for $_entity and add some extra data to history
  *
  * @param Varien_Object $entity
  * @return Enterprise_Reward_Model_Action_Abstract
  */
 public function setEntity($entity)
 {
     parent::setEntity($entity);
     $this->getHistory()->addAdditionalData(array('increment_id' => $this->getEntity()->getIncrementId()));
     return $this;
 }
コード例 #3
0
 /**
  * Setter for $_entity and add some extra data to history
  *
  * @param Varien_Object $entity
  * @return Enterprise_Reward_Model_Action_Abstract
  */
 public function setEntity($entity)
 {
     parent::setEntity($entity);
     $this->getHistory()->addAdditionalData(array('email' => $this->getEntity()->getEmail()));
     return $this;
 }
コード例 #4
0
ファイル: OrderExtra.php プロジェクト: jpbender/mage_virtual
 /**
  * Check whether rewards can be added for action
  * Checking for the history records is intentionaly omitted
  *
  * @return bool
  *
  */
 public function canAddRewardPoints()
 {
     return parent::canAddRewardPoints() && Mage::helper('enterprise_reward')->isOrderAllowed($this->getReward()->getWebsiteId());
 }
コード例 #5
0
 /**
  * Estimate available points reward for specified action
  *
  * @param Enterprise_Reward_Model_Action_Abstract $action
  * @return int|null
  */
 public function estimateRewardPoints(Enterprise_Reward_Model_Action_Abstract $action)
 {
     $websiteId = $this->getWebsiteId();
     $uncappedPts = (int) $action->getPoints($websiteId);
     $max = (int) Mage::helper('enterprise_reward')->getGeneralConfig('max_points_balance', $websiteId);
     if ($max > 0) {
         return min(max($max - (int) $this->getPointsBalance(), 0), $uncappedPts);
     }
     return $uncappedPts;
 }