Save email in quote the soonest for abandoned cart extension

This article applies if you have installed an abandoned cart extension, like e.g. Ebizmarts Mailchimp and want to get the email saved in the quote the earliest possible.

That is actually all there is in abandoned cart extensions: they look for active quotes from database that are idling and notify the e-mail stored in quote.

Quote will be stored in One Step Checkout when ajax refresh of shipping, payment and summary sections is run.

If you want to have quote saved the soonest, so that abandoned cart extension picks it up, you can move email field to 1st position and you can edit checkout.phtml on your site and add trigger to e-mail field to save data straight away when it is changed.

Look up this code:

var url_save_billing = 'getUrl('onestepcheckout/ajax/save_billing', array('_secure'=>true)); ?>';
var url_set_methods = 'getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
var update_payments = settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
var update_on_initial = false;

AND ADD THIS CODE AFTER IT:

var bemail = $('billing:email');
if(bemail !== null){
bemail.observe('change',



get_save_billing_function(url_save_billing, url_set_methods,
update_payments, true));

}

The result of that modification is that the email address value gets saved to table sales_flat_quote_address.

NB! Issues have reported that email does not get saved to quote. This is not a regular issue, maybe an exception gets thrown because of required fields. There is something about your configuration that breaks it, usually we do not have issues with mailchimp.

What you can do is force save the fields, please add that code to ajaxcontroller.php

Add the code to line 445 .

$this->_getOnepage()->getQuote()->setCustomerEmail(Mage::helper('core')->escapeHtml($billing_data['email']));
$this->_getOnepage()->getQuote()->setCustomerFirstname(Mage::helper('core')->escapeHtml($billing_data['firstname']));
$this->_getOnepage()->getQuote()->setCustomerLastname(Mage::helper('core')->escapeHtml($billing_data['lastname']));
$tmp = $this->_getOnepage()->getQuote()->save();