예제 #1
0
파일: Api.php 프로젝트: monarcmoso/beta2
 /**
  * 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;
 }
 public function getActionInstance()
 {
     return AW_Points_Model_Actions_Abstract::getInstance($this->getAction(), $this->getCustomer())->setTransaction($this);
 }