以编程方式发送运输/跟踪邮件 [英] Programmatically send shipping/tracking mail

查看:68
本文介绍了以编程方式发送运输/跟踪邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento 1.4中,我成功使用此代码将订单标记为完成"并向其中添加运送跟踪代码:

In Magento 1.4, I am successfully using this code to mark an order as Complete and add a shipping tracking code to it :

$order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);

if($order->canShip())
{
$itemQty =  $order->getItemsCollection()->count();
$ship = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
$ship = new Mage_Sales_Model_Order_Shipment_Api();
$shipmentId = $ship->create($increment_id);
}

$shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
$shipment_collection->addAttributeToFilter('order_id', $order_id);

foreach($shipment_collection as $sc) {
    $shipment = Mage::getModel('sales/order_shipment');
    $shipment->load($sc->getId());
    if($shipment->getId() != '') { 
        $track = Mage::getModel('sales/order_shipment_track')
                 ->setShipment($shipment)
                 ->setData('title', $type)
                 ->setData('number', $code)
                 ->setData('carrier_code', 'custom')
                 ->setData('order_id', $shipment->getData('order_id'))
                 ->save();
        }
} 

它正常工作,但是我找不到正确的代码,需要向客户发送货运确认邮件,就像您选中正确的框并在magento后端验证货运一样.

It is working properly, but I cannot find the right piece of code I need to send shipment confirmation mail to customer, as when you check the right box and validate shipping in magento backend.

非常感谢您的帮助.

推荐答案

                if($shipment){
                    if(!$shipment->getEmailSent()){
                        $shipment->sendEmail(true);
                        $shipment->setEmailSent(true);
                        $shipment->save();                          
                    }
                }   

这篇关于以编程方式发送运输/跟踪邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