/** * Creates a new transfer with a pending status using the rule information * * @param TBT_Rewards_Model_Special $rule */ private function createPendingTransfer($rule) { try { $is_transfer_successful = Mage::helper('rewards/transfer')->transferReviewPoints($rule->getPointsAmount(), $rule->getPointsCurrencyId(), $this->getId(), $rule->getId()); } catch (Exception $ex) { Mage::getSingleton('core/session')->addError($ex->getMessage()); } return $is_transfer_successful; }
/** * Runs through each rule validator * * Note: the parent does not have the extra $customer argument * parent uses SessionCustomer in place of this param * * @param TBT_Rewards_Model_Special $rule * @param unknown_type $actionType * @param Mage_Model_Customer $customer * @return boolean true if rule valid */ protected function isRuleValidCheck($rule, $actionType, $customer = null) { //check to see if its active if (!$rule->getIsActive()) { return false; } //check its after the start date $localDate = Mage::getModel('core/date')->gmtDate(); if (strtotime($rule->getFromDate()) >= strtotime($localDate)) { return false; } //check ending date if not empty if ($rule->getToDate() != "") { //if it isn't make sure its before the ending date if (strtotime($rule->getToDate()) + 86399 <= strtotime($localDate)) { return false; } } //check customer has a birthday today and the rule is within the allowed group if ($customer != null) { if (!$this->isCustomerBirthdayRewardValidToday($customer)) { return false; } $customer_group_ids = explode(",", $rule->getCustomerGroupIds()); if (!$this->isInGroup($customer, $customer_group_ids)) { return false; } } //Unhashes the coditions and check rule triggers on customer performing the correct action $rule_conditions = $this->_getRH()->unhashIt($rule->getConditionsSerialized()); if (is_array($rule_conditions)) { if (!in_array($actionType, $rule_conditions)) { return false; } } else { if ($rule_conditions != $actionType) { return false; } } return true; }
/** * Runs through each rule validator * * @param TBT_Rewards_Model_Special $rule * @param unknown_type $actionType * @return boolean true if rule valid */ protected function isRuleValidCheck($rule, $actionType) { //check to see if its active if (!$rule->getIsActive()) { return false; } //check if current website_id is valid if (!$rule->isApplicableToWebsite(Mage::app()->getStore()->getWebsiteId())) { return false; } //check its after the start date $localDate = Mage::getModel('core/date')->gmtDate(); if (strtotime($rule->getFromDate()) >= strtotime($localDate)) { return false; } //check ending date if not empty if ($rule->getToDate() != "") { //if it isn't make sure its before the ending date if (strtotime($rule->getToDate()) + 86399 <= strtotime($localDate)) { return false; } } //check customer is within the allowed group for the rule $customer = $this->_getRS()->getSessionCustomer(); $customer_group_ids = explode(",", $rule->getCustomerGroupIds()); if (!$this->isInGroup($customer, $customer_group_ids)) { return false; } //Unhashes the coditions and check rule triggers on customer performing the correct action $rule_conditions = $this->_getRH()->unhashIt($rule->getConditionsSerialized()); if (is_array($rule_conditions)) { if (!in_array($actionType, $rule_conditions)) { return false; } } else { if ($rule_conditions != $actionType) { return false; } } return true; }