Jump to content

Where do I get Order, Product and Customer data?


iyousifi

Recommended Posts

Hi everyone,

 

I didn't have much luck looking in the forums, but my searching skills may need some work.

 

I am trying to call an API after order confirmation which will dispatch the order to a printer.

 

I've made a little test module that hooks on to displayOrderConfirmation, this works lovely. My challenge now is to dig out the data I need to send to the API. My problem is I have no idea which objects are available to me at this point.

 

I've tried dumping some objects to see what's what.

 

	$orderObject = $params['objOrder'];
	$customerObj = $params['objOrder']->getCustomer();
	$addressId = $orderObject->id_address_delivery;

	$address = new Address(intval($orderObject->id_address_delivery));

	$this->Dump($address, "ADDRESS");
	foreach ($params['objOrder']->getProducts() as $product)
	{
		$this->Dump($params, "PRODUCT");
	}
	$this->Dump($orderObject, "ORDER");

	$this->Dump($customerObj, "CUSTOMER");

 

So far I've found the delivery address, customer looks fine aswell. I have some trouble with finding the product names. I think they showed up when I just dumped the entire getProducts array.

 

So I guess my questions are:

  1. Am I getting the address correctly, is this best practice?
  2. Am I getting the customer data correctly?
  3. How do I get proper order and product data, specifically the product names, if possible attributes and price impact of those?

Thanks in advance and have a nice day :)

Link to comment
Share on other sites

Hi,

if you're on 1.5, try this first

 

$this->context->cart->address (for the address)

$this->context->cart->customer (for the customer, in case you need to get id, email, etc)

 

also, try var_dump on $orderObj to see if there is something else in it. I'm pretty much sure the contextual cart holds everything you need ;)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...