protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false) { $this->_getSession()->addSuccess($this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())); if ($this->_isVatValidationEnabled()) { // Show corresponding VAT message to customer $configAddressType = Mage::helper('customer/address')->getTaxCalculationAddressType(); $userPrompt = ''; switch ($configAddressType) { case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING: $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you shipping address for proper VAT calculation', Mage::getUrl('customer/address/edit')); break; default: $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you billing address for proper VAT calculation', Mage::getUrl('customer/address/edit')); } $this->_getSession()->addSuccess($userPrompt); } $customer->sendNewAccountEmail($isJustConfirmed ? 'confirmed' : 'registered', '', Mage::app()->getStore()->getId()); if (Mage::getModel("bmicalculator/bmi")->getMyw8status()) { $successUrl = Mage::getUrl("bmicalculator/index/myw8", array('_secure' => true)); } else { $successUrl = Mage::getUrl("customer/account/edit", array('_secure' => true)); } // $successUrl = Mage::getUrl("bmicalculator/index/myw8", array('_secure'=>true)); if ($this->_getSession()->getBeforeAuthUrl()) { $successUrl = $this->_getSession()->getBeforeAuthUrl(true); } return $successUrl; }
/** * EITHER CREATE OR UPDATE THE CUSTOMER * * TO CREATE * http://help.paytrace.com/api-create-customer-profile * * TO UPDATE * http://help.paytrace.com/api-update-customer-profile * * TO DELETE * if $card is empty then we delete the card from paytrace * * @param Mage_Customer_Model_Customer $customer */ public function paytraceCustomer(Mage_Customer_Model_Customer $customer, Widgetized_Level3_Model_Card $card = null) { $defaults = array('UN' => $this->getConfigData('login'), 'PSWD' => $this->getConfigData('trans_key'), 'TERMS' => 'Y', 'METHOD' => 'CreateCustomer', 'CUSTID' => $customer->getId(), 'BNAME' => $customer->getFirstname() . ' ' . $customer->getLastname(), 'CC' => '', 'EXPMNTH' => '', 'EXPYR' => ''); $addressId = $customer->getDefaultBilling(); $billing = Mage::getModel('sales/order_address')->load($addressId); if ($billing) { $defaults['BADDRESS'] = $billing->getPostcode(); $defaults['BCITY'] = $billing->getCity(); $defaults['BSTATE'] = $billing->getRegion(); $defaults['BZIP'] = $billing->getPostcode(); $defaults['BCOUNTRY'] = $billing->getCountryId(); } if ($card) { $defaults['CC'] = $card->getNumber(); $defaults['EXPMNTH'] = $card->getMonth(); $defaults['EXPYR'] = $card->getYear(); } try { $result = $this->call(array_keys($defaults), $defaults); } catch (Exception $ex) { $message = $this->__($ex->getMessage()); if ($card) { $card->setToken($message); $card->save(); } } }
public function sendSubscription(Mage_Customer_Model_Customer $parent, $destination, $destination_name) { $translate = Mage::getSingleton('core/translate'); /* @var $translate Mage_Core_Model_Translate */ $translate->setTranslateInline(false); //$template = Mage::getStoreConfig(self::XML_PATH_SUBSCRIPTION_EMAIL_TEMPLATE, $this->getStoreId()); $email = Mage::getModel('core/email_template'); /* @var $email Mage_Core_Model_Email_Template */ //$email->setDesignConfig(array('area'=>'frontend', 'store'=>$this->getStoreId())); $template = Mage::getStoreConfig(self::XML_PATH_SUBSCRIPTION_EMAIL_TEMPLATE, Mage::app()->getStore()->getId()); $recipient = array('email' => $destination, 'name' => $destination_name); if (Mage::helper('core')->isModuleEnabled('Aschroder_SMTPPro')) { $sender = Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_EMAIL_IDENTITY); } else { $sender = array('name' => strip_tags($parent->getFirstname() . ' ' . $parent->getLastname()), 'email' => strip_tags($parent->getEmail())); } /* $sender = array( 'name' => strip_tags($parent->getFirstname().' '.$parent->getLastname()), 'email' => strip_tags($parent->getEmail()) ); */ $real_url = Mage::getUrl('rewardpoints/index/goReferral', array("referrer" => $parent->getId())); $used_url = Mage::getUrl('', array("referral-program" => str_replace('/', '-', base64_encode($parent->getId() . 'j2t')))); $email->setDesignConfig(array('area' => 'frontend', 'store' => Mage::app()->getStore()->getId()))->sendTransactional($template, $sender, $recipient['email'], $recipient['name'], array('parent' => $parent, 'referral' => $this, 'store_name' => Mage::getModel('core/store')->load(Mage::app()->getStore()->getCode())->getName(), 'referral_url' => $used_url)); $translate->setTranslateInline(true); return $email->getSentSuccess(); }
/** * Referral Signup trigger * * @param Mage_Customer_Model_Customer $customer * @return TBT_RewardsReferral_Model_Referral_Abstract */ public function triggerEvent(Mage_Customer_Model_Customer $customer) { $this->loadByEmail($customer->getEmail()); if (!$this->getReferralParentId()) { Mage::helper('rewardsref')->initateSessionReferral($customer); $this->loadByEmail($customer->getEmail()); if (!$this->getReferralParentId()) { return $this; } } // update referral status $this->setReferralChildId($customer->getId()); $this->setReferralStatus($this->getReferralStatusId()); $this->save(); $points = $this->getTotalReferralPoints(); if ($points->isEmpty()) { return $this; } try { foreach ($points->getPoints() as $currencyId => $points_amount) { $transfer = Mage::getModel('rewardsref/transfer'); $transferStatus = Mage::getStoreConfig('rewards/InitialTransferStatus/ReferralSignup'); $transfer->create($points_amount, $currencyId, $this->getReferralParentId(), $customer->getId(), $this->getReferralTransferMessage($customer), $this->getTransferReasonId(), $transferStatus); } // send affiliate an email of the transaction $affiliate = $this->getParentCustomer(); if ($affiliate->getRewardsrefNotifyOnReferral()) { $msg = $this->getReferralTransferMessage($customer); $this->sendConfirmation($affiliate, $customer->getEmail(), $customer->getName(), $msg, (string) $points); } } catch (Exception $e) { Mage::logException($e); } return $this; }
/** * Set customer data. * * @param Mage_Customer_Model_Customer $customer */ public function setCustomerData(Mage_Customer_Model_Customer $customer) { $this->customer = $customer; $this->setReviewCollection(); $website = $customer->getStore()->getWebsite(); if ($website && Mage::helper('ddg')->isSweetToothToGo($website)) { $this->setRewardCustomer($customer); } foreach ($this->getMappingHash() as $key => $field) { /** * call user function based on the attribute mapped. */ $function = 'get'; $exploded = explode('_', $key); foreach ($exploded as $one) { $function .= ucfirst($one); } try { $value = call_user_func(array('self', $function)); $this->customerData[$key] = $value; } catch (Exception $e) { Mage::logException($e); } } }
protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false) { $this->_getSession()->addSuccess($this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())); if ($this->_isVatValidationEnabled()) { $configAddressType = Mage::helper('customer/address')->getTaxCalculationAddressType(); $userPrompt = ''; switch ($configAddressType) { case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING: $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you shipping address for proper VAT calculation', Mage::getUrl('customer/address/edit')); break; default: $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you billing address for proper VAT calculation', Mage::getUrl('customer/address/edit')); } $this->_getSession()->addSuccess($userPrompt); } $customer->sendNewAccountEmail($isJustConfirmed ? 'confirmed' : 'registered', '', Mage::app()->getStore()->getId()); $cusromerRedirectStatus = Mage::getStoreConfig('customer/customercreateredirect/active'); $customerCreateRedirectUrl = Mage::getStoreConfig('customer/customercreateredirect/redirecturl'); if ($cusromerRedirectStatus == 1) { $successUrl = Mage::getUrl() . $customerCreateRedirectUrl; } else { $successUrl = Mage::getUrl('*/*/index', array('_secure' => true)); } if ($this->_getSession()->getBeforeAuthUrl()) { if ($cusromerRedirectStatus == 1) { $successUrl = Mage::getUrl() . $customerCreateRedirectUrl; } else { $successUrl = $this->_getSession()->getBeforeAuthUrl(true); } } return $successUrl; }
public static function createFromCustomer(Mage_Customer_Model_Customer $customer) { /** @var Mage_Log_Model_Customer $logCustomer */ $logCustomer = Mage::getModel('log/customer')->loadByCustomer($customer->getId()); switch ($customer->getGender()) { case '1': $gender = 1; break; case '2': $gender = 2; break; default: $gender = 0; } $aCustomer = new self(); $aCustomer->email = $customer->getEmail(); $aCustomer->type = 'e'; $aCustomer->gender = $gender; $aCustomer->id = $customer->getId(); $aCustomer->first_name = $customer->getFirstname(); $aCustomer->last_name = $customer->getLastname(); if (($birthday = $customer->getDob()) !== null) { $aCustomer->birthday = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime($birthday)); } if (($document_id = $customer->getTaxvat()) !== null) { $aCustomer->document_id = $document_id; } $aCustomer->date_joined = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime('@' . $customer->getCreatedAtTimestamp())); if (($lastLogin = $logCustomer->getLoginAtTimestamp()) != null) { $aCustomer->last_login = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime('@' . $lastLogin)); } return $aCustomer; }
public function load($printQuery = false, $logQuery = false) { $this->_select = $this->_read->select(); $entityTable = $this->getEntity()->getEntityTable(); $paidTable = $this->getAttribute('grand_total')->getBackend()->getTable(); $idField = $this->getEntity()->getIdFieldName(); $this->getSelect()->from(array('sales' => $entityTable), array('store_id', 'lifetime' => 'sum(sales.base_grand_total)', 'avgsale' => 'avg(sales.base_grand_total)', 'num_orders' => 'count(sales.base_grand_total)'))->where('sales.entity_type_id=?', $this->getEntity()->getTypeId())->group('sales.store_id'); if ($this->_customer instanceof Mage_Customer_Model_Customer) { $this->getSelect()->where('sales.customer_id=?', $this->_customer->getId()); } $this->printLogQuery($printQuery, $logQuery); try { $values = $this->_read->fetchAll($this->getSelect()->__toString()); } catch (Exception $e) { $this->printLogQuery(true, true, $this->getSelect()->__toString()); throw $e; } $stores = Mage::getResourceModel('core/store_collection')->setWithoutDefaultFilter()->load()->toOptionHash(); if (!empty($values)) { foreach ($values as $v) { $obj = new Varien_Object($v); $storeName = isset($stores[$obj->getStoreId()]) ? $stores[$obj->getStoreId()] : null; $this->_items[$v['store_id']] = $obj; $this->_items[$v['store_id']]->setStoreName($storeName); $this->_items[$v['store_id']]->setAvgNormalized($obj->getAvgsale() * $obj->getNumOrders()); foreach ($this->_totals as $key => $value) { $this->_totals[$key] += $obj->getData($key); } } if ($this->_totals['num_orders']) { $this->_totals['avgsale'] = $this->_totals['lifetime'] / $this->_totals['num_orders']; } } return $this; }
/** * @param Mage_Customer_Model_Customer $customer * @return bool * @throws Exception */ public function isCustomerFacebookUser(Mage_Customer_Model_Customer $customer) { $customerEmail = $customer->getData('email'); $facebookUser = $this->getFacebookUser()->setData('store_id', $customer->getStoreId()); $facebookUser->loadByEmail($customerEmail); return (bool) $facebookUser->getId() && $customer->getStoreId() == $facebookUser->getData('store_id'); }
public function assignCustomerWithAddressChange(Mage_Customer_Model_Customer $customer, Mage_Sales_Model_Quote_Address $billingAddress = null, Mage_Sales_Model_Quote_Address $shippingAddress = null) { if ($customer->getId()) { $this->setCustomer($customer); if (!is_null($billingAddress)) { $this->setBillingAddress($billingAddress); } else { $defaultBillingAddress = $customer->getDefaultBillingAddress(); if ($defaultBillingAddress && $defaultBillingAddress->getId()) { $billingAddress = Mage::getModel('request4quote/quote_address')->importCustomerAddress($defaultBillingAddress); $this->setBillingAddress($billingAddress); } } if (is_null($shippingAddress)) { $defaultShippingAddress = $customer->getDefaultShippingAddress(); if ($defaultShippingAddress && $defaultShippingAddress->getId()) { $shippingAddress = Mage::getModel('request4quote/quote_address')->importCustomerAddress($defaultShippingAddress); } else { $shippingAddress = Mage::getModel('request4quote/quote_address'); } } $this->setShippingAddress($shippingAddress); } return $this; }
/** * @param \Mage_Customer_Model_Customer $customer * @return $this */ public function withCustomer($customer) { $this->attributes['customer_id'] = $customer->getId(); $this->attributes['firstname'] = $customer->getFirstname(); $this->attributes['lastname'] = $customer->getLastname(); return $this; }
/** * Setter for $_customer * * @param Mage_Customer_Model_Customer $customer * @return Enterprise_Checkout_Model_Cart */ public function setCustomer($customer) { if ($customer instanceof Varien_Object && $customer->getId()) { $this->_customer = $customer; $this->_quote = null; } return $this; }
protected function setUp() { $customer = new Mage_Customer_Model_Customer(); $customer->load(1); Mage::register('current_customer', $customer); $layout = new Mage_Core_Model_Layout(array('area' => 'adminhtml')); $this->_block = $layout->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion'); }
/** * Check if quote meets the minimun quantity * of total items for a specific customer * * @todo Change to more meaningful name * * @param Mage_Sales_Model_Quote $quote * @param Mage_Customer_Model_Customer $customer * @return int|false */ public function minimunOrderQty(Mage_Sales_Model_Quote $quote, Mage_Customer_Model_Customer $customer) { $minQtyForCustomer = $this->getConfigValue($customer->getGroupId()); if ($quote->getItemsQty() < $minQtyForCustomer && $quote->getItemsQty() !== 0) { return $minQtyForCustomer; } return false; }
/** * Prepare data before attribute save * * @param Mage_Customer_Model_Customer $customer * @return Mage_Customer_Model_Attribute_Backend_Data_Boolean */ public function beforeSave($customer) { $attributeName = $this->getAttribute()->getName(); $inputValue = $customer->getData($attributeName); $sanitizedValue = !empty($inputValue) ? '1' : '0'; $customer->setData($attributeName, $sanitizedValue); return $this; }
public function loginByCustomer(Mage_Customer_Model_Customer $customer) { if ($customer->getConfirmation()) { $customer->setConfirmation(null); $customer->save(); } Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); }
/** * @param Mage_Customer_Model_Customer $customer * * @return bool|string * @throws \Mage_Core_Exception */ protected function getCustomerTipoPessoa($customer) { $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'tipopessoa'); $tipopessoa = $customer->getTipopessoa(); if ($attribute && $attribute->usesSource() && $tipopessoa) { return $attribute->getSource()->getOptionText($tipopessoa); } return false; }
/** * Set customer filter * * @param Mage_Customer_Model_Customer $customer * @return Mage_Customer_Model_Resource_Address_Collection */ public function setCustomerFilter($customer) { if ($customer->getId()) { $this->addAttributeToFilter('parent_id', $customer->getId()); } else { $this->addAttributeToFilter('parent_id', '-1'); } return $this; }
public function getAllPasswordHashesForCustomer(Mage_Customer_Model_Customer $customer) { $passwordHashes = []; $records = $this->getCollection()->addFilter('customer_id', $customer->getId()); foreach ($records as $record) { array_push($passwordHashes, $record->getPasswordHash()); } return $passwordHashes; }
/** * Check customer's group * * @param Mage_Customer_Model_Customer $customer * * @return bool */ public function validateCustomerGroup($customer) { if (!$this->getId() || !$customer->getId()) { return FALSE; } $customerGroupId = $customer->getData('group_id'); $couponGroupIds = $this->getData('customer_group_ids'); $result = in_array($customerGroupId, $couponGroupIds); return $result; }
/** * * @param Mage_Customer_Model_Customer $customer * @param string $pointsString * @param type $date */ public function systemLog($customer, $pointsString, $date) { $storeId = $customer->getStoreId(); if ($this->_getHelper()->isLogBirthdayEnabled($storeId)) { $name = $customer->getName(); $email = $customer->getEmail(); $msg = $this->_getHelper()->__("Customer %s with the e-mail %s has a birthday on %s and been rewarded %s.", $name, $email, $date, $pointsString); Mage::log($msg, null, $this->getLogFileName()); } }
/** * @param $customer * @return string */ private function getReporter(Mage_Customer_Model_Customer $customer) { if ($this->_reporter) { return $this->_reporter; } $model = Mage::getModel('eltrino_diamantedesk/customerRelation')->load($customer->getId(), 'customer_id'); if ($model->getId()) { return Eltrino_DiamanteDesk_Model_Api::TYPE_DIAMANTE_USER . $model->getUserId(); } return ''; }
/** * Fetch dealer IDs for a given customer and attach to the customer object * * @param Mage_Customer_Model_Customer $customer * @return Gorilla_ChasePaymentech_Model_Mysql4_Profile */ public function loadInfoByCustomer($customer) { $read = $this->_getReadAdapter(); if ($read) { $select = $read->select()->from($this->getMainTable(), array('id', 'customer_ref_num', 'is_default'))->where('customer_id = ?', $customer->getId()); if ($data = $read->fetchRow($select)) { $customer->setChasePaymentechCustomerRefNum($data['customer_ref_num'])->setChasePaymentechProfileId($data['id']); } } return $this; }
/** * Get Customer Info * * @param Mage_Customer_Model_Customer $customer got customer * @return void */ public function registerCustomerInfo($customer) { /** * @var $customer Mage_Customer_Model_Customer */ if ($customer) { $telephone = $customer->getData('oc_telephone'); $name = $customer->getName(); Mage::register('customer_name', $name); Mage::register('customer_phone', $telephone); } }
/** * @param Mage_Customer_Model_Customer|integer $customer * * @return AW_Followupemail_Model_Mysql4_Unsubscribe_Collection */ public function addCustomerFilter($customer) { if ($customer instanceof Mage_Customer_Model_Customer) { $customerId = $customer->getId(); } elseif (is_numeric($customer)) { $customerId = $customer; } else { return $this; } $this->addFieldToFilter('customer_id', $customerId); return $this; }
/** * Retrieve Customer instance * * @return Mage_Customer_Model_Customer */ protected function _getCustomer() { if (is_null($this->_customer)) { $this->_customer = Mage::getModel('customer/customer'); $params = Mage::helper('core')->urlDecode($this->getRequest()->getParam('data')); $data = explode(',', $params); $cId = abs(intval($data[0])); if ($cId && $cId == Mage::getSingleton('customer/session')->getCustomerId()) { $this->_customer->load($cId); } } return $this->_customer; }
/** * @param Mage_Customer_Model_Customer $customer * @param $subscriberId * @return $this */ public function addSubscriberToSegment(Mage_Customer_Model_Customer $customer, $subscriberId) { $segments = Mage::helper('newsman_newsletter')->getSegments(); if (!$segments) { return $this; } foreach ($segments as $segment) { if ($segment['customer_group_id'] == $customer->getGroupId()) { Mage::getModel('newsman_newsletter/api_segment')->addSubscriber($segment['segment'], $subscriberId); } } return $this; }
public function syncCustomer(Mage_Customer_Model_Customer $customer) { if (!($email = $customer->getEmail())) { return false; } $this->load($email); if (!$this->getId()) { $this->setEmail($email); } $this->setName($customer->getName()); $this->save(); $this->cleanCache(); return true; }
private function _getAttributeValue(Mage_Customer_Model_Customer $customer, $attributeCode) { $attribute = $customer->getResource()->getAttribute($attributeCode); if (!$attribute) { return; } if (is_array($attribute)) { return join(",", $attribute->getFrontEnd()->getValue($customer)); } else { if (!is_array($attribute)) { return $attribute->getFrontEnd()->getValue($customer); } } }
public function getUrl(Mage_Customer_Model_Customer $customer) { switch (Mage::helper('rewardsref')->getReferralUrlStyle()) { case TBT_RewardsReferral_Helper_Data::REWARDSREF_URL_STYLE_EMAIL: $url_data = array('email' => urlencode($customer->getEmail())); break; case TBT_RewardsReferral_Helper_Data::REWARDSREF_URL_STYLE_CODE: $url_data = array('code' => urlencode(Mage::helper('rewardsref/code')->getCode($customer->getEmail()))); break; default: $url_data = array('id' => $customer->getId()); } $url = Mage::getUrl('rewardsref/index/refer', $url_data); return $url; }