Exemple #1
0
 /**
  * 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.'));
             }
         }
     }
 }
Exemple #2
0
 /**
  * Perform Row-level data update
  *
  * @param Enterprise_Reward_Model_Reward $object
  * @param array $data New data
  * @return Enterprise_Reward_Model_Resource_Reward
  */
 public function updateRewardRow(Enterprise_Reward_Model_Reward $object, $data)
 {
     if (!$object->getId() || !is_array($data)) {
         return $this;
     }
     $where = array($this->getIdFieldName() . '=?' => $object->getId());
     $this->_getWriteAdapter()->update($this->getMainTable(), $data, $where);
     return $this;
 }
Exemple #3
0
 /**
  * Render if all there is a customer and a balance
  *
  * @return string
  */
 protected function _toHtml()
 {
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     if ($customer && $customer->getId()) {
         $this->_rewardInstance = Mage::getModel('enterprise_reward/reward')->setCustomer($customer)->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByCustomer();
         if ($this->_rewardInstance->getId()) {
             $this->_prepareTemplateData();
             return parent::_toHtml();
         }
     }
     return '';
 }