コード例 #1
0
ファイル: Address.php プロジェクト: jameshalsall/Manager
 /**
  * @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;
 }
コード例 #2
0
ファイル: Observer.php プロジェクト: xiaoguizhidao/magento
 /**
  * Subscribe customer after registration
  * @param Mage_Customer_Model_Customer $customer 
  */
 protected function subscribeAfterRegistration($customer)
 {
     if (Mage::helper('advancednewsletter')->showSegmentsAtCustomerRegistration()) {
         $subscribedSegments = Mage::app()->getRequest()->getParam('segments_select');
         if (!empty($subscribedSegments)) {
             $customer->setIsSubscribed(true);
             $params = array('first_name' => $customer->getFirstname(), 'last_name' => $customer->getLastname());
             try {
                 Mage::getModel('advancednewsletter/subscriber')->setCustomer($customer)->subscribe($customer->getEmail(), $subscribedSegments);
             } catch (Exception $ex) {
             }
         }
     } else {
         if ($customer->getIsSubscribed()) {
             $segmentsToSubscribe = array();
             $params = array('first_name' => $customer->getFirstname(), 'last_name' => $customer->getLastname());
             $segmentsCollection = Mage::getModel('advancednewsletter/segment')->getCollection()->addFieldToFilter('frontend_visibility', array('eq' => array(1)))->addDefaultStoreFilter(Mage::app()->getStore()->getId());
             foreach ($segmentsCollection as $segment) {
                 $segmentsToSubscribe[] = $segment->getCode();
             }
             try {
                 Mage::getModel('advancednewsletter/subscriber')->setCustomer($customer)->subscribe($customer->getEmail(), $segmentsToSubscribe);
             } catch (Exception $ex) {
             }
         }
     }
 }
コード例 #3
0
ファイル: Customer.php プロジェクト: aplazame/magento
 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;
 }
