Domanda

Sto aggiungendo un PDF a tutte le mie e-mail di vendita al momento, ma voglio solo che questi PDF siano aggiunti se l'ordine contiene almeno un prodotto virtuale. Come posso implorare questo nella seguente dichiarazione?

    if (Mage::getStoreConfig('sales_email/' . $configPath . '/attachpdf', $storeId)) {

        //Create Pdf and attach to email - play nicely with PdfCustomiser

        $pdf = Mage::getModel('emailattachments/order_pdf_order')->getPdf(array($order));
        Mage::helper('emailattachments')->addAttachment(
            $pdf, $mailTemplate, $this->getOrderAttachmentName($order)
        );
    }
.

È stato utile?

Soluzione

    $isVirtual = false;
    foreach ($order->getAllItems() as $items) {            
        if ($items->getProductType() == 'virtual') {
            $isVirtual = true; 
            break;
        }
    }

    if (Mage::getStoreConfig('sales_email/' . $configPath . '/attachpdf', $storeId) && $isVirtual) {

        //Create Pdf and attach to email - play nicely with PdfCustomiser

        $pdf = Mage::getModel('emailattachments/order_pdf_order')->getPdf(array($order));
        Mage::helper('emailattachments')->addAttachment(
            $pdf, $mailTemplate, $this->getOrderAttachmentName($order)
        );
    }
.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top