1

I followed this Answer: customer save before process checkout button click

And it works great. However, when I add the line:

Mage::getSingleton('customer/session')->loginById($customer->getId()); // to login that customer.

It doesn't update the toplinks. I need to refresh the page to actually reflect that I got logged in. How can I achieve that?

1

I think you're going to find that pretty difficult to do. Each step of the default OPC in Magento is an AJAX step not a full page request. You therefore can't re-direct the customer from your observer, as this will re-direct the AJAX request.

The only way I can think of doing it and this is purely hypothetical, is to inject an extra field in the JSON response and then modify the JS that calls save billing and refresh the page if that value is present in the result value. I think the event may be late enough to allow manipulation of the response with something along the lines of:

$resp = Mage::app()->getResponse()->getBody();
$resp = Mage::helper('core')->jsonDecode($resp);
$resp['redirect_me'] = 1;
Mage::app()->getResponse()->setBody($resp);

At this point you'd need to overwrite Billing.prototype.onSave to refresh the page rather than move to the next step. Of course the problem with that is the customer will see the billing section they just filled out (all be it, they will be logged in) rather than the shipping / shipping method section.

Depending on your exact requirements, you might be able to simply modify the DOM rather than re-direct, I.E. change the login link to log out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.