public function getCustomerByPost($params)
 {
     $customer = $this->_getCustomer();
     // Patch for custom Contact Us form with ability to change email or name of customer (HDMX-98)
     if ($customer->getId() > 0 && !isset($params['customer_email']) && !isset($params['customer_name'])) {
         return $customer;
     }
     $email = $params['customer_email'];
     $name = $params['customer_name'];
     $customers = Mage::getModel('customer/customer')->getCollection();
     $customers->addAttributeToSelect('*')->addAttributeToFilter('email', $email);
     if ($customers->count() > 0) {
         return $customers->getFirstItem();
     }
     $c = Mage::getModel('customer/customer');
     $c->getEmail();
     $c->setEmail('aaa');
     /** @var Mage_Customer_Model_Customer $address */
     $address = $customers->getFirstItem();
     if ($address->getId()) {
         $customer = new Varien_Object();
         $customer->setName($address->getName());
         $customer->setEmail($address->getEmail());
         $customer->setQuoteAddressId($address->getId());
         return $customer;
     }
     $customer = new Varien_Object();
     $customer->setName($name);
     $customer->setEmail($email);
     return $customer;
 }
Пример #2
0
 public function render(Varien_Object $row)
 {
     if (!$row->getEntityId()) {
         $row->setEmail($row->getGuestEmail());
     }
     echo $row->getEmail();
 }
Пример #3
0
 /**
  * @test
  * @loadFixture data
  *
  * @doNotIndex catalog_product_price
  */
 public function last_reply_byTest()
 {
     $ticket = Mage::getModel('helpdesk/ticket')->load(2);
     $rule = Mage::getModel('helpdesk/rule')->load(2);
     $rule->setConditionsSerialized($this->getConditions('last_reply_by', '==', 'customer'));
     $rule->afterLoad();
     $this->assertFalse($rule->validate($ticket));
     $customer = new Varien_Object();
     $customer->setName('John Doe');
     $customer->setEmail('*****@*****.**');
     $ticket->addMessage('message 1', $customer, false, true);
     $this->assertTrue($rule->validate($ticket));
 }
Пример #4
0
 /**
  * @test
  * @loadFixture data
  *
  * @doNotIndex catalog_product_price
  */
 public function addMessageUnknownCustomerTest()
 {
     $customer = new Varien_Object();
     $customer->setName('John Doe');
     $customer->setEmail('*****@*****.**');
     $this->_model->addMessage('message 1', $customer, false, true);
     $message = Mage::getModel('helpdesk/message')->getCollection()->getLastItem();
     $this->assertEquals('message 1', $message->getBody());
     $this->assertEquals(2, $message->getTicketId());
     $this->assertEquals(Mirasvit_Helpdesk_Model_Config::MESSAGE_PUBLIC, $message->getType());
     $this->assertEquals('John Doe', $message->getCustomerName());
     $this->assertEquals('*****@*****.**', $message->getCustomerEmail());
     $this->assertEquals('John Doe', $this->_model->getLastReplyName());
 }
Пример #5
0
 /**
  * Retrieve form data
  *
  * @return Varien_Object
  */
 public function getFormData()
 {
     $data = $this->getData('form_data');
     if (is_null($data)) {
         $customerFormData = Mage::getSingleton('customer/session')->getCustomerFormData(true);
         $data = new Varien_Object($customerFormData);
         if (empty($customerFormData)) {
             $invitation = $this->getCustomerInvitation();
             if ($invitation->getId()) {
                 // check, set invitation email
                 $data->setEmail($invitation->getEmail());
             }
         }
         $this->setData('form_data', $data);
     }
     return $data;
 }
 public function testInitDataObject()
 {
     $this->setCurrentStore(0);
     $adminUser = new Varien_Object();
     $adminUser->setUserId(1);
     $adminUser->setUsername('username');
     $adminUser->setEmail('email');
     $adminUser->setFirstname('firstname');
     $adminUser->setLastname('lastname');
     $apiSessionMock = $this->getModelMockBuilder('api/session')->disableOriginalConstructor()->setMethods(array('getUser'))->getMock();
     $apiSessionMock->expects($this->any())->method('getUser')->will($this->returnValue($adminUser));
     $this->replaceByMock('singleton', 'api/session', $apiSessionMock);
     $apiEvent = new DEG_OrderLifecycle_Model_Lifecycle_Event_Api_Event();
     $apiEvent->initDataObject();
     $this->assertEquals(1, $apiEvent->getUserId());
     $this->assertEquals('username', $apiEvent->getUsername());
     $this->assertEquals('email', $apiEvent->getEmail());
 }
 public function testGetEventDataObjectApi()
 {
     $this->setCurrentStore(0);
     $adminUser = new Varien_Object();
     $adminUser->setUserId(1);
     $adminUser->setUsername('username');
     $adminUser->setEmail('email');
     $adminUser->setFirstname('firstname');
     $adminUser->setLastname('lastname');
     $apiSessionMock = $this->getModelMockBuilder('api/session')->disableOriginalConstructor()->setMethods(array('getUser'))->getMock();
     $apiSessionMock->expects($this->any())->method('getUser')->will($this->returnValue($adminUser));
     $this->replaceByMock('singleton', 'api/session', $apiSessionMock);
     $apiServerMock = $this->getModelMock('api/server', array('getAdapter'));
     $apiServerMock->expects($this->any())->method('getAdapter')->will($this->returnValue('api'));
     $this->replaceByMock('singleton', 'api/server', $apiServerMock);
     $factory = new DEG_OrderLifecycle_Model_Lifecycle_Event_Factory();
     $eventObject = $factory->getEventDataObject();
     $this->assertInstanceOf('DEG_OrderLifecycle_Model_Lifecycle_Event_Api_Event', $eventObject);
 }
