Update the POS and mobile receipt email notification for cash rounding

If your store uses customized notification templates, then you might need to update your POS and mobile receipt email notification manually to ensure that it displays cash rounding on the receipt.

These changes require familiarity with the code that's used in Shopify's notification templates. If your templates are highly customized and you're not sure how to apply the necessary changes, then contact the developer that made the changes or click Revert to default to restore your template to its original state. When you revert to default, all of your customizations are removed, but the default template ensures that you have the most current template version.

Update the POS and mobile receipt email notification

You can update the POS and mobile receipt notification to display the net cash rounding amount from payment and refund transactions, along with the rounded total amount in the receipt.

Steps:

  1. From your Shopify admin, go to Settings > Notifications.

  2. Click Customer notifications.

  3. In the Point of Sale section, click POS and mobile receipt.

  4. Click Edit code.

  5. Add logic to calculate the net cash rounding amount (net_transaction_amount_rounding).

    1. Locate the first {% assign transaction_size = 0 %} code line.
    2. Replace the existing code block with the following code block:
{% assign transaction_size = 0 %}
      {% assign transaction_amount = 0 %}
      {% assign net_transaction_amount_rounding = 0 %}
      {% assign authorized_amount = 0 %}
      {% assign has_refunds = false %}
      {% assign shopify_pay_captured = false %}
      {% assign shop_cash_offers_captured = false %}
      {% for transaction in transactions %}
        {% if transaction.status == "success" %}
          {% if transaction.kind == "sale" or transaction.kind == "capture"  %}
              {% if transaction.payment_details.credit_card_company %}
                {% assign shopify_pay_captured = true %}
              {% endif %}
              {% if transaction.gateway == "shop_cash" or transaction.gateway == "shop_offer" %}
                {% assign shop_cash_offers_captured = true %}
              {% endif %}
              {% assign transaction_size = transaction_size | plus: 1 %}
              {% assign transaction_amount = transaction_amount | plus: transaction.amount %}
              {% if transaction.amount_rounding != nil %}
                {% assign net_transaction_amount_rounding = net_transaction_amount_rounding | plus: transaction.amount_rounding %}
              {% endif %}
          {% elsif transaction.kind == "refund" or transaction.kind == "change" %}
            {% assign transaction_size = transaction_size | plus: 1 %}
            {% assign transaction_amount = transaction_amount | minus: transaction.amount %}
            {% assign has_refunds = true %}
            {% if transaction.amount_rounding != nil %}
              {% assign net_transaction_amount_rounding = net_transaction_amount_rounding | minus: transaction.amount_rounding %}
            {% endif %}
          {% elsif transaction.kind == "authorization" %}
            {% assign authorized_amount = authorized_amount | plus: transaction.amount %}
          {% endif %}
        {% endif %}
      {% endfor %}

      {% # Add shop cash/offer transactions to totals if shopify pay is captured and shop cash/offer is not captured yet %}
      {% if shopify_pay_captured == true and shop_cash_offers_captured == false %}
        {% for transaction in transactions %}
        {% if transaction.status == "success" %}
          {% if transaction.kind == "authorization" and transaction.gateway == "shop_cash" or transaction.gateway == "shop_offer" %}
              {% assign transaction_size = transaction_size | plus: 1 %}
              {% assign transaction_amount = transaction_amount | plus: transaction.amount %}
              {% if transaction.amount_rounding != nil %}
                {% assign net_transaction_amount_rounding = net_transaction_amount_rounding | plus: transaction.amount_rounding %}
              {% endif %}
          {% endif %}
        {% endif %}
      {% endfor %}
      {% endif %}
  1. Display the total cash rounding adjustment and rounded amount in receipt.
    1. Locate the <table class="row subtotal-table subtotal-table--total"> code line.
    2. Replace the existing code block with the following code block which utilizes values in net_transaction_amount_rounding and amount_rounding to compute the rounded amounts.
<table class="row subtotal-table subtotal-table--total">
  {% if payment_terms and payment_terms.automatic_capture_at_fulfillment == false or b2b? %}
    {% assign next_payment = payment_terms.next_payment %}
    {% assign due_at_date = next_payment.due_at | date: "%b %d, %Y" %}
    {% if net_transaction_amount_rounding != 0 %}

      <tr class="subtotal-line">
        <td class="subtotal-line__title">
          <p> <span>Total</span></p>
        </td>
        <td class="subtotal-line__value">
        <strong>{{ total_price | money_with_currency }}</strong>
        </td>
      </tr>

      {% if total_discounts > 0 %}
        <tr class="subtotal-line">
          <td></td>
          <td class="subtotal-line__value total-discount">
            You saved <span class="total-discount--amount">{{ total_discounts | money }}</span>
          </td>
        </tr>
      {% endif %}
      <tr><td colspan="2" class="subtotal-table__line"></td></tr>
      <div class="subtotal-line__value-small">
        <tr class="subtotal-line">
          <td class="subtotal-line__title">
            <p> <span>Cash rounding</span> </p>
          </td>
          <td class="subtotal-line__value">
            <strong>{% if net_transaction_amount_rounding < 0 %}-{% endif %} {{ net_transaction_amount_rounding | abs | money }}</strong>
          </td>
        </tr>
      </div>
      <tr><td colspan="2" class="subtotal-table__line"></td></tr>
    {% endif %}

    <tr class="subtotal-line">
      <td class="subtotal-line__title">
        <p><span>Total paid today</span></p>
      </td>
      <td class="subtotal-line__value">
        <strong>{{ transaction_amount | plus: net_transaction_amount_rounding | money_with_currency }}</strong>
      </td>
    </tr>

    <div class="payment-terms">
      {% assign next_amount_due = total_price %}
      {% if next_payment %}
        {% assign next_amount_due = next_payment.amount_due %}
      {% endif %}

      {% if payment_terms.type == 'receipt' %}
        <tr class="subtotal-line">
          <td class="subtotal-line__title">
            <p><span>Total due on receipt</span></p>
          </td>
          <td class="subtotal-line__value">
            <strong>{{ next_amount_due | money_with_currency }}</strong>
          </td>
        </tr>
      {% elsif payment_terms.type == 'fulfillment' %}
        <tr class="subtotal-line">
          <td class="subtotal-line__title">
            <p><span>Total due on fulfillment</span></p>
          </td>
          <td class="subtotal-line__value">
            <strong>{{ next_amount_due | money_with_currency }}</strong>
          </td>
        </tr>
      {% else %}
        <tr class="subtotal-line">
          <td class="subtotal-line__title">
            <p><span>Total due {{ due_at_date }}</span></p>
          </td>
          <td class="subtotal-line__value"><strong>{{ next_amount_due | money_with_currency }}</strong></td>
        </tr>
      {% endif %}
    </div>
    {% if total_discounts > 0 and net_transaction_amount_rounding == 0 %}
      <tr class="subtotal-line">
        <td></td>
        <td class="subtotal-line__value total-discount">
          You saved <span class="total-discount--amount">{{ total_discounts | money }}</span>
        </td>
      </tr>
    {% endif %}
  {% else %}
    <tr class="subtotal-line">
      <td class="subtotal-line__title">
        <p> <span>Total</span></p>
      </td>
      <td class="subtotal-line__value">
        <strong>{{ total_price | money_with_currency }}</strong>
      </td>
    </tr>

    {% if total_discounts > 0 %}
      <tr class="subtotal-line">
        <td></td>
        <td class="subtotal-line__value total-discount">
          You saved <span class="total-discount--amount">{{ total_discounts | money }}</span>
        </td>
      </tr>
    {% endif %}

    {% if net_transaction_amount_rounding != 0 %}
      <tr><td colspan="2" class="subtotal-table__line"></td></tr>
      <div class="subtotal-line__value-small">
        <tr class="subtotal-line">
          <td class="subtotal-line__title">
            <p><span>Cash rounding</span></p>
          </td>
          <td class="subtotal-line__value">
            <strong>{% if net_transaction_amount_rounding < 0 %}-{% endif %} {{ net_transaction_amount_rounding | abs | money }}</strong>
          </td>
        </tr>
      </div>

      {% if financial_status == 'paid' %}
        <tr class="subtotal-line">
          <td class="subtotal-line__title">
            <p> <span>Paid</span> <br>
              <small>{{ gateway | capitalize }}</small>
            </p>
          </td>

          <td class="subtotal-line__value">
            <strong>{{ transaction_amount | plus: net_transaction_amount_rounding | money_with_currency }}</strong>
          </td>
        </tr>

      {% endif %}
    {% endif %}

    {% if transaction_amount != total_price and payment_terms == nil%}
      {% if transaction_amount == 0 and authorized_amount > 0 and has_refunds == false %}
      {% else %}
        <div class="payment-terms">
          <tr class="subtotal-line">
            <td class="subtotal-line__title">
              <p><span>Total paid today</span></p>
            </td>

            <td class="subtotal-line__value">
              <strong>{{ transaction_amount | plus: net_transaction_amount_rounding | money_with_currency }}</strong>
            </td>
          </tr>
        </div>
      {% endif %}
    {% endif %}
  {% endif %}
</table>

{% unless payment_terms %}
  {% if transaction_size > 1 or transaction_amount < total_price %}
    <table class="row subtotal-table">
      <tr><td colspan="2" class="subtotal-table__line"></td></tr>
      <tr><td colspan="2" class="subtotal-table__small-space"></td></tr>

      {% for transaction in transactions %}
        {% assign amount_rounding = 0 %}
        {% if transaction.amount_rounding != 0 %}
          {% assign amount_rounding =  transaction.amount_rounding %}
        {% endif %}
        {% if transaction.status == "success" and transaction.kind == "capture" or transaction.kind == "sale" %}
          {% if transaction.payment_details.gift_card_last_four_digits %}
            {% capture transaction_name %}Gift card (ending with {{ transaction.payment_details.gift_card_last_four_digits }}){% endcapture %}
          {% elsif transaction.payment_details.credit_card_company %}
            {% capture transaction_name %}{{ transaction.payment_details.credit_card_company }} (ending in {{ transaction.payment_details.credit_card_last_four_digits }}){% endcapture %}
          {% else %}
            {% capture transaction_name %}{{ transaction.gateway_display_name }}{% endcapture %}
          {% endif %}

          <tr class="subtotal-line">
            <td class="subtotal-line__title">
              <p> <span>{{transaction_name}}</span> </p>
            </td>
            <td class="subtotal-line__value">
              <strong>{{ transaction.amount | plus: amount_rounding | money }}</strong>
            </td>
          </tr>
        {% elsif shopify_pay_captured and shop_cash_offers_captured == false and transaction.kind == "authorization" and transaction.gateway == "shop_cash" or transaction.gateway == "shop_offer" %}
          {% capture transaction_name %}{{ transaction.gateway_display_name }}{% endcapture %}
          <tr class="subtotal-line">
            <td class="subtotal-line__title">
              <p> <span>{{transaction_name}}</span> </p>
            </td>
            <td class="subtotal-line__value">
              <strong>{{ transaction.amount | plus: amount_rounding | money }}</strong>
            </td>
          </tr>
        {% endif %}

        {% if transaction.kind == 'refund' %}
          {% if transaction.payment_details.gift_card_last_four_digits %}
            {% assign refund_method_title = transaction.payment_details.type %}
          {% elsif transaction.payment_details.credit_card_company %}
            {% assign refund_method_title = transaction.payment_details.credit_card_company %}
          {% else %}
            {% assign refund_method_title = transaction.gateway_display_name %}
          {% endif %}

          <tr class="subtotal-line">
            <td class="subtotal-line__title">
              <p> <span>Refund</span> <br>
                <small>{{ refund_method_title | replace: '_', ' ' | capitalize }}</small>
              </p>
            </td>
            <td class="subtotal-line__value">
              <strong>- {{ transaction.amount | plus: amount_rounding | money }}</strong>
            </td>
          </tr>

        {% endif %}
      {% endfor %}
    </table>
  {% endif %}

  {% if total_outstanding > 0 %}
    <table class="row subtotal-table">
      <tr class="subtotal-line">
        <td class="subtotal-line__title">
          <p><span>Balance due</span></p>
        </td>
        <td class="subtotal-line__value">
          <strong>{{ total_outstanding | money }}</strong>
        </td>
      </tr>
    </table>
  {% endif %}
{% endunless %}
Can’t find the answers you’re looking for? We’re here to help.