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; }
public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setCcType('openinvoice'); // check if option gender or date of birth is enabled $genderShow = $this->genderShow(); $dobShow = $this->dobShow(); $telephoneShow = $this->telephoneShow(); if ($genderShow || $dobShow || $telephoneShow) { // set gender and dob to the quote $quote = $this->getQuote(); // dob must be in yyyy-MM-dd $dob = $data->getYear() . "-" . $data->getMonth() . "-" . $data->getDay(); if ($dobShow) { $quote->setCustomerDob($dob); } if ($genderShow) { $quote->setCustomerGender($data->getGender()); // Fix for OneStepCheckout (won't convert quote customerGender to order object) $info->setAdditionalInformation('customerGender', $data->getGender()); } if ($telephoneShow) { $telephone = $data->getTelephone(); $quote->getBillingAddress()->setTelephone($data->getTelephone()); } /* Check if the customer is logged in or not */ if (Mage::getSingleton('customer/session')->isLoggedIn()) { /* Get the customer data */ $customer = Mage::getSingleton('customer/session')->getCustomer(); // set the email and/or gender if ($dobShow) { $customer->setDob($dob); } if ($genderShow) { $customer->setGender($data->getGender()); } if ($telephoneShow) { $billingAddress = $customer->getPrimaryBillingAddress(); if ($billingAddress) { $billingAddress->setTelephone($data->getTelephone()); } } // save changes into customer $customer->save(); } } return $this; }
/** * Assigning shipping address to soap object * * @param Varien_Object $shipping */ protected function addShippingAddress($shipping) { //checking if we have shipping address, in case of virtual order we will not have it if ($shipping) { $shipTo = new stdClass(); $shipTo->firstName = $shipping->getFirstname(); $shipTo->lastName = $shipping->getLastname(); $shipTo->company = $shipping->getCompany(); $shipTo->street1 = $shipping->getStreet(1); $shipTo->street2 = $shipping->getStreet(2); $shipTo->city = $shipping->getCity(); $shipTo->state = $shipping->getRegion(); $shipTo->postalCode = $shipping->getPostcode(); $shipTo->country = $shipping->getCountry(); $shipTo->phoneNumber = $this->cleanPhoneNum($shipping->getTelephone()); $this->_request->shipTo = $shipTo; Mage::getSingleton('core/session')->setShipping($shipTo); } }
/** * 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; }