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;
}