cancel
Showing results for 
Search instead for 
Did you mean: 

Onepage Checkout SaveBilling observer - Customer email is required

Onepage Checkout SaveBilling observer - Customer email is required

I'm trying to create an observer after the customer saves his billing address (onepage checkout). What the observer does is validate if a giftcard matches the customer email address (external service). Everything works fine, but order won't process at the end. I always get the erro "Customer email is required".

 

Anyone can help? Here's a quick view of my code:

 

config.xml

<controller_action_postdispatch_checkout_onepage_saveBilling>
          <observers>
              <community>
                  <type>singleton</type>
                  <class>community/observer</class>
                  <method>afterBillingMethod</method>
              </community>
          </observers>
      </controller_action_postdispatch_checkout_onepage_saveBilling>

the actual observer (simplify version)

public function afterBillingMethod($observer){

    // Get quote
    $session = Mage::getSingleton('checkout/session');
    $quote = $session->getQuote();
    $coupon_code = $quote->getCouponCode();

    // Get customer billing email address
    $post= Mage::app()->getRequest()->getPost();
    $email= $post['billing']['email'];
        if($coupon['email'] != $email)
        {
          $rule = Mage::getModel('salesrule/rule')->load($coupon['rule_id']);
          if($rule)
          {
            $coupon->delete();
            $rule->delete();
          }
        }

    return $this;
  }
1 REPLY 1

Re: Onepage Checkout SaveBilling observer - Customer email is required

@jfcromp

 

First of all check if all the inforamtion are being receiving in observer by debugging your code with Try and Catch.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now