Maybe you run into the same issue i had. I got emails, not containing the correct updated informations.
i figured out (Magento 1.7.2) that the Email for tracking is generated even before the tracking information was saved. Normally all works fine in default, but sometimes it happened, that the email sending is generated before the tracking is generated or updated.
What i were doing is to add an additional $this->save()
in app/code/core/Mage/Sales/Model/Order/Shipment.php
at the function addTrack
right before the return
statement.
For sure i didn't do this in the core file itself, i've cloned it into app/code/local/Mage/Sales/Model/Order/Shipment.php
My addTrack looks like this now:
public function addTrack(Mage_Sales_Model_Order_Shipment_Track $track)
{
$track->setShipment($this)
->setParentId($this->getId())
->setOrderId($this->getOrderId())
->setStoreId($this->getStoreId());
if (!$track->getId()) {
$this->getTracksCollection()->addItem($track);
}
/**
* Track saving is implemented in _afterSave()
* This enforces Mage_Core_Model_Abstract::save() not to skip _afterSave()
*/
$this->_hasDataChanges = true;
/**
* Added additional $this->save(); to have the new data for shippment
* tracking already in the Mage_Sales_Model_Order_Shipment object.
* If this would not happen, the tracking mails generated may have old
* or wrong data regarding carrier title.
*/
$this->save();
return $this;
}
EDIT 3nd May 2016:
Hi Scot,
in app/code/local/Mage/Sales/Model/Order/Shipment/Api/V2.php
and app/code/local/Mage/Sales/Model/Order/Shipment/Api.php
i've REMOVED $shipment->sendEmail($email, ($includeComment ? $comment : ''));
in the create() function at the try/catch block right after the ->save();
public function create($orderIncrementId, $itemsQty = array(), $comment = null, $email = false,
$includeComment = false
) {
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
/**
* Check order existing
*/
if (!$order->getId()) {
$this->_fault('order_not_exists');
}
/**
* Check shipment create availability
*/
if (!$order->canShip()) {
$this->_fault('data_invalid', Mage::helper('sales')->__('Cannot do shipment for order.'));
}
/* @var $shipment Mage_Sales_Model_Order_Shipment */
$shipment = $order->prepareShipment($itemsQty);
if ($shipment) {
$shipment->register();
$shipment->addComment($comment, $email && $includeComment);
if ($email) {
$shipment->setEmailSent(true);
}
$shipment->getOrder()->setIsInProcess(true);
try {
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
} catch (Mage_Core_Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
}
return $shipment->getIncrementId();
}
return null;
}
But i've added the email send in addTrack()
public function addTrack($shipmentIncrementId, $carrier, $title, $trackNumber)
{
$shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);
/* @var $shipment Mage_Sales_Model_Order_Shipment */
if (!$shipment->getId()) {
$this->_fault('not_exists');
}
$carriers = $this->_getCarriers($shipment);
if (!isset($carriers[$carrier])) {
$this->_fault('data_invalid', Mage::helper('sales')->__('Invalid carrier specified.'));
}
$track = Mage::getModel('sales/order_shipment_track')
->setNumber($trackNumber)
->setCarrierCode($carrier)
->setTitle($title);
$shipment->addTrack($track);
try {
$shipment->save();
$track->save();
if(!$shipment->getEmailSent()) {
$shipment->sendEmail(true, $shipment->getCommentsCollection());
$shipment->setEmailSent(true);
$shipment->save();
}
} catch (Mage_Core_Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
}
return $track->getId();
}
Hope i didn't mix up something again.
Don't change base files;
create copy of
/app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
To
/app/design/frontend/default/default/template/checkout/onepage/shipping_method/available.phtml
Now add line
<?php echo $this->getChildHtml('form.additional.info'); ?>
At last in phtml.
Best Answer
I found out problem.
I had placed custom mail block "shippingmail.phtml" under my custom template.
Once i changed this this to default template it worked
Ie.
Changed to this: