5

I am using magento version 1.9 and its soap api to create order. In case of guest checkout(customer mode is guest), the email address is not getting saved or shown in admin sales orders. This is working fine for customer in "customer" mode. In the api, it is working fine because "customer_is_guest" is 1 and customer_email is correctly set when we check cart.info api call. Please help to resolve this magento bug.

  • You got any solution on this please let me know i also have same problem – Magento 2 Feb 15 '16 at 16:38
4

Fixed and tested: add to your existing module or add a new module:

config.xml

// src/app/code/local/Your/Module/etc/config.xml
<?xml version="1.0"?>
<config>
    <modules>
        <Your_Module>
            <version>1.0.0</version>
        </Your_Module>
    </modules>
    <global>
        <models>
            <your_module_alias>
                <class>Your_Module_Model</class>
            </your_module_alias>
            <checkout>
                <rewrite>
                    <api_resource_customer>Your_Module_Model_Api_Resource_Customer</api_resource_customer>
                </rewrite>
            </checkout>
        </models>
    </global>
</config>

Customer.php

// src/app/code/local/Your/Module/Model/Api/Resource/Customer.php
/**
 * Class Your_Module_Model_Api_Resource_Customer
 */
class Your_Module_Model_Api_Resource_Customer
    extends Mage_Checkout_Model_Api_Resource_Customer
{
    /**
     * FIX guest order email blank.
     *
     * Mage using billing address email as customer email on guest orders.
     *
     * see http://magento.stackexchange.com/questions/90380/magento-customer-email-missing-in-guest-checkout-when-using-soap-api
     *
     * @param Mage_Sales_Model_Quote $quote
     *
     * @return $this
     */
    protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
    {
        $quote->setCustomerId(null)
            // ORIG: email always empty ->setCustomerEmail($quote->getBillingAddress()->getEmail())
            ->setCustomerEmail($quote->getCustomerEmail()) // fix
            ->setCustomerIsGuest(true)
            ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
        return $this;
    }
}
2

I had the same problem, on this file:

app/code/core/Mage/Checkout/Model/Api/Resource/Customer.php #114

I found this code

protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
{
    $quote->setCustomerId(null)
        ->setCustomerEmail($quote->getBillingAddress()->getEmail())
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    return $this;
}

Basically the "email" address is overridden by the "email" address of the billing address. I changed the code to:

protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
{
    $quote->setCustomerId(null)
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    return $this;
}

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.