0

I am using the partial shipment case for multiple shipments and multiple tracking number against one order. For this i have added the new button (Leopard TN) on order view page. Actually when we click on this button its will send the shipment id and order id to the external page by using query string.

I have the order id in the external page by using the below code but i also need to get the shipment id in the next page.

$url = "http://www.exportleftovers.co/leopardmagento/api_call_get.php?order_id={$order->getId()}";
$this->_addButton('get_review_payment_update', array(
    'label'     => Mage::helper('sales')->__('Leopard TN'),
    'onclick' => "window.open('".$url."')"

)); 

Is anyone know how can i get the shipment id and send to the external page?

  • Which version you try? – Sohel Rana May 28 '16 at 7:10
  • magento 1.9.2.3 – Muneeb Ahmad May 28 '16 at 7:19
1

If you have $order object then you can easily find out shipping id. Here is an example:

if (!$order->canShip()) {
    foreach ($order->getShipmentsCollection() as $shipment) {
        $shipmentId = $shipment->getId();
    }
}

OR

if (!$order->canShip()) {
    $shipment = $order->getShipmentsCollection()->getFirstItem();
    $shipmentId = $shipment->getId();
}

Below Code is working fine:

foreach ($order->getShipmentsCollection() as $shipment) {
    $shipmentId = $shipment->getId();

    $url = "http://www.example.co/filename.php?order_id={$order->getId()}&shipment_id=$shipmentId";

    $this->_addButton('get_review_payment_update', array(
        'label' => Mage::helper('sales')->__('Leopard TN'),
        'onclick' => "window.open('" . $url . "')"

    ));

}

Thanks for the help.

  • Hi, i try both but i am unable to get the shipment id, i also mention code that i am using in view.php to get the order id. can you please explain how can i get the shipment id? – Muneeb Ahmad Jun 1 '16 at 4:53
  • you can get shipment_id if you created any shipment. – Sohel Rana Jun 1 '16 at 6:08
  • yes i create the shipment but didn't get any shipment id, basically i am working with partial shipment concept. – Muneeb Ahmad Jun 1 '16 at 6:15
  • I think you try this from 'Mage_Adminhtml_Block_Sales_Order_View' ? It's working for me. Could you show your code? – Sohel Rana Jun 1 '16 at 9:30
  • i edit you answer for final solution. thanks for help. – Muneeb Ahmad Jun 2 '16 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.