0

enter image description here

I am using Magento 1.9.2.3 and finding the QTY and PRICE being misaligned in New Order emails. I have had a look at the template for this email and it is calling a handle sales_email_order_items which I can find in sales.xml. This then calls the block email/order/items/order/default.phtml. I have had a look at this file but can't find why this is occurring?

<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>
<tbody>
<tr>
    <td class="cell-content product-info">
    <p class="product-name"><?php echo $this->escapeHtml($_item->getName()) ?></p>
    <p class="sku"><?php echo $this->__('SKU'); ?>: <?php echo $this->escapeHtml($this->getSku($_item)) ?></p>
        <?php if ($this->getItemOptions()): ?>
            <dl style="margin:0; padding:0;">
        <?php foreach ($this->getItemOptions() as $option): ?>
                        <dt><strong><em><?php echo $option['label'] ?></em></strong></dt>
                        <dd style="margin:0; padding:0 0 0 9px;">
                            <?php echo nl2br($option['value']) ?>
                        </dd>
                    <?php endforeach; ?>
                </dl>
            <?php endif; ?>
            <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
            <?php if ($addInfoBlock) :?>
                <?php echo $addInfoBlock->setItem($_item)->toHtml(); ?>
            <?php endif; ?>
            <?php echo $this->escapeHtml($_item->getDescription()) ?>
        </td>
        <td class="cell-content align-center"><?php echo $_item->getQtyOrdered()*1 ?></td>
        <td class="cell-content align-right">
            <?php if ($this->helper('tax')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('tax')->displaySalesBothPrices($_order->getStore())): ?>
                <?php if ($this->helper('tax')->displaySalesBothPrices($_order->getStore())): ?>
                    <span class="label"><?php echo Mage::helper('tax')->__('Excl. Tax'); ?>:</span>
                <?php endif; ?>
                <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'email', $_order->getStore())): ?>
                    <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
                <?php else: ?>
                    <?php echo $_order->formatPrice($_item->getRowTotal()) ?>
                <?php endif; ?>


                <?php if (Mage::helper('weee')->getApplied($_item)): ?>
                    <br />
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'email', $_order->getStore())): ?>
                        <small>
                            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br />
                            <?php endforeach; ?>
                        </small>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></small></span><br />
                        <?php endforeach; ?>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'email', $_order->getStore())): ?>
                        <small>
                            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br />
                            <?php endforeach; ?>
                        </small>
                    <?php endif; ?>

                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
                        <br />
                        <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
                    <?php endif; ?>
                <?php endif; ?>
            <?php endif; ?>


            <?php if ($this->helper('tax')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('tax')->displaySalesBothPrices($_order->getStore())): ?>
                <?php if ($this->helper('tax')->displaySalesBothPrices($_order->getStore())): ?>
                    <br /><span class="label"><?php echo Mage::helper('tax')->__('Incl. Tax'); ?>:</span>
                <?php endif; ?>
                <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
                <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'email', $_order->getStore())): ?>
                    <?php echo $_order->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
                <?php else: ?>
                    <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
                <?php endif; ?>
                <?php if (Mage::helper('weee')->getApplied($_item)): ?>
                    <br />
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'email', $_order->getStore())): ?>
                        <small>
                            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
                            <?php endforeach; ?>
                        </small>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
                        <?php endforeach; ?>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'email', $_order->getStore())): ?>
                        <small>
                            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
                            <?php endforeach; ?>
                        </small>
                    <?php endif; ?>

                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
                        <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
                    <?php endif; ?>
                <?php endif; ?>
            <?php endif; ?>
        </td>
    </tr>
<?php if ($_item->getGiftMessageId() && $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_item->getGiftMessageId())): ?>
    <tr>
        <td colspan="4" style=" border-bottom:2px solid #CCCCCC; padding:3px 9px;">
            <strong style="color:#444444; font-size:11px;"><?php echo $this->__('Gift Message') ?></strong>
            <?php echo $this->__('From:'); ?> <?php echo $this->escapeHtml($_giftMessage->getSender()) ?><br />
            <?php echo $this->__('To:'); ?> <?php echo $this->escapeHtml($_giftMessage->getRecipient()) ?><br />
            <strong><?php echo $this->__('Message:'); ?></strong><br /><?php echo $this->escapeHtml($_giftMessage->getMessage()) ?>
        </td>
    </tr>
<?php endif; ?>

  • I assume, based on the placement of SKU in this template that you are using the RWD theme or some custom child of it. In that theme, there are a LOT of things that can get placed in that last column where "Price" goes. That table cell's code is 70+ lines long. View your source on this document, make sure nothing is getting placed in that cell after the price like an empty div or span. – TJ Gamble at Jamersan Feb 14 '16 at 15:37
  • Yes, I am using the RWD theme. I have had a look at the source code and the table data '1' under QTY is aligned to the left when it should be centered. I couldn't find where that was coming from and there is no mention of 'left' in default.phtml – bondimedical Feb 14 '16 at 20:40
  • post the source of the default.phtml file that you reference above. – TJ Gamble at Jamersan Feb 14 '16 at 20:49
0

I believe it's only alignment issue.

To change the class name for th, you can go to template/email/order/items.phtml and change the class name of qty and price as required.

If you don't find template/email/order/items.phtml in your theme, then copy it from default/template/email/order/items.phtml and place it in your_theme/template/email/order/items.phtml then change accordingly.

Whatever class you set to <th> here should exactly match with the <td> class in your_theme/template/email/items/order/default.phtml file.

Hope this helps.

  • items.phtml is for the headings "QTY" and "PRICE". What is misaligned are the figures below the headings. – bondimedical Feb 15 '16 at 2:38
  • I understand, you have to change either this file's headings or change default.phtml file's td's class to align them together. – Adarsh Khatri Feb 15 '16 at 2:40
  • But both of them are center aligned? – bondimedical Feb 15 '16 at 2:42
  • I can see <td class="cell-content align-right"> in your code above. Also can you go to email, and do inspect element, then open those th and td node then take screenshot and add in to your qst plez. It's hard to tell what's going on from here. – Adarsh Khatri Feb 15 '16 at 2:43
  • It's difficult to post a screenshot because the source code is all squashed to the side. But I had a look at the alignment of the number under the heading "QTY" and it says "left". I am currently using the rwd theme and what I did was switch it to the default theme and the new order email looked perfectly aligned? – bondimedical Feb 15 '16 at 3:13
0

I contacted my Magento developer to fix this issue. He came to the conclusion that magento is supposed to inject the alignment while it generates the style but for some reason it isn't. All he did was add an extra style himself. So line 50 in default.phtml change to:

<td class="cell-content align-center" style="text-align:center"><?php echo $_item->getQtyOrdered()*1 ?></td>

Line 51 change to:

<td class="cell-content align-right" style="text-align:right">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.