I need to include product Customizable Options with price in order email template. For this I have modified the code and added the Customizable Options code. All are showing fine but the Customizable Options is not showing.
Here is my code added in
module-sales/view/frontend/templates/email/items.phtml
<?php $_order = $block->getOrder() ?>
<?php if ($_order): ?>
<?php $_items = $_order->getAllItems(); ?>
<table class="email-items" cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
<thead>
<tr>
<th class="item-info" align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">
<?= /* @escapeNotVerified */ __('Items') ?>
</th>
<th class="item-info" align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">
<?= /* @escapeNotVerified */ __('SKU') ?>
</th>
<th class="item-qty" align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">
<?= /* @escapeNotVerified */ __('Qty') ?>
</th>
<th class="item-price" align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">
<?= /* @escapeNotVerified */ __('Price') ?>
</th>
</tr>
</thead>
<?php foreach ($_items as $_item): ?>
<?php if (!$_item->getParentItem()) : ?>
<tbody>
<tr>
<td class="item-info"><?= /* @escapeNotVerified */ $_item->getName() ?>
<table class="item-info">
<?php
$options = $_item->getProductOptions();
$option_label="";
$option_value="";
if (isset($options['options']))
{
foreach ($options['options'] as $option)
{
$option_label= $option['label'];
$option_value= $option['value'];
}
}
?>
<tr>
<td><?= /* @escapeNotVerified */ $option_label?></td>
</tr>
<tr>
<td><?= /* @escapeNotVerified */ $option_value?></td>
</tr>
</table>
</td>
<td class="item-info" style="font-size:11px;"><?= /* @escapeNotVerified */ $_item->getSku() ?></td>
<td align="center" class="item-info" style="font-size:11px;"><?= /* @escapeNotVerified */ $_item->getQtyOrdered() ?></td>
<td class="item-info" style="font-size:11px;">Rs: <?= /* @escapeNotVerified */ $_item->getPrice() ?></td>
</tr>
</tbody>
<?php endif; ?>
<?php endforeach; ?>
<tfoot class="order-totals">
<tr class="subtotal">
<th style="padding-right:20px;font-weight:normal;font-size:11px;" align="right" colspan="3" scope="row">
<?= /* @escapeNotVerified */ __('Subtotal') ?>
</th>
<td>
<span style="font-size:11px;" class="price">Rs: <?= /* @escapeNotVerified */ $_order->getSubtotal() ?></span>
</td>
</tr>
<tr class="shipping">
<th style="padding-right:20px;font-weight:normal;font-size:11px;" align="right" colspan="3" scope="row">
<?= /* @escapeNotVerified */ __('Shipping & Handling') ?>
</th>
<td>
<span style="font-size:11px;" class="price">Rs: <?= /* @escapeNotVerified */ $_order->getShippingAmount() ?></span>
</td>
</tr>
<tr class="grand_total">
<th style="padding-right:20px;font-size:11px;" align="right" colspan="3" scope="row">
<strong><?= /* @escapeNotVerified */ __('Grant total') ?></strong>
</th>
<td>
<strong><span style="font-size:11px;" class="price">Rs: <?= /* @escapeNotVerified */ $_order->getGrandTotal() ?></span></strong>
</td>
</tr>
</tfoot>
</table>
<?php if ($this->helper('Magento\GiftMessage\Helper\Message')->isMessagesAllowed('order', $_order, $_order->getStore()) && $_order->getGiftMessageId()): ?>
<?php $_giftMessage = $this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessage($_order->getGiftMessageId()); ?>
<?php if ($_giftMessage): ?>
<br />
<table class="message-gift">
<tr>
<td>
<h3><?= /* @escapeNotVerified */ __('Gift Message for this Order') ?></h3>
<strong><?= /* @escapeNotVerified */ __('From:') ?></strong> <?= $block->escapeHtml($_giftMessage->getSender()) ?>
<br /><strong><?= /* @escapeNotVerified */ __('To:') ?></strong> <?= $block->escapeHtml($_giftMessage->getRecipient()) ?>
<br /><strong><?= /* @escapeNotVerified */ __('Message:') ?></strong>
<br /><?= $block->escapeHtml($_giftMessage->getMessage()) ?>
</td>
</tr>
</table>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
Can anyone let me know what's the issue and how to include custom options with price in this template.
Thanks.