shipperhq / module-shipper

Base ShipperHQ Repo
Open Software License 3.0
21 stars 20 forks source link

Method to pull Delivery Dates #104

Closed pbaum83 closed 2 years ago

pbaum83 commented 2 years ago

What is the best way to pull the delivery/dispatch date from an order with the shipperhq module installed? Are there are any magic methods on the order interface or is helper that ships with the module to help with this? We have been using a SQL call to pull the values from the shipperhq_order_detail table which isn't ideal.

wsadasmit commented 2 years ago

Hi @pbaum83 ,

Here's a link to a document in our KB which mentions the following function you can use to do this: https://docs.shipperhq.com/integrate-shipperhq-order-management-fulfillment-service-magento/#Magento_2

The function getOrderCarrierGroupInfo($orderId) will output the pieces of data from that array included in the attached screenshot. This function can be found in “ShipperHQ\Shipper\Helper\CarrierGroup”.

For example for the delivery date you should be able to use the following piece of code: $carrierGroupInfo = $this->carrierGroupHelper->getOrderCarrierGroupInfo($order->getId()); $deliveryDate = $carrierGroupInfo['deivery_date'];

pbaum83 commented 2 years ago

Thank you for the update! Much Appreciated.

pbaum83 commented 2 years ago

Just in case anyone else uses this helper the return was an array when I implemented this code:

`$carrierGroupInfo = $this->carrierGroupHelper->getOrderCarrierGroupInfo($order->getId());

if (isset($carrierGroupInfo[0]['delivery_date']) === true) { $deliveryDate = $carrierGroupInfo[0]['delivery_date']; }`