示例#1
0
 public function SendSmsRegister(Varien_Event_Observer $observer)
 {
     $msisdn = $observer->getCustomerAddress()->getTelephone();
     // Customer Mobile No
     //START SMS API Code here your code
     //$msisdn2='0171767xxxx'; // Store Admin Mobile No
     $sms = 'Congrats! You have successfully Register. Thank You.@SSLW';
     //May Change SMS Body here
     $user = "******";
     $pass = "******";
     //if change login password isms.sslwireless.com then change new here
     $sid = "StakeHolderName";
     //Stake Holder Name here
     $url = "http://sms.sslwireless.com/pushapi/dynamic/server.php";
     $unique_id_1 = uniqid();
     $unique_id_2 = uniqid();
     $param = "user={$user}&pass={$pass}&sid={$sid}&";
     $sms = "sms[0][0]={$msisdn}&sms[0][1]=" . urlencode($sms) . "&sms[0][2]=" . $unique_id_1 . "&sms[1][0]={$msisdn2}&sms[1][1]=" . urlencode($sms) . "&sms[1][2]=" . $unique_id_2 . "";
     $data = $param . $sms . $sid;
     $crl = curl_init();
     curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($crl, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($crl, CURLOPT_URL, $url);
     curl_setopt($crl, CURLOPT_HEADER, 0);
     curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($crl, CURLOPT_POST, 1);
     curl_setopt($crl, CURLOPT_POSTFIELDS, $data);
     $response = curl_exec($crl);
     curl_close($crl);
     //echo $response;
     //ENd SMS API Code here your code
     //Mage::log('obersver custave_after12'.'Mobile=='.$msisdn,null,'SendSmsRegister.log' );
 }
示例#2
0
 /**
  * Strip non-digit characters from phone/fax numbers in customer addresses
  *
  * @param  Varien_Event_Observer $observer
  * @return void
  */
 public function customer_address_save_before(Varien_Event_Observer $observer)
 {
     $customer_address = $observer->getCustomerAddress();
     $cleanPhone = $this->_cleanPhone($customer_address, 'telephone');
     $cleanFax = $this->_cleanPhone($customer_address, 'fax');
     $customer_address->setTelephone($cleanPhone);
     $customer_address->setFax($cleanFax);
 }
示例#3
0
 /**
  * Validate vat id if given and assign tax class to customer address
  *
  * @param Varien_Event_Observer $observer
  */
 public function afterAddressSave($observer)
 {
     /** @var $customerAddress Mage_Customer_Model_Address */
     $customerAddress = $observer->getCustomerAddress();
     $customer = $customerAddress->getCustomer();
     if (!Mage::helper('customer/address')->isVatValidationEnabled($customer->getStore()) || Mage::registry(self::VIV_PROCESSED_FLAG) || !$this->_canProcessAddress($customerAddress)) {
         return;
     }
     try {
         Mage::register(self::VIV_PROCESSED_FLAG, true);
         /** @var $customerHelper Mage_Customer_Helper_Data */
         $customerHelper = Mage::helper('customer');
         if ($customerAddress->getVatId() == '' || !Mage::helper('core')->isCountryInEU($customerAddress->getCountry())) {
             $defaultGroupId = $customerHelper->getDefaultCustomerGroupId($customer->getStore());
             if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $defaultGroupId) {
                 $customerGroup = Mage::getModel('customer/group')->load($customer->getGroupId());
                 $customerAddress->setTaxClassId($customerGroup->getTaxClassId());
                 $customerAddress->save();
             }
         } else {
             $result = $customerHelper->checkVatNumber($customerAddress->getCountryId(), $customerAddress->getVatId());
             if (!$customer->getDisableAutoGroupChange()) {
                 $customerGroup = Mage::getModel('customer/group')->load($customer->getGroupId());
                 if ($result->getIsValid()) {
                     $customerAddress->setTaxClassId($customerGroup->getTaxClassIdVatId());
                 } else {
                     $customerAddress->setTaxClassId($customerGroup->getTaxClassId());
                 }
                 $customerAddress->save();
             }
             if (!Mage::app()->getStore()->isAdmin()) {
                 $validationMessage = Mage::helper('customer')->getVatValidationUserMessage($customerAddress, $customer->getDisableAutoGroupChange(), $result);
                 if (!$validationMessage->getIsError()) {
                     Mage::getSingleton('customer/session')->addSuccess($validationMessage->getMessage());
                 } else {
                     Mage::getSingleton('customer/session')->addError($validationMessage->getMessage());
                 }
             }
         }
     } catch (Exception $e) {
         Mage::register(self::VIV_PROCESSED_FLAG, false, true);
     }
 }
 /**
  * Save changed customer address at customer quotes that are linked
  *
  * @param Varien_Event_Observer $observer
  * @return $this
  * @throws Exception
  */
 public function updateCustomerAddressAtQuotes(Varien_Event_Observer $observer)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     /** @var Mage_Customer_Model_Address $address */
     $address = $observer->getCustomerAddress();
     $subscriptions = Mage::getModel('adyen_subscription/subscription')->getCollection()->addFieldToFilter('customer_id', $address->getCustomerId());
     foreach ($subscriptions as $subscription) {
         /** @var Adyen_Subscription_Model_Subscription $subscription */
         foreach ($subscription->getQuoteAdditionalCollection() as $quoteAdditional) {
             /** @var Adyen_Subscription_Model_Subscription_Quote $quoteAdditional */
             $quote = $quoteAdditional->getQuote();
             $billingAddress = $quote->getBillingAddress();
             if ($billingAddress->getCustomerAddressId() == $address->getId()) {
                 $billingAddress->addData($address->getData());
                 $billingAddress->save();
             }
             $shippingAddress = $quote->getShippingAddress();
             if ($shippingAddress->getCustomerAddressId() == $address->getId()) {
                 $shippingAddress->addData($address->getData());
                 $shippingAddress->save();
             }
         }
     }
     return $this;
 }