Example #1
0
 /**
  * @param null|Varien_Object $dataObject
  * @return Xcom_Xfabric_Model_Message_Request
  */
 public function _prepareData(Varien_Object $dataObject = null)
 {
     $avroDataObject = Mage::getModel('xcom_chronicle/message_customer', $dataObject->getCustomer());
     $data = array('data' => $avroDataObject->toArray());
     $this->setMessageData($data);
     return parent::_prepareData($dataObject);
 }
Example #2
0
 /**
  * Set a cookie with the customer group id when customer logs in
  *
  * Events: customer_login
  *
  * @param Varien_Object $eventObject
  * @return null
  */
 public function setCustomerGroupCookie($eventObject)
 {
     $customer = $eventObject->getCustomer();
     $cookie = Mage::getSingleton('core/cookie');
     if (Mage::getStoreConfig('persistent/options/enabled')) {
         $cookie->set('customer_group', $customer->getGroupId(), Mage::getStoreConfig('persistent/options/lifetime'));
     } else {
         $cookie->set('customer_group', $customer->getGroupId());
     }
 }
Example #3
0
 /**
  * Calculate points amount depending on tax settings: before or after tax
  *
  * @param Varien_Object $transport
  * @param bool $convertToPoints
  *
  * @return int
  */
 protected function _calcPointAmount($transport, $convertToPoints = false)
 {
     /* extract params */
     $customer = $transport->getCustomer();
     $invoice = $transport->getInvoice();
     $orderWebsite = $transport->getOrder()->getStore()->getWebsite();
     if ($invoice->getBaseDiscountAmount() < 0) {
         $invoiceDiscount = $invoice->getBaseDiscountAmount();
     } else {
         $invoiceDiscount = -$invoice->getBaseDiscountAmount();
     }
     if ($invoice->getBaseMoneyForPoints() < 0) {
         $invoiceBaseMoneyForPoints = $invoice->getBaseMoneyForPoints();
     } else {
         $invoiceBaseMoneyForPoints = -$invoice->getBaseMoneyForPoints();
     }
     $pointsType = Mage::helper('points/config')->getPointsCollectionOrder($transport->getOrder()->getStoreId());
     if ($pointsType == AW_Points_Helper_Config::AFTER_TAX) {
         $amountToPoint = $invoice->getBaseSubtotalInclTax() + $invoiceDiscount + $invoiceBaseMoneyForPoints;
     } else {
         $amountToPoint = $invoice->getBaseSubtotal() + $invoiceDiscount + $invoiceBaseMoneyForPoints;
     }
     if ($convertToPoints) {
         return Mage::getModel('points/api')->changeMoneyToPoints($amountToPoint, $customer, $orderWebsite);
     }
     return $amountToPoint;
 }