gpt4 book ai didi

magento - 以编程方式发送运输/跟踪邮件

转载 作者:行者123 更新时间:2023-12-04 19:15:45 25 4
gpt4 key购买 nike

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

$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 后端验证发货一样。

非常感谢您的帮助。

最佳答案

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

关于magento - 以编程方式发送运输/跟踪邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9887198/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com