1

I want to load a specific block in the transactional email only when the order is shipped. I want to load the block, buy using the following code:

{{block type='core/template' area='frontend' template='email/order/invoiceemailhead.phtml' order=$order}}

I already use that template to check the paymentmethod, but using;

<?php if($this->getOrder()->getPayment()->getMethodInstance()->getCode()=='cashondelivery'):?>

How can I also check if a order is shipped? What code do I need for this?

2 Answers 2

3

Try using below code to check if the order has shipped.

<?php $hasShipment = $this->getOrder()->getShipmentsCollection()->count();
if($hasShipment){
    .... // Do your stuff
}
?>
1

If you want to check if the order is completely shipped, the following function could help:

/**
 * @param Mage_Sales_Model_Order $order
 * @return boolean
 */
protected function isOrderCompletelyShipped(Mage_Sales_Model_Order $order)
{
    foreach ($order->getAllItems() as $item) {
        if ($item->getParentItemId()) {
            continue;
        }
        if ($item->getQtyShipped() !== $item->getQtyOrdered()) {
            return false;
        }
    }
    return true;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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