public function addTransaction($additionalData = array())
 {
     // Expire negative transactions can be created only for transactions not marked as expired yet
     $this->getObjectForAction()->setBalanceChangeSpent($this->getObjectForAction()->getBalanceChange())->save();
     parent::addTransaction($additionalData);
     return $this;
 }
Beispiel #2
0
 protected function _applyLimitations($amount)
 {
     if ($newAmount = $this->_limitAmountByWordsCount($amount)) {
         $newAmount = $this->_limitAmountByDay($newAmount);
     }
     return parent::_applyLimitations($newAmount);
 }
Beispiel #3
0
 /**
  * Creates new transaction with information about points changes of customer.
  * To add additional params use $additionalData array
  * Example of usage:
  * Mage::getModel('points/api')->addTransaction(
  * -15, 'points_spend_on_order', $customer, $order, array('order_increment_id' => 111000010),
  * array('notice' => Mage::helper('points')->__('My test notice')))
  *
  * How it works:
  * it will subtract 15 points from customer $customer, action will be set as 'points_spend_on_order',
  * comment for this action is
  * 'Spent on order #%s', to change %s to order increment id
  * you must set array('order_increment_id' => 111000010) as $commentParams,
  * to set notice to the aw_points_transaction table you must directly set 'notice' to
  * $additionalData - array('notice' => Mage::helper('points')->__('My test notice'))
  *
  * @param int $amount
  * @param string $action
  * @param Mage_Customer_Model_Customer $customer
  * @param Varien_Object $objectForAction
  * @param array $commentParams
  * @param array $additionalData
  * @return int $transactionId
  */
 public function addTransaction($amount, $action, $customer, $objectForAction = null, $commentParams = array(), $additionalData = array())
 {
     try {
         $a = AW_Points_Model_Actions_Abstract::getInstance($action, $customer)->setAmount($amount)->setObjectForAction($objectForAction)->setCommentParams($commentParams)->addTransaction($additionalData);
         $transactionId = $a->getTransaction()->getId();
     } catch (Exception $ex) {
         return 0;
     }
     return $transactionId;
 }
 protected function _applyLimitations($amount)
 {
     $pointLimitForAction = Mage::helper('points/config')->getPointsLimitForParticipatingInPoll();
     $collection = Mage::getModel('points/transaction')->getCollection()->addFieldToFilter('summary_id', $this->getSummary()->getId())->addFieldToFilter('action', $this->getAction())->limitByDay(Mage::getModel('core/date')->gmtTimestamp());
     /* Current summ getting */
     $summ = 0;
     foreach ($collection as $transaction) {
         $summ += $transaction->getBalanceChange();
     }
     return parent::_applyLimitations($this->_calculateNewAmount($summ, $amount, $pointLimitForAction));
 }
Beispiel #5
0
 public static function getInstance($action, $customer)
 {
     if (!self::$_actions) {
         self::$_actions = Mage::getConfig()->getNode('points_actions');
     }
     if ($action == 'an_customer_subscription' && !self::$_actions->{$action}) {
         $action = 'customer_subscription';
     }
     if (!self::$_actions->{$action}) {
         throw new AW_Core_Exception('Cannot find instance for action');
     }
     $instance = Mage::getModel(self::$_actions->{$action});
     if (!$instance instanceof AW_Points_Model_Actions_Abstract) {
         throw new Exception('Cannot find instance for action');
     }
     return $instance->setSummary(Mage::getModel('points/summary')->loadByCustomer($customer));
 }
 public function addTransaction($additionalData = array())
 {
     $action = parent::addTransaction($additionalData);
     $this->getTransaction()->saveSpendOrderInfo($this->getObjectForAction());
     return $action;
 }
 public function getActionInstance()
 {
     return AW_Points_Model_Actions_Abstract::getInstance($this->getAction(), $this->getCustomer())->setTransaction($this);
 }