What We're Trying To Do

Using Magento CE 1.7.0.2. We are using a one-page checkout. We need users to be registered to checkout (NO guest checkout). BUT, we need them to be able to login and/or register on the one-page checkout.

The Problem

We cannot use Magento's default option "require login to checkout" becuase it doesn't allow users to reach the checkout page unless they are logged in.

The Solution

Well, I dunno... yet. This is what I've tried, but it led to all sorts of disastrous checkout problems with SagePay (multiple transactions):

if (!$this->getCustomerSession()->isLoggedIn()) {
    Mage::throwException(Mage::helper('checkout')->
      __('Please login. You must be logged in to checkout.'));
}

Any helpful input appreciated, thanks.

有帮助吗?

解决方案

Go: template/chackout/onepage.phtml

**put this code on before page code**
<?php
          if (!$this->helper('customer')->isLoggedIn()) {
                header('Location: '.$this->getUrl('customer/account/login')) ;
                 exit();
          }
?>

其他提示

IN CONCLUSION:

The problems with this piece of functionality are:

  1. We can't check if the user is logged in because users can register on this page, hence until they register, they are not logged in, so they will supply a valid request on submit.
  2. The one page module is overwriting some of Magento's default validation behaviour, so we need to intercept the module's validation or write our own.

To solve the problem, we ultimately validated the fields for registration. If those are empty (if guest checkout is disabled), then the form cannot be submitted. A bit ugly, but functional.

Hope someone else can use that.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top