コード例 #4
0
 /**
  * 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();
         }
     }
 }
コード例 #5
0
ファイル: Referral.php プロジェクト: xiaoguizhidao/devfashion
 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();
 }
コード例 #6
0
ファイル: Referral.php プロジェクト: ntnhan220488/ggm
 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);
     $sender = array('name' => strip_tags($parent->getFirstname() . ' ' . $parent->getLastname()), 'email' => strip_tags($parent->getEmail()));
     $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()));
     $translate->setTranslateInline(true);
     return $email->getSentSuccess();
 }
コード例 #7
0
 /**
  * Create array of customer values for API
  *
  * @param Mage_Customer_Model_Customer $customer
  * @return array
  */
 public function getCustomerData(Mage_Customer_Model_Customer $customer)
 {
     try {
         if ($primaryBillingAddress = $customer->getPrimaryBillingAddress()) {
             $address = implode(', ', $primaryBillingAddress->getStreet());
             $state = $customer->getPrimaryBillingAddress()->getRegion();
             $zipcode = $customer->getPrimaryBillingAddress()->getPostcode();
         } else {
             $address = '';
             $state = '';
             $zipcode = '';
         }
         $data = array('id' => $customer->getEmail(), 'key' => 'email', 'fields' => array('keys' => 1), 'keysconfict' => 'merge', 'vars' => array('id' => $customer->getId(), 'name' => $customer->getName(), 'suffix' => $customer->getSuffix() ? $customer->getSuffix() : '', 'prefix' => $customer->getPrefix() ? $customer->getPrefix() : '', 'firstName' => $customer->getFirstname(), 'middleName' => $customer->getMiddlename() ? $customer->getMiddlename() : '', 'lastName' => $customer->getLastname(), 'address' => $address, 'storeID' => $customer->getStoreId(), 'groupId' => $customer->getGroupId(), 'taxClassId' => $customer->getTaxClassId(), 'createdAt' => date("Y-m-d H:i:s", $customer->getCreatedAtTimestamp()), 'primaryBillingAddress' => $this->getAddress($customer->getPrimaryBillingAddress()), 'defaultBillingAddress' => $this->getAddress($customer->getDefaultBillingAddress()), 'defaultShippingAddress' => $this->getAddress($customer->getDefaultShippingAddress()), 'state' => $state, 'zipCode' => $zipcode), 'lists' => array(Mage::helper('sailthruemail')->getMasterList() => 1));
         return $data;
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
コード例 #8
0
ファイル: Customer.php プロジェクト: javik223/Evron-Magento
 public function getCustomerHtml(Mage_Customer_Model_Customer $customer)
 {
     $html = "<li onclick=\"addCustomerToCart(" . $customer->getId() . ")\" style='width:100%; float:left; cursor: pointer' class='email-customer col-lg-6 col-md-6'><span style='float:left;'>" . $customer->getFirstname() . " " . $customer->getLastname() . "</span><span style='float:right'><a href='mailto:" . $customer->getEmail() . "'>" . $customer->getEmail() . "</a></span><br/><span style='float:right'>" . $customer->getTelephone() . "</span></li>";
     return $html;
 }
コード例 #9
0
ファイル: Quote.php プロジェクト: arslbbt/mangentovies
 /**
  * Define customer object
  *
  * @param   Mage_Customer_Model_Customer $customer
  * @return  Mage_Sales_Model_Quote
  */
 public function setCustomer(Mage_Customer_Model_Customer $customer)
 {
     $this->_customer = $customer;
     $this->setCustomerId($customer->getId());
     $this->setCustomerEmail($customer->getEmail());
     $this->setCustomerFirstname($customer->getFirstname());
     $this->setCustomerLastname($customer->getLastname());
     $this->setCustomerGroupId($customer->getGroupId());
     $this->setCustomerTaxClassId($customer->getTaxClassId());
     return $this;
 }
コード例 #10
0
ファイル: Filter.php プロジェクト: bevello/bevello
 /**
  * @param Mage_Customer_Model_Customer $customer
  *
  * @return Bronto_Common_Model_Email_Template_Filter
  */
 protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
 {
     if (!in_array('customer', $this->_filteredObjects)) {
         // Handle Defaults from settings
         $customerName = trim($customer->getName()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('full', 'store', $this->getStoreId()) : $customer->getName();
         $customerPrefix = trim($customer->getPrefix()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('prefix', 'store', $this->getStoreId()) : $customer->getPrefix();
         $customerFirstName = trim($customer->getFirstname()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('firstname', 'store', $this->getStoreId()) : $customer->getFirstname();
         $customerLastName = trim($customer->getLastname()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('lastname', 'store', $this->getStoreId()) : $customer->getLastname();
         $this->setField('customerName', $customerName);
         $this->setField('firstName', $customerFirstName);
         $this->setField('prefix', $customerPrefix);
         $this->setField('lastName', $customerLastName);
         $this->setField('customerEmail', $customer->getEmail());
         $this->setField('customerPassword', $customer->getPassword());
         if ($store = $customer->getStore()) {
             $this->setField('confirmationLink', $store->getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
             if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
                 $this->setField('passwordResetLink', $store->getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
             }
         } else {
             $this->setField('confirmationLink', Mage::getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
             if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
                 $this->setField('passwordResetLink', Mage::getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
             }
         }
         $this->_filteredObjects[] = 'customer';
     }
     return $this;
 }
 /**
  * Synchronise a Magento customer with WordPress
  *
  * @param Mage_Customer_Model_Customer $customer
  * @return bool
  */
 public function synchroniseCustomer(Mage_Customer_Model_Customer $customer)
 {
     $email = $customer->getEmail();
     if ($customer->getCsData() && $customer->getCsData()->getEmail()) {
         $email = $customer->getCsData()->getEmail();
     }
     $user = Mage::getModel('wordpress/user')->loadByEmail($email);
     if (!$user->getId() && !$customer->getPassword()) {
         return false;
     }
     $user->setUserEmail($customer->getEmail())->setUserRegistered($customer->getCreatedAt())->setUserNicename($customer->getName())->setDisplayName($customer->getFirstname())->setFirstName($customer->getFirstname())->setLastName($customer->getLastname())->setNickname($customer->getFirstname());
     if (!$user->getUserLogin() || strpos($user->getUserLogin(), '@') !== false) {
         $user->setUserLogin($customer->getEmail());
     }
     try {
         if ($customer->hasPassword()) {
             if ($customer->validatePassword($customer->getPassword())) {
                 $wpHash = $this->hashPasswordForWordPress($customer->getPassword());
                 if ($this->isValidWordPressPassword($customer->getPassword(), $wpHash)) {
                     $user->setUserPass($wpHash);
                 }
             }
         }
         $user->save();
         $customer->setWordpressUser($user);
     } catch (Exception $e) {
         Mage::helper('wordpress')->log($e);
     }
 }
コード例 #12
0
 /**
  * @param Mage_Customer_Model_Customer $customer
  * @return bool|mixed
  */
 public function createDiamanteUser(Mage_Customer_Model_Customer $customer)
 {
     try {
         $this->init()->setMethod('desk/users')->setHttpMethod('POST')->addPostData(array('email' => $customer->getEmail(), 'firstName' => $customer->getFirstname(), 'lastName' => $customer->getLastname()))->doRequest(false);
     } catch (Exception $e) {
         return false;
     }
     if ($this->result->getStatus() === 201) {
         $diamanteUser = json_decode($this->result->getBody());
         $customerRelation = Mage::getModel('eltrino_diamantedesk/customerRelation');
         $customerRelation->setData(array('customer_id' => $customer->getId(), 'user_id' => $diamanteUser->id));
         $customerRelation->save();
         return $diamanteUser;
     }
     return false;
 }
コード例 #13
0
ファイル: Data.php プロジェクト: ridhoq/mxpi-twitter
 /**
  * Create OCL Name record
  *
  * @param Mage_Sales_Model_Order_Address|Mage_Customer_Model_Customer $address
  * @return array
  */
 public function createName($address)
 {
     $data = array('firstName' => (string) $address->getFirstname(), 'middleName' => $address->getMiddlename(), 'lastName' => (string) $address->getLastname(), 'prefix' => $address->getPrefix(), 'suffix' => $address->getSuffix());
     return $data;
 }