Issue with unique_gateways Storing Multiple Values in Shopify Staff Notifications

Hello Shopify Community,

I have a question regarding the unique_gateways variable used in Shopify’s staff notification emails.

My company operates multiple online stores, one of which is on Shopify. Orders from Shopify are integrated into a system that centralizes order management for all our stores. This is done by configuring the staff notification emails with a specific template in Shopify.

We are encountering an issue where multiple payment methods are being concatenated into the unique_gateways field, which is causing errors in our centralized system, as it cannot correctly identify the payment method used.

I have two main questions:

  1. Under what conditions does unique_gateways store multiple values in one order? For instance, it appears that this issue may occur when a customer tries Shopify Payments first and then switches to Cash on Delivery, but I do not have definitive evidence, and it is difficult to reproduce the issue consistently.

  2. If unique_gateways contains multiple concatenated values, I would like to use only the last payment method. Based on my understanding, if unique_gateways is treated as an array, does the below code correctly extract the last value?

    {{ unique_gateways | last }}

Any help or guidance would be greatly appreciated. Thank you in advance!

@Pinot

Under what conditions does unique_gateways store multiple values in one order? For instance, it appears that this issue may occur when a customer tries Shopify Payments first and then switches to Cash on Delivery, but I do not have definitive evidence, and it is difficult to reproduce the issue consistently.

unique_gatewaysに、複数のペイメント情報が出力されてしまう発生条件が

複数あるかもしれないため、

あくまで、私が経験したことがある発生条件の説明になります。

お客様がチェックアウト画面で、最初に選んだ決済方法で決済に失敗し、その後、別の決済方法で決済に成功すると、unique_gatewaysが複数の支払方法を出力することがあるように見えています。

(※これが原因である可能性が高い、と言うだけで確証はありません。)

If unique_gateways contains multiple concatenated values, I would like to use only the last payment method. Based on my understanding, if unique_gateways is treated as an array, does the below code correctly extract the last value?

{{ unique_gateways | last }}

unique_gatewaysに、複数の支払方法がarray(配列)で格納されているのであれば、

{{ unique_gateways | last }}
で、ご希望の出力になるはずです。

しかし、arrayではなく、単純に文字列である場合は、少し大変です。

検証していませんが下記のようにすることで実現できる可能性があります。

{% assign payment_methods = "支払方法1,支払方法2,支払方法3,支払方法4" | split: ',' %}
{% assign last_payment_method = unique_payments %}
{% for peayment_method in payment_methods %}
  {% assign check_if_last_payment = unique_payments | split: peayment_method %}
  {% if check_if_last_payment.size == 1 and check_if_last_payment[0] != unique_payments %}
    {% assign last_payment_method = unique_payments | split: check_if_last_payment[0] | last %}
    {% break %}
  {% endif %}
{% endfor %}
{{ last_payment_method }}

{% assign payment_methods = “支払方法1,支払方法2,支払方法3,支払方法4” | split: ‘,’ %}

に、ストアに存在する全ての決済方法名をコンマ区切りで並べてください。

うまく機能すれば、

{{ last_payment_method }}

が、unique_gatewaysに文字列として格納された支払方法のうち、最後の1つを出力してくれるはずです。

ご参考まで。

(キュー田辺)

1 Like