产品名称描述公司使用cart-session-magento



我试图在onepage.php中获取产品详细信息,但失败了。我已经尝试了很多代码,但我没有得到它。我需要使用会话得到它吗?有人知道代码吗?我该如何在onepage.php页面中获取产品详细信息?

好的,首先当我点击购买产品时,它会重定向到checkout/cart/,这意味着cart.html和cart.php。在这个页面中,我有产品名称price qauntity grand-total。好的,在我点击Procced以结账后,它重定向到checkout/onepage/。。。onepage.php和onepage.html

好的,现在我在onepage.php中设置了一封电子邮件,每当用户在加载onepage.php时点击购物车页面上的Procced to checkout按钮时,它就会发送电子邮件。

现在我想在电子邮件中添加产品详细信息,如产品名称数量公司名称。在这里,我已经完成了所有步骤,但无法获得产品的详细信息。该产品将是用户选择进行结账的产品。

here is my simple email template:
    $to = "$email";
    $from = "test@test.com";
    $subject = "email test";
    //begin of HTML message
    $message = <<<EOF
<html>
  <body bgcolor="#DCEEFC">
    <center>
        <b>email test</b> <br>
        <h1><font color="red">Your Coupon Code:</font>$letters$random_chars<br></h1>
<h1>Product Name : $productname</h1>
<h1>Company Name : $comname</h1>
    </center>
  </body>
</html>
EOF;
$headers  = "From: $fromrn";
$headers .= "Content-type: text/htmlrn";

mail($to, $subject, $message, $headers);

好吧,所以在这里我已经发送了电子邮件,它的工作原理很好,只需要包括产品名称和公司名称,但我不知道我将如何获得它?

结账时可用的产品不包含所有属性。您应该定义config.xml 的收银台/购物车部分的可用属性

<sales>
  <quote>
    <item>
      <product_attributes>
        <product_attribute_1/>
        <product_attribute_2/>
      </product_attributes>
    </item>
  <quote>
<sales>

这个把戏属于Brim LLC的Tim Milhouse

编辑:在事务性电子邮件中包含变量。。。假设您创建了一个产品属性,名称为product_origin

  • 创建事务性电子邮件模板并进行如下修改:
<html>
   <h1>Dear {{htmlescape var=$order.getCustomerName()}}</h1>
   <p>Thank you choosing {{var store.getFrontendName()}}</p>
   <h2>Here is the order details</h2>
   {{block type='core/template' area='frontend' template='/emails/product_info.phtml' order=$order}}
</html>
  • 创建产品模板product_info.phtml
# File path : /app/design/frontend/[YOUR_NAMESPACE]/[YOUR_THEME]/template/emails/product_info.phtml
 <?php $_order = $this->getOrder(); ?>
 <table>
   <tr>
     <td>Product Name</td>
     <td>Price</td>
     <td>Product Origin (Attribute)</td>
   </tr>
   <?php foreach($_order->getAllItems() as $_item): ?>
   <tr>
     <td><?php echo $_item->getName() ?></td>
     <td><?php echo $_order->formatPrice($_item->getPrice()) ?></td>
     <td>
        <?php
           $_product = Mage::getModel('catalog/product');
           $_product ->load($_item->getProductId());
           echo $_product->getProductOrigin(); // product attribute, if attribute name productorigin, therefore should be getProductorigin
        ?>
     </td>
   </tr>
   <?php endforeach ?>
 </table>

最新更新