Jump to content

Preferred way to get Carrier from Order Id


Recommended Posts

Hi there!

I am creating a very simple module to extend email templating functionalities.
I am trying to understand how Controllers, Adapters, Core and so on are working together.

 

I want to get the carrier used given an order ID. What would be the best way to do this?
From Prestashop official documentation, classes and Adapters are going to be removed in future major versions: https://devdocs.prestashop.com/1.7/development/architecture/introduction/

So which would be the best way, in a hook to do that?

I am trying to use the GetOrderForViewing in Core Domain, but I am not really sure how to use this... At the moment when I build the object, it only has the orderId, how should I run the query?
 

Thanks in advance. If there is a documentation somewhere which explains this, sorry in advance, I couldn't find it

Edited by theodiablo (see edit history)
Link to comment
Share on other sites

Given the fact you have the order ID

$order = new Order((int) $order_id);

if (Validate::isLoadedObject($order)) {
	// We verify the order exists and use the $order->id_carrier

	// Your code here
}

The old stack will not be replaced immediately. Actually they make it step by step because it's a ton of work.
So for the moment, this is the way.

  • 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...