1

Magento で請求書と電子メールの作成を自動化したいと考えています。請求書の作成は機能しているようですが、メールの部分は機能しています...

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

    try 
    {
        if(!$order->canInvoice())           {   
            Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
        }

        $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();

        if (!$invoice->getTotalQty()) {
            Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
        }

        $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
        $invoice->register();
        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($invoice)
            ->addObject($invoice->getOrder());
        $transactionSave->save();
    }       
    catch (Mage_Core_Exception $e) {

    }
}
4

1 に答える 1

1

私の反応がちょっと遅いことはわかっていますが、このページを見つけた他の人のために:

メールを送信するためのコードを追加する必要があります。登録行の後にこれを行います。


$invoice->register();
$invoice->getOrder()->setCustomerNoteNotify(true);
$invoice->getOrder()->setIsInProcess(true);
$invoice->sendEmail();

setCustomerNoteNotify は、顧客がメールを受信する必要があるかどうかを示すために使用されます。

setIsInProcess は注文状態を処理中に変更します

于 2014-05-23T13:27:32.307 に答える