Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Questions get customer details and onepage/checkout/success doesn't sending email

How to get customers data so i can pass it to a gateway payment.

Here is my model:

public function getStandardCheckoutFormFields() {
        $orderIncrementId = $this->getCheckout()->getLastRealOrderId();
        $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
        //$order = $this->get_sale_order($orderIncrementId);
        echo Mage::getModel('customer/customer')->load($orderIncrementId);

        $productArray = array();

        foreach ($order->getAllItems() as $item) {
            $productArray[] = array(
                "product_name"  => $item->getName(),
                "product_qty"   => $item->getQtyOrdered(),
                "product_price" => $item->getPrice(),
            );
        }
        return $productArray;
    }

here is my controller:

public function redirectAction(){
        $session = Mage::getSingleton('checkout/session');
        $session->setAsurepayCustompayQuoteId($session->getQuoteId());
        $this->getResponse()->setBody($this->getLayout()->createBlock('custompay/redirect')->toHtml());
        $session->unsQuoteId();
        $session->unsRedirectUrl();
    }

This are running perfectly running, the problem is i can't get customer details such as customer name, address and etc.

I already tried this code

Mage::getSingleton(customer/customer)->getData();

There was a result but not printing.

In the checkout page success (onepage). When customer redirected here, There is no email will be send to the customer and the order was not update as completed.

like image 681
Jorge Avatar asked May 20 '11 17:05

Jorge


1 Answers

You're trying to load a customer with an id that belongs to the order. This obviously doesn't work! You need to extract the customer_id from the order and load the customer model based on that.

$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());

You're also using Mage::getSingleton which is the wrong call. You want a new instance tailored to a specific customer, not the single permissible instance of the class.

like image 129
Nick Avatar answered Sep 23 '22 02:09

Nick