【问题标题】:product name description company using cart sesssion magento使用购物车会话 magento 的产品名称描述公司
【发布时间】:2012-03-15 06:05:32
【问题描述】:

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

首先,当我单击购买产品时,它会重定向到结帐/购物车/,这意味着在此页面中的 cart.phtml 和 cart.php 我有产品名称 price qauntity 总计。好的,在我单击 Procced 结帐后,它会重定向到 checkout/onepage/ ... onepage.php 和 onepage.phtml

好的,现在我在 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: $from\r\n";
$headers .= "Content-type: text/html\r\n";


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

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

【问题讨论】:

    标签: magento mage


    【解决方案1】:

    结帐时可用的产品不包含所有属性。您应该从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>
    

    【讨论】:

    • 我只需要在 onpage.php 上获取我要购买的特定产品的产品名称公司名称。因为我从 onepage.php 页面发送电子邮件,所以我必须包含产品名称。能不能描述的更清楚一点
    • 我没有正确理解。如果您只获得购物车中可用的产品详细信息,您可以这样做。因为,产品名称、数量等已经可用。
    • 还没有完成。我想这是我的错误,我无法让你理解。好吧,让我给你完整的细节:$message = Email

      产品名称:$pro
    猜你喜欢
    • 1970-01-01
    • 2015-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 2023-03-10
    • 2018-06-03
    • 2020-10-06
    相关资源
    最近更新 更多