2016-07-27 99 views

回答

2

我將向您展示如何添加額外的產品屬性值以及訂購商品選項和自定義選項以訂購電子郵件和發票電子郵件。

這是應該的訂單和發票的電子郵件的工作就是讓代碼顯示的附加產品屬性:

$productId = $_item->getProduct()->getId(); //for order emails 
//$productId = $_item->getProductId(); //for invoice emails 
$product = Mage::getModel('catalog/product')->load($productId); 
$attributes = $product->getAttributes(); 

//Get a list of all PRODUCT ATTRIBUTES you want to show in this array... 
$dispAttribs = array('hardrive', 'memory', 'processor'); 

foreach ($attributes as $attribute) {  
     $attributeCode = $attribute->getAttributeCode(); 
     if(!in_array($attributeCode, $dispAttribs)) continue; 
     $label = $attribute->getFrontend()->getLabel($product); 
     $value = $attribute->getFrontend()->getValue($product); 
     echo "<br /><strong>" . $label . ":</strong> " . $value; 
} 

對於從項目顯示自定義選項和/或項目的選項,使用:

foreach($this->getItemOptions() as $opt) { 
    if(isset($opt['option_id'])) { //for CUSTOM OPTIONS 
      echo "<strong>" . $opt['label'] . ":</strong> ". $opt['option_value'] . "<br />"; 
    } else { //for ITEM OPTIONS 
      echo "<strong>" . $opt['label'] . ":</strong> ". $opt['value'] . "<br />"; 
    } 
} 

對於將代碼添加到訂單電子郵件,其中的代碼應該去的文件是:

app/design/frontend/base/default/template/email/order/items/order/default.phtml 

對於添加代碼發票的電子郵件,其中的代碼應該去的文件是:

app/design/frontend/base/default/template/email/order/items/invoice/default.phtml 

相反基地/默認的,你可以把它放在你的自定義主題的位置這是顯而易見的。

+0

它的作品就像一個魅力,謝謝哈桑ALi – Robert

+0

你能告訴我一些東西嗎?無論如何要把它放在交易電子郵件中?像{{var items_productSerialDescription}}? – Robert

+0

請閱讀https://www.yireo.com/tutorials/magento/magento-theming/1670-customizing-magento-email-templates這裏是跨國電子郵件的解決方案。 –

相關問題