0

I'm using Magento for a client's store and they have a CRM that they use (Hubspot). Their request is that when a client makes a purchase via their one-step checkout page, that the contact information entered is also sent to their CRM.

The form action and whatnot is not what I'm looking for. Rather, I'm hoping someone could outline how I'll obtain the information they entered in the checkout. Do I need to have a success page and add the code to that success page?

Thanks!

Brian Schroeter
  • 1,583
  • 5
  • 22
  • 41

2 Answers2

0

You can use the app/design/frontend/base/default/template/checkout/success.phtml page. First, copy it to your own package & theme. Then you can use something like this:

$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$customerData = Mage::getModel('customer/customer')->load($customerId)->getData();
var_dump($customerData);

You should be able to pull what you need from there.

hth!

seanbreeden
  • 6,104
  • 5
  • 36
  • 45
0

Assuming that you are using their REST Api @ http://developers.hubspot.com/docs/methods/contacts/create_contact

You could add your api post to app/design/frontend/base/default/template/checkout/success.phtml (will only send info to crm for customer who places order from the frontend and not from admin)

You could also create a observer

In config.xml

    <events>
        <sales_order_place_after>
            <observers>
                <hubspot_create_customer_api>
                    <type>singleton</type>
                    <class>hubspotApi/observer</class>
                    <method>createCustomer</method>
                </hubspot_create_customer_api>
            </observers>
        </sales_order_place_after>

In your observer.php

class MageIgniter_HubspotApi_Model_Observer 
{

    public function createCustomer($event)
    {
        //$_order = $event->getOrder();
        //$_order->getCustomerFirstname();
        print_r($_order->getBillingAddress()); //get customer billing info
        print_r($_order->getBillingAddress()->getFirstname()); 

       //make curl call to post info to api
       //see http://mydons.com/using-curl-functions-in-magento-way/

    }
}

To learn how to create an custom module with an observer

Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62