交易电子邮件中的php变量/对象

时间:2016-07-07 16:42:34

标签: php email magento templates

我有一封交易电子邮件,位于此处: 系统>交易电子邮件>装运更新

以下是货件更新中的内容:

{{block type="core/template" template="email/header.phtml"}}
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{htmlescape var=$order.getCustomerName()}},</h1>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
    Your order # {{var order.increment_id}} has been shipped and now has a status of <strong>{{var order.getStatusLabel()}}</strong>.
</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">You can check the status of your order by 

        <a href="https://mystore.narvar.com/mystore/tracking/fedex?tracking_numbers=<?php echo $this->escapeHtml($_track->getTrackNumber()) ?>">Find tracking here</a>.


<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">{{var comment}}</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
{{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}
</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
{{block type='core/template' area='frontend' template='email/order/shipment/track.phtml' shipment=$shipment order=$order}}
</p>
<p style="font-size:12px; line-height:16px; margin:0;">
    If you have any questions, please feel free to contact us at
    <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a>
    or by phone at {{config path='general/store_information/phone'}}.
</p>
{{block type="core/template" template="email/footer.phtml"}}

我有一个与上面的电子邮件相关的块类型和文件,它位于:/email/order/shipment/track.phtml

<?php $_shipment=$this->getShipment() ?>
<?php $_order=$this->getOrder() ?>
<?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?>
<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
    <thead>
        <tr>
            <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Shipped By') ?></th>
            <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking Number') ?></th>
            <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking URL') ?></th>
        </tr>
    </thead>
    <tbody>
    <?php $i=0; foreach ($_shipment->getAllTracks() as $_item): $i++ ?>
        <tr <?php echo $i%2?'bgcolor="#F6F6F6"':'' ?>>
            <td align="left" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_item->getTitle()) ?></td>
            <td align="center" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_item->getNumber());//getConsignmentNumber()) ?></td>
            <?php $trackUrl = "https://mystore.narvar.com/mystore/tracking/fedex?tracking_numbers=";?>
            <td align="center" valign="top" style="padding:3px 9px"><a href="<?php echo $trackUrl. $_item->getNumber();?>" target="_blank"><?php echo $trackUrl. $_item->getNumber();?></a></td>        </tr>
    <?php endforeach ?>
    </tbody>
</table>
<?php endif; ?>

我将track_number存储在我们的数据库中。请看下面的图片。

enter image description here

我的问题是如何在此网址末尾设置我的变量,这些变量将转到第三方网站。

<a href="https://mystore.narvar.com/mystore/tracking/fedex?tracking_numbers=<?php echo $this->escapeHtml($_track->getTrackNumber()) ?>">Find tracking here</a>.

1 个答案:

答案 0 :(得分:0)

试试这个:

$order = $this->getData('order');

正如http://www.webspeaks.in/2011/06/customize-new-order-email-template-in-magento.html

所述