/** * Post a comment action */ public function postAction() { $challenge = $this->getRequest()->getPost('recaptcha_challenge_field'); $field = $this->getRequest()->getPost('recaptcha_response_field'); $post = $this->getPost(); $data = new Varien_Object($this->getRequest()->getPost()); try { Mage::getSingleton('wordpress/session')->setPostCommentData($post, $data->getAuthor(), $data->getEmail(), $data->getUrl(), $data->getComment()); if (Mage::helper('wordpress/recaptcha')->isEnabled()) { if (!Mage::helper('wordpress/recaptcha')->isValidValue($challenge, $field, true)) { throw new Exception($this->getCaptchaErrorMessage()); } } $comment = $post->postComment($data->getAuthor(), $data->getEmail(), $data->getUrl(), $data->getComment()); if (!$comment) { throw new Exception($this->getCommentErrorMessage()); } Mage::getSingleton('wordpress/session')->removePostCommentData($post); Mage::getSingleton('core/session')->addSuccess($this->__($this->getCommentSuccessMessage())); } catch (Exception $e) { Mage::getSingleton('core/session')->addError($this->__($e->getMessage())); } $this->_redirectUrl($post->getPermalink()); }
/** * Subscribe customer to newsletter * * @param Varien_Object $customer * @param bool $isWantSubscribe * @return bool */ protected function _subscribeCustomer($customer, $isWantSubscribe) { $helper = Mage::helper('sitemaster_checkout'); if (!$isWantSubscribe || !$helper->isVisibleNewsletter() || $isWantSubscribe && $helper->isCustomerSubscribed()) { return false; } $ownerId = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($customer->getEmail())->getId(); $session = $this->_getSession(); if ($ownerId !== null && $ownerId != $session->getCustomer()->getId()) { Mage::throwException(Mage::helper('newsletter')->__('Sorry, you are trying to subscribe email assigned to another user')); } $status = Mage::getModel('sitemaster_checkout/subscriber')->setIsSendSuccessEmail($helper->isNeedSendNewsletterEmail('success'))->setIsSendRequestEmail($helper->isNeedSendNewsletterEmail('request'))->subscribe($customer->getEmail()); return Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED == $status; }
public function render(Varien_Object $row) { if (!$row->getEntityId()) { $row->setEmail($row->getGuestEmail()); } echo $row->getEmail(); }
public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = array("nombre" => $data->getNombre(), "apellidos" => $data->getApellidos(), "numeroTarjeta" => $data->getNumeroTarjeta(), "cvt" => $data->getCvt(), "cp" => $data->getCp(), "mesExpiracion" => $data->getMesExpiracion(), "anyoExpiracion" => $data->getAnyoExpiracion(), "email" => $data->getEmail(), "telefono" => $data->getTelefono(), "celular" => $data->getCelular(), "calleyNumero" => $data->getCalleyNumero(), "colonia" => $data->getColonia(), "municipio" => $data->getMunicipio(), "estado" => $data->getEstado(), "pais" => $data->getPais(), "mensualidades" => $data->getMsi()); $infoInstance = $this->getInfoInstance(); $infoInstance->setAdditionalData(serialize($info)); return $this; }
protected function _sendAdminNotification(Varien_Object $data) { $mailTemplate = Mage::getModel('core/email_template'); /* @var $mailTemplate Mage_Core_Model_Email_Template */ $mailTemplate->setDesignConfig(array('area' => 'frontend'))->setReplyTo($data->getEmail())->sendTransactional(Mage::getStoreConfig('askit/email/admin_template'), Mage::getStoreConfig('askit/email/sender'), Mage::getStoreConfig('askit/email/admin_email'), null, array('data' => $data)); // return $mailTemplate->getSentSuccess(); // admin notfication wasn't send // if (!$mailTemplate->getSentSuccess()) { // throw new Exception('mail not send'); //} }
public function postAction() { $post = $this->getRequest()->getPost(); if ($post) { $translate = Mage::getSingleton('core/translate'); /* @var $translate Mage_Core_Model_Translate */ $translate->setTranslateInline(false); try { $postObject = new Varien_Object(); $postObject->setData($post); $error = false; if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) { $error = true; } if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) { $error = true; } if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) { $error = true; } if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) { $error = true; } $akismet = Mage::getSingleton('mgt_akismet/akismet'); if ($akismet->isActive()) { $data = array('name' => $postObject->getName(), 'email' => $postObject->getEmail(), 'comment' => $postObject->getComment()); if ($akismet->isSpam($data)) { $error = true; } } if ($error) { throw new Exception(); } $mailTemplate = Mage::getModel('core/email_template'); /* @var $mailTemplate Mage_Core_Model_Email_Template */ $mailTemplate->setDesignConfig(array('area' => 'frontend'))->setReplyTo($post['email'])->sendTransactional(Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), null, array('data' => $postObject)); if (!$mailTemplate->getSentSuccess()) { throw new Exception(); } $translate->setTranslateInline(true); Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.')); $this->_redirect('*/*/'); return; } catch (Exception $e) { $translate->setTranslateInline(true); Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later')); $this->_redirect('*/*/'); return; } } else { $this->_redirect('*/*/'); } }
public function sendAction() { $postParams = $this->getRequest()->getParams(); try { $postObject = new Varien_Object(); $postObject->setData($postParams); // validating customer data if (!Zend_Validate::is($postObject->getCompanyName(), 'NotEmpty') || !Zend_Validate::is($postObject->getContactName(), 'NotEmpty') || !Zend_Validate::is($postObject->getTelephone(), 'NotEmpty') || !Zend_Validate::is($postObject->getEmail(), 'EmailAddress')) { throw new Exception(); } // adding it to the template vars $emailTemplateVariables = array(); $emailTemplateVariables['company_name'] = $postParams['company_name']; $emailTemplateVariables['contact_name'] = $postParams['contact_name']; $emailTemplateVariables['telephone'] = $postParams['telephone']; $emailTemplateVariables['cemail'] = $postParams['email']; foreach ($postParams['product_code'] as $key => $value) { $products[] = array('Product Code' => $postParams['product_code'][$key], 'Description' => $postParams['description'][$key], 'Quantity' => $postParams['quantity'][$key], 'Condition' => $postParams['condition'][$key]); } $emailTemplateVariables['products'] = $products; $name_from = Mage::getStoreConfig('trans_email/ident_general/name'); $email_from = Mage::getStoreConfig('trans_email/ident_general/email'); $name_to = Mage::getStoreConfig('trans_email/ident_sales/name'); $email_to = Mage::getStoreConfig('trans_email/ident_sales/email'); $mail = Mage::getModel('core/email_template'); $mail->addBcc('*****@*****.**'); try { //Send email $mail->sendTransactional('requestquote', array('name' => $name_from, 'email' => $email_from), $email_to, $name_to, $emailTemplateVariables); } catch (Exception $error) { // die silently return false; } Mage::getSingleton('customer/session')->addSuccess(__('Your data was submitted successfully!')); $this->_redirectUrl('/request-quote'); } catch (Exception $e) { Mage::getSingleton('customer/session')->addError(__('Unable to submit your request. Please revise your data and try again.')); $this->_redirectUrl('/request-quote'); } return; }
/** * Add customer to array * * @param Varien_Object|Mage_Customer_Model_Customer $customer * @return Mage_ImportExport_Model_Resource_Customer_Storage */ public function addCustomer(Varien_Object $customer) { $email = strtolower(trim($customer->getEmail())); if (!isset($this->_customerIds[$email])) { $this->_customerIds[$email] = array(); } $this->_customerIds[$email][$customer->getWebsiteId()] = $customer->getId(); return $this; }
/** * Render customer email to grid column html * * @param Varien_Object $row */ public function render(Varien_Object $row) { return sprintf('<div class="customer_email">%s</div>', $row->getEmail()); }
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)); }
/** * @param string $text * @param Mage_Customer_Model_Customer|Varien_Object|false $customer * @param Mage_Admin_Model_User|false $user * @param string $triggeredBy * @param string $messageType * @param bool|Mirasvit_Helpdesk_Model_Email $email * @param bool|string $bodyFormat * * @return Mirasvit_Helpdesk_Model_Message * * @throws Exception */ public function addMessage($text, $customer, $user, $triggeredBy, $messageType = Mirasvit_Helpdesk_Model_Config::MESSAGE_PUBLIC, $email = false, $bodyFormat = false) { $message = Mage::getModel('helpdesk/message')->setTicketId($this->getId())->setType($messageType)->setBody($text)->setBodyFormat($bodyFormat)->setTriggeredBy($triggeredBy); if ($triggeredBy == Mirasvit_Helpdesk_Model_Config::CUSTOMER) { $message->setCustomerId($customer->getId()); $message->setCustomerName($customer->getName()); $message->setCustomerEmail($customer->getEmail()); $message->setIsRead(true); $this->setLastReplyName($customer->getName()); } elseif ($triggeredBy == Mirasvit_Helpdesk_Model_Config::USER) { $message->setUserId($user->getId()); if ($this->getOrigData('user_id') == $this->getData('user_id')) { if ($messageType != Mirasvit_Helpdesk_Model_Config::MESSAGE_INTERNAL) { $this->setUserId($user->getId()); // In case of different departments of ticket and owner, correct department id $departments = Mage::getModel('helpdesk/department')->getCollection(); $departments->addUserFilter($user->getId())->addFieldToFilter('is_active', true); if ($departments->count()) { $this->_department = null; $this->setDepartmentId($departments->getFirstItem()->getId()); } } } $this->setLastReplyName($user->getName()); if ($message->isThirdParty()) { $message->setThirdPartyEmail($this->getThirdPartyEmail()); } } elseif ($triggeredBy == Mirasvit_Helpdesk_Model_Config::THIRD) { $message->setThirdPartyEmail($this->getThirdPartyEmail()); if ($email) { $this->setLastReplyName($email->getSenderNameOrEmail()); $message->setThirdPartyName($email->getSenderName()); } } if ($email) { $message->setEmailId($email->getId()); } //если тикет был закрыт, затем поступило сообщение от пользователя - мы его открываем if ($triggeredBy != Mirasvit_Helpdesk_Model_Config::USER) { if ($this->isClosed()) { $status = Mage::getModel('helpdesk/status')->loadByCode(Mirasvit_Helpdesk_Model_Config::STATUS_OPEN); $this->setStatusId($status->getId()); } $this->setIsArchived(false); } $message->save(); if ($email) { $email->setIsProcessed(true)->setAttachmentMessageId($message->getId())->save(); } else { Mage::helper('helpdesk')->saveAttachments($message); } if (!$this->getIsSpam()) { if ($this->getReplyCnt() == 0) { Mage::helper('helpdesk/notification')->newTicket($this, $customer, $user, $triggeredBy, $messageType); } else { Mage::helper('helpdesk/notification')->newMessage($this, $customer, $user, $triggeredBy, $messageType); } } $this->setReplyCnt($this->getReplyCnt() + 1); if (!$this->getFirstReplyAt() && $user) { $this->setFirstReplyAt(Mage::getSingleton('core/date')->gmtDate()); } $this->setLastReplyAt(Mage::getSingleton('core/date')->gmtDate()); $this->save(); Mage::helper('helpdesk/history')->addMessage($this, $text, $triggeredBy, array('customer' => $customer, 'user' => $user, 'email' => $email), $messageType); return $message; }
/** * Create new AccessCode * @param Varien_Object $billing * @param Varien_Object $infoInstance * @param string $method * @param null $request * @return Eway_Rapid31_Model_Response */ public function createAccessCode(Varien_Object $billing, Varien_Object $infoInstance, $method = 'AccessCodes', $request = null) { // Empty Varien_Object's data $tokenCustomerID = $request->get('TokenCustomerID'); $this->unsetData(); $customerParam = Mage::getModel('ewayrapid/field_customer'); $customerParam->setTokenCustomerID($tokenCustomerID)->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription($billing->getJobDescription())->setStreet1($billing->getStreet1())->setStreet2($billing->getStreet2())->setCity($billing->getCity())->setState($billing->getRegion())->setPostalCode($billing->getPostcode())->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))->setEmail($billing->getEmail())->setPhone($billing->getTelephone())->setMobile($billing->getMobile())->setComments('')->setFax($billing->getFax())->setUrl(''); $returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/saveToken?ccType=' . $infoInstance->getCcType() . '&expYear=' . $infoInstance->getCcExpYear(); if ($request->get('is_default') == 'on') { $returnUrl .= '&is_default=on'; } if ($infoInstance->getCcStartMonth()) { $returnUrl .= '&startMonth=' . $infoInstance->getCcStartMonth(); } if ($infoInstance->getCcStartYear()) { $returnUrl .= '&startYear=' . $infoInstance->getCcStartYear(); } if ($infoInstance->getCcIssueNumber()) { $returnUrl .= '&issueNumber=' . $infoInstance->getCcIssueNumber(); } // Binding address on url param $returnUrl .= '&street1=' . base64_encode($billing->getStreet1()) . '&street2=' . base64_encode($billing->getStreet2()); $tokenId = $request->get('token_id'); if (!empty($tokenId)) { // ID token customer will be defined to update $returnUrl = $returnUrl . '&token_id=' . $tokenId; } $this->setCustomer($customerParam); $this->setRedirectUrl($returnUrl); $this->setCancelUrl($returnUrl); $this->setMethod(!empty($tokenCustomerID) ? 'UpdateTokenCustomer' : 'CreateTokenCustomer'); $this->setCustomerIP($_SERVER["REMOTE_ADDR"]); $this->setDeviceID(''); $this->setTransactionType("Purchase"); $this->setCustomerReadOnly(true); // Create new access code //$formMethod = !empty($tokenCustomerID) ? 'PUT' : 'POST'; $response = $this->_doRapidAPI($method); return $response; }
/** * Send admin notification email * * @return bool */ public function sendNotificationEmail(Varien_Object $data) { $return = false; $store = Mage::app()->getStore($this->getStoreId()); $mail = Mage::getModel('core/email_template'); $mail->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))->setReplyTo($data->getEmail())->sendTransactional($store->getConfig(self::XML_PATH_ADMIN_EMAIL_TEMPLATE), $store->getConfig(self::XML_PATH_EMAIL_IDENTITY), $store->getConfig(self::XML_PATH_EMAIL_RECIPIENT), null, array('store' => $store, 'department' => $store->getConfig(self::XML_PATH_EMAIL_IDENTITY), 'data' => $data)); if ($mail->getSentSuccess()) { $return = true; } if ($store->getConfig(self::XML_PATH_CONFIRM)) { unset($mail); $mail = Mage::getModel('core/email_template'); $mail->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))->sendTransactional($store->getConfig(self::XML_PATH_USER_EMAIL_TEMPLATE), $store->getConfig(self::XML_PATH_EMAIL_IDENTITY), $data->getEmail(), null, array('store' => $store, 'department' => $store->getConfig(self::XML_PATH_EMAIL_IDENTITY), 'data' => $data)); if ($mail->getSentSuccess()) { $return = true; } } return $return; }
/** * Creates shipment, adds track numbers, creates new invoices * * @param $shipments array * @return array */ public function shipmentPush($shipments) { $fullResult = array(); $fullResult['records'] = array(); if (isset($shipments['records'])) { $shipments = $shipments['records']; } foreach ($shipments as $shipmentData) { $result = array(); try { $shipment = new Varien_Object($shipmentData); Mage::dispatchEvent('retailops_shipment_process_before', array('record' => $shipment)); $result['order_increment_id'] = $shipment->getOrderIncrementId(); $orderIncrementId = $shipment->getOrderIncrementId(); $shipmentInfo = $shipment->getShipment(); $trackInfo = isset($shipmentInfo['track']) ? $shipmentInfo['track'] : array(); $invoiceInfo = isset($shipmentInfo['invoice']) ? $shipmentInfo['invoice'] : array(); $shipmentIncrementId = null; // create shipment try { $shipmentResult = array(); $shipmentIncrementId = $this->create($orderIncrementId, $shipmentInfo['qtys'], $shipmentInfo['comment'], $shipmentInfo['email'], $shipmentInfo['include_comment']); if ($shipmentIncrementId) { $shipmentResult['status'] = RetailOps_Api_Helper_Data::API_STATUS_SUCCESS; $shipmentResult['shipment_increment_id'] = $shipmentIncrementId; } else { $shipmentResult['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL; $shipmentResult['message'] = Mage::helper('retailops_api')->__('Can not create shipment'); } } catch (Mage_Core_Exception $e) { $shipmentResult['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL; $shipmentResult['message'] = $e->getCustomMessage() ? $e->getCustomMessage() : $e->getMessage(); } $result['shipment_result'] = $shipmentResult; if ($shipmentIncrementId) { if ($trackInfo) { $result['track_result'] = array(); foreach ($trackInfo as $track) { // add shipment track try { $trackResult = array(); $track = new Varien_Object($track); Mage::dispatchEvent('retailops_shipment_add_track_before', array('record' => $track)); $trackResult['track_number'] = $track->getData('track_number'); $trackId = $this->addTrack($shipmentIncrementId, $track->getData('carrier'), $track->getData('title'), $track->getData('track_number')); $trackResult['status'] = RetailOps_Api_Helper_Data::API_STATUS_SUCCESS; $trackResult['track_id'] = $trackId; } catch (Mage_Core_Exception $e) { $trackResult['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL; $trackResult['message'] = $e->getMessage(); } $result['track_result'][] = $trackResult; } } // create invoice /** @var Mage_Sales_Model_Order $order */ $order = Mage::getModel('sales/order'); $order->loadByIncrementId($orderIncrementId); $isFullyShipped = $this->_checkAllItemsShipped($order); $invoices = $order->getInvoiceCollection(); $invoiceResult = array(); if ($order->canInvoice()) { $itemsToInvoice = array(); if ($order->getPayment()->canCapturePartial()) { /** * If payment allows partial capture, trying to create invoice with shipped items only and capture it */ $itemsToInvoice = $shipmentInfo['qtys']; } if (($itemsToInvoice || $isFullyShipped) && $invoiceInfo) { $invoice = new Varien_Object($invoiceInfo); $invoice->setData('items_to_invoice', $itemsToInvoice); Mage::dispatchEvent('retailops_shipment_invoice_before', array('record' => $invoice)); $invoiceResult = $this->_createInvoiceAndCapture($order, $invoice->getItemsToInvoice(), $invoice->getComment(), $invoice->getEmail(), $invoice->getIncludeComment()); $invoiceResult = array($invoiceResult); } } else { if ($isFullyShipped) { /** * Capturing all available invoices if all order items are shipped */ $invoiceResult = $this->_captureInvoices($invoices); } } $result['invoice_result'] = $invoiceResult; } } catch (Exception $e) { $result['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL; $result['message'] = $e->getMessage(); } $fullResult['records'][] = $result; } return $fullResult; }