Пример #8
0
 protected function _prepareCollection()
 {
     $helper = Mage::helper('mailinglist');
     //$data = $helper->getAllSubscribersInfo();
     $data = $helper->getAllSubscribers();
     $total = $helper->getCollectionTotal();
     $current_offset = $helper->getCurrentOffset();
     $collection = new Varien_Data_Collection();
     foreach ($data as $item) {
         $varienObject = new Varien_Object();
         $varienObject->setSubscriberId($item['id']);
         $varienObject->setEmail($item['email']);
         $varienObject->setFirstName($item['first_name']);
         $varienObject->setLastName($item['last_name']);
         $collection->addItem($varienObject);
     }
     parent::setCollection($collection);
     return parent::_prepareCollection();
 }
Пример #9
0
 /**
  * initialize
  *
  * @access public
  * @author Ultimate Module Creator
  */
 public function __construct()
 {
     $customerSession = Mage::getSingleton('customer/session');
     parent::__construct();
     $data = Mage::getSingleton('customer/session')->getPopupCommentFormData(true);
     $data = new Varien_Object($data);
     // add logged in customer name as nickname
     if (!$data->getName()) {
         $customer = $customerSession->getCustomer();
         if ($customer && $customer->getId()) {
             $data->setName($customer->getFirstname());
             $data->setEmail($customer->getEmail());
         }
     }
     $this->setAllowWriteCommentFlag($customerSession->isLoggedIn() || Mage::getStoreConfigFlag('iou_ultimatepopup/popup/allow_guest_comment'));
     if (!$this->getAllowWriteCommentFlag()) {
         $this->setLoginLink(Mage::getUrl('customer/account/login/', array(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME => Mage::helper('core')->urlEncode(Mage::getUrl('*/*/*', array('_current' => true)) . '#comment-form'))));
     }
     $this->setCommentData($data);
 }
 public function editAction()
 {
     /* Inits edit ticket form */
     $id = $this->getRequest()->getParam('id');
     $ticket = Mage::getModel('helpdeskultimate/ticket');
     $ticket->load($id);
     if ($id !== 0 && !$ticket->getData()) {
         $this->_getSession()->addError($this->__('Couldn\'t load ticket by given ID'));
         return $this->_redirect('*/index/index');
     }
     if ($ticket->isReadOnly()) {
         $format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
         $datetime = Mage::app()->getLocale()->date($ticket->getLockedAt(), Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
         Mage::getSingleton('adminhtml/session')->addError($this->__("Ticket has been locked by %s at %s", $ticket->getLockedUser()->getName(), $datetime));
     }
     if ($this->getRequest()->getParam('customer_id')) {
         if ($customer = Mage::getModel('customer/customer')->load($this->getRequest()->getParam('customer_id'))) {
             $ticket->setCustomer($customer);
         }
     }
     if ($this->getRequest()->getParam('order_id') && !$id) {
         if ($order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'))) {
             $customer = new Varien_Object();
             $customer->setEmail($order->getCustomerEmail())->setName($order->getCustomerFirstname() . " " . $order->getCustomerLastname())->setId($order->getCustomerId());
             $ticket->setTitle(Mage::helper('helpdeskultimate')->__("Order ID %s", $order->getIncrementId()))->setCustomer($customer)->setStoreId($order->getStore()->getId())->setOrderIncrementalId($order->getIncrementId());
         }
     }
     Mage::register('hdu_ticket_data', $ticket);
     $this->_title($this->__('Help Desk - Tickets'));
     $_title = is_null($ticket->getId()) ? $this->__('Create New Ticket') : '#' . $ticket->getUid();
     $this->_title($_title);
     $this->loadLayout()->_setActiveMenu('helpdeskultimate');
     $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
     $this->_addContent($this->getLayout()->createBlock('core/template')->setTemplate('helpdeskultimate/head.phtml'));
     $this->_addContent($this->getLayout()->createBlock('helpdeskultimate/adminhtml_tickets_edit'))->_addLeft($this->getLayout()->createBlock('helpdeskultimate/adminhtml_tickets_edit_tabs'));
     $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
     $this->renderLayout();
     Mage::getSingleton('adminhtml/session')->setFormData(null);
 }
Пример #11
0
 public function getCustomerInfoFromOrder($order)
 {
     $billingAddress = $order->getBillingAddress();
     $address = new Varien_Object();
     $address->setStreet($billingAddress->getStreet(1));
     $address->setStreetNumber($billingAddress->getStreet(2));
     $address->setComplementary($billingAddress->getStreet(3));
     // optional
     $address->setNeighborhood($billingAddress->getStreet(4));
     $address->setZipcode(Zend_Filter::filterStatic($billingAddress->getPostcode(), 'Digits'));
     $customer = new Varien_Object();
     $customer->setName($order->getCustomerName());
     $customer->setDocumentNumber($order->getCustomerTaxvat());
     $customer->setEmail($order->getCustomerEmail());
     $customer->setPhone($this->splitTelephone($billingAddress->getTelephone()));
     $customer->setSex($this->formatGender($order->getCustomerGender()));
     // optional
     $customer->setBornAt($this->formatDob($order->getCustomerDob()));
     // optional
     $customer->setAddress($address);
     Mage::dispatchEvent('pagarme_get_customer_info_from_order_after', array('order' => $order, 'customer_info' => $customer));
     return $customer;
 }
Пример #12
0
 public function getCustomerId($createIfNotExists = true)
 {
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     if ($customer->getIuguCustomerId()) {
         // Verify if customer really exists and try create again
         $result = Mage::getSingleton('iugu/api')->getCustomer($customer->getIuguCustomerId());
         if (!$result->getId()) {
             $customer->setIuguCustomerId('');
             $customer->save();
             return $this->getCustomerId();
         }
     } elseif ($createIfNotExists) {
         $customerData = new Varien_Object();
         $customerData->setEmail($customer->getEmail());
         $customerData->setName($customer->getName());
         $customerData->setNotes(Mage::app()->getWebsite()->getName());
         try {
             $result = Mage::getSingleton('iugu/api')->saveCustomer($customerData);
             $customer->setIuguCustomerId($result->getId());
             $customer->save();
         } catch (Exception $e) {
             Mage::throwException($e->getMessage());
         }
     }
     return $customer->getIuguCustomerId();
 }
Пример #13
0
 /**
  * Register on Magento's registry GUEST customer data for MergeVars for on checkout subscribe
  *
  * @param Mage_Sales_Model_Order $order
  * @return void
  */
 public function registerGuestCustomer($order)
 {
     if (Mage::registry('mc_guest_customer')) {
         return;
     }
     $customer = new Varien_Object();
     $customer->setId('guest' . time());
     $customer->setEmail($order->getBillingAddress()->getEmail());
     $customer->setStoreId($order->getStoreId());
     $customer->setFirstname($order->getBillingAddress()->getFirstname());
     $customer->setLastname($order->getBillingAddress()->getLastname());
     $customer->setPrimaryBillingAddress($order->getBillingAddress());
     $customer->setPrimaryShippingAddress($order->getShippingAddress());
     Mage::register('mc_guest_customer', $customer, TRUE);
 }
 /**
  * Construct a new profile request for the customer
  *
  * @param $payment
  * @param bool $forcedCustomerId
  * @return Varien_Object
  */
 protected function _buildProfileRequest($payment, $forcedCustomerId = false)
 {
     $customer_id = $forcedCustomerId ? null : $this->getCustomer()->getId();
     if (!$customer_id || !$this->isSavingCc()) {
         $customer_id = $payment->getOrder()->getIncrementId() . now();
         // Make up a customer ID so we don't ever have duplicate issues
         $description = "Guest or Unsaved Card";
     } else {
         $description = "Magento Customer ID: {$customer_id}";
     }
     $customerRefNum = $this->getCustomer()->getChasePaymentechCustomerRefNum();
     $billingAddress = $payment->getOrder()->getBillingAddress();
     $customer = new Varien_Object();
     $customer->setEmail($payment->getOrder()->getCustomerEmail())->setId($customer_id)->setDescription($description)->setCustomerRefNum($customerRefNum)->setFirstname($billingAddress->getFirstname())->setLastname($billingAddress->getLastname())->setCompany($billingAddress->getCompany())->setAddress($billingAddress->getStreet(true))->setCity($billingAddress->getCity())->setState($billingAddress->getRegion())->setZip($billingAddress->getPostcode())->setCountry($billingAddress->getCountryId());
     $payment_profile = new Varien_Object();
     $customer->setPaymentProfile($payment_profile);
     $customer->getPaymentProfile()->setCc($payment->getCcNumber())->setCcv($payment->getCcCid())->setExpiration(sprintf('%04d-%02d', $payment->getCcExpYear(), $payment->getCcExpMonth()));
     return $customer;
 }
 private function _sendTestContactFormEmail()
 {
     $postObject = new Varien_Object();
     $postObject->setName("SMTPPro Tester");
     $postObject->setComment("If you get this email then everything seems to be in order.");
     $postObject->setEmail("*****@*****.**");
     $mailTemplate = Mage::getModel('core/email_template');
     /* @var $mailTemplate Mage_Core_Model_Email_Template */
     include Mage::getBaseDir() . '/app/code/core/Mage/Contacts/controllers/IndexController.php';
     $mailTemplate->setDesignConfig(array('area' => 'frontend'))->setReplyTo($postObject->getEmail())->sendTransactional(Mage::getStoreConfig(Mage_Contacts_IndexController::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(Mage_Contacts_IndexController::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(Mage_Contacts_IndexController::XML_PATH_EMAIL_RECIPIENT), null, array('data' => $postObject));
 }
 /**
  * Authorize payment
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Paypal_Model_Direct
  */
 public function authorize(Varien_Object $payment, $amount)
 {
     $result = new Varien_Object($this->getPbridgeMethodInstance()->authorize($payment, $amount));
     $order = $payment->getOrder();
     $result->setEmail($order->getCustomerEmail());
     $this->_importResultToPayment($result, $payment);
     return $this;
 }
 public function postexternalAction()
 {
     $session = $this->_getSession();
     $customer = $session->getCustomer();
     $ticket = $this->_initExternalTicket();
     if (!$ticket) {
         $this->_forward('no_route');
         return;
     }
     if ($customer->getId() == 0) {
         $customer = new Varien_Object();
         $customer->setName($ticket->getCustomerName());
         $customer->setEmail($ticket->getCustomerEmail());
     }
     if ($this->postTicket($ticket, $customer)) {
         $this->_redirectUrl($ticket->getExternalUrl());
     } else {
         $this->_forward('no_route');
     }
 }
Пример #18
0
 public function testAppendReceiverEmail()
 {
     $request = new Dhl_Intraship_Model_Soap_Client_Shipment_Create();
     $parcel = new Varien_Object();
     $shipment = new Varien_Object();
     $billingAddress = new Varien_Object();
     $billingAddress->setPackageNotification(true);
     $shipment->setBillingAddress($billingAddress);
     $parcel->setShipment($shipment);
     $receiver = new Varien_Object();
     $receiver->setEmail('*****@*****.**');
     $shipmentOrder = array('Shipment' => array('Receiver' => array('Communication' => array('email' => null))));
     $params = new Dhl_Intraship_Model_Soap_Client_Shipment_Create();
     $params->offsetSet('ShipmentOrder', $shipmentOrder);
     $request->offsetSet('shipment', $parcel);
     $request->offsetSet('receiver', $receiver);
     $request->offsetSet('params', $params);
     $observer = Mage::getModel('dhlaccount/observer');
     $event = new Varien_Event_Observer();
     $eventData = new Varien_Object();
     $eventData->setRequest($request);
     $event->setEvent($eventData);
     $observer->appendReceiverEmail($event);
     $shipmentOrder = $request->offsetGet('params')->offsetGet('ShipmentOrder');
     $this->assertTrue(array_key_exists('Shipment', $shipmentOrder));
     $this->assertTrue(array_key_exists('Receiver', $shipmentOrder['Shipment']));
     $this->assertTrue(array_key_exists('Communication', $shipmentOrder['Shipment']['Receiver']));
     $this->assertTrue(array_key_exists('email', $shipmentOrder['Shipment']['Receiver']['Communication']));
     $this->assertEquals('*****@*****.**', $shipmentOrder['Shipment']['Receiver']['Communication']['email']);
 }