1

I have drupal 8 and commerce installed. The receipt email that is sent to the customers includes the final price of the product (with the promotion integrated). Is it possible to print the price of the product without the discount? I tried {{order_item.getUnitPrice}} but I still get the price with the discount:

I paste below my template:

    {#
/**
 * @file
 * Template for the order receipt.
 *
 * Available variables:
 * - order_entity: The order entity.
 * - billing_information: The billing information.
 * - shipping_information: The shipping information.
 * - payment_method: The payment method.
 * - totals: An array of order totals values with the following keys:
 *   - subtotal: The order subtotal price.
 *   - adjustments: An array of adjustment totals:
 *     - type: The adjustment type.
 *     - label: The adjustment label.
 *     - total: The adjustment total price.
 *     - weight: The adjustment weight, taken from the adjustment type.
 *   - total: The order total price.
 *
 * @ingroup themeable
 */
#}

<!--[if gte mso 9]>
        <style>
            .ol {
              width: 100%;
            }
        </style>
    <![endif]--><!--[if gte mso 9]><table width="600" cellpadding="0" cellspacing="0"><tr><td>
                    <![endif]-->
                    <table border="0" cellpadding="0" cellspacing="0" class="container600" style="width:calc(100%);max-width:calc(600px);margin: 0 auto;" width="100%">
    <tbody>
        <tr>
            <td style="text-align:left" width="100%">
            <table cellpadding="0" cellspacing="0" style="min-width:100%;" width="100%">
                <tbody>
                    <tr>
                        <td style="color:#000000; padding:30px"><img alt="" src="http://itb.aserver.gr/sites/default/files/logo_idryma_voulis.jpg" style="display: block;" width="180" /></td>
                    </tr>
                </tbody>
            </table>

            <table cellpadding="0" cellspacing="0" style="min-width:100%;" width="100%">
                <tbody>
                    <tr>
                        <td style="color:#58585a; padding:30px">
                        <h3>{{ 'Order #@number details:'|t({'@number': order_entity.getOrderNumber}) }}</h3>

                        <p style="font-family:Arial,sans-serif; font-size:14px;">Ευχαριστούμε! Η παραγγελία σας καταχωρήθηκε επιτυχώς.</p>
                        <h3>Στοιχεία παραγγελίας:</h3>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-bottom:20px">&nbsp;
                        <table border="1" cellpadding="0" cellspacing="0" class="smarttable" style="min-width:100%;" width="100%">
                            <thead>
                                <tr>
                                    <th scope="col" style="padding:5px; font-family: Arial,sans-serif; font-size: 14px; line-height:20px;line-height:30px">Έκδοση</th>
                                    <th scope="col" style="padding:5px; font-family: Arial,sans-serif; font-size: 14px; line-height:20px;line-height:30px">Ποσότητα</th>
                                    <th scope="col" style="padding:5px; font-family: Arial,sans-serif; font-size: 14px; line-height:20px;line-height:30px">Σύνολο</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for order_item in order_entity.getItems %}
                                    <tr>
                                        <td style="font-family:Arial,sans-serif; font-size:14px; line-height:20px; padding:5px; vertical-align:top">
                                            <span>{{ order_item.label }}</span>
                                        </td>
                                        <td style="font-family:Arial,sans-serif; font-size:14px; line-height:20px; padding:5px; vertical-align:top">
                                        <span>x {{ order_item.getQuantity|number_format }}</span>
                                        
                                        </td>
                                        <td style="font-family:Arial,sans-serif; font-size:14px; line-height:20px; padding:5px; vertical-align:top">
                                            <span style="float: right;">{{ order_item.getTotalPrice|commerce_price_format }} {{order_item.getUnitPrice}}</span>
                                         
                                        </td>
                                    </tr>
                                    {% endfor %}
                                <tr>
                                    <td colspan="2" style="font-family:Arial,sans-serif; font-size:14px; line-height:20px; padding:5px; vertical-align:top"><strong>Αξία</strong></td>
                                    <td><strong>{{ totals.total|commerce_price_format }}</strong></td>
                                </tr>
                                    {% for adjustment in totals.adjustments %}
                                        <tr>
                                            <td colspan="2" style="font-family:Arial,sans-serif; font-size:14px; line-height:20px; padding:5px; vertical-align:top">
                                            {{ adjustment.label }} 
                                            </td>
                                            <td>{{ adjustment.total|commerce_price_format }}</td>
                                        </tr>
                                        {% endfor %}
                                        <tr>
                                    <td colspan="2" style="font-family:Arial,sans-serif; font-size:14px; line-height:20px; padding:5px; vertical-align:top"> Σύνολο:</td>
                                    <td>{{order_entity.getTotalPrice|commerce_price_format}}</td>
                                </tr>
                                </tr>
                            </tbody>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <table border="1" cellpadding="0" cellspacing="0" class="smarttable" style="min-width:100%;" width="100%">
                            <thead>
                                <tr>
                                    <th scope="col" style="padding:5px; font-family: Arial,sans-serif; font-size: 14px; line-height:20px;line-height:30px">{{ 'Billing Information'|t }}</th>
                                    <th scope="col" style="padding:5px; font-family: Arial,sans-serif; font-size: 14px; line-height:20px;line-height:30px">{{ 'Shipping Information'|t }}</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>
                                {% if billing_information %}
                                 {% block billing_information %}
                                {{ billing_information }}
                                {% endblock %}
                               {% endif %}
                               </td>
                            <td>  
                            {% if shipping_information %}
                                {% block shipping_information %}
                                {{ shipping_information }}
                                {% endblock %}
                         {% endif %}
                         </td>
                            </tr>
                           
                    
                    </tr>
                    <tr>
                    <td>
                     <strong>{{ 'Selected Payment Method'|t }}</strong>
                    </td>
                    {# <td><strong>{{ 'Selected Shipping information'|t }}</strong></td> #}
                    </tr>
                    <tr rowspan="2">
                    <td>
                        {% if payment_method %}
                
                 
                  <br/>
                    {% block payment_method %}
                      {{ payment_method }}
                    {% endblock %}
                    {% endif %}
                  </td>
                  {# <td>
                    {% if shipping_information %}
                   <br/>
                                {% block shipping_information_2 %}
                                {{ shipping_information }}
                                {% endblock %}
                         {% endif %}
                  </td> #}
                </tr>
              
                </tbody>
            </table>

            <table cellpadding="0" cellspacing="0" style="min-width:100%;" width="100%">
                <tbody>
                    <tr>
                        <td style="background-color:#2c3949; color:#ffffff; min-width:100%; padding:30px" width="100%">
                        <p style="font-size:16px;line-height:20px;font-family:Arial,sans-serif;text-align:center;">&Iota;&Delta;&Rho;&Upsilon;&Mu;&Alpha; &Tau;&Eta;&Sigma; &Beta;&Omicron;&Upsilon;&Lambda;&Eta;&Sigma; &Tau;&Omega;&Nu; &Epsilon;&Lambda;&Lambda;&Eta;&Nu;&Omega;&Nu;</p>
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<!--[if gte mso 9]></td></tr></table>
                    <![endif]-->

<p>&nbsp;</p>
1

You could get the promotion value and add it back.

{% set promotions = order_item.getAdjustments(['promotion']) %}

{# assuming there is always one promotion, otherwise you'll want to loop here #}
{% set promotion_amount = promotions.0.getAmount.getNumber %}

{# since promotion is a negative number we have to substract to add back #}
{% set original_price = order_item.getUnitPrice - promotion_amount %}
{{ original_price }}
1

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.