Customize order confirmation email to show payment method details

Customize order confirmation email to show payment method details

MikeWeb
Visitor
2 0 2

Hello! Looking to customize the order confirmation email
Familiar with HTML but not so familiar with liquid. 

I know I would go to
Admin -> Settings -> Notifications -> Order confirmation -> Edit code

 

I imagine it's related to

 

transaction_payment_details object
credit_card_company string
credit_card_last_four_digits string
credit_card_number string
gift_card string

But I don't know how to insert this information into the Order Confirmation code so that the buyer receives the card company and last four digits of the card used for the order in their email.

I also only want this specific information to be included in order confirmations where a credit card is used, and not for manually collected payments.

In the order confirmation email is the button "View order", when the buyer goes to View order it shows the Card company logo, card name used and last four digits, so perhaps the same relevant goes is in the View order page, but I can't locate where in my theme files this page is or this bit of code.

Any info is appreciated. Thank you!
Replies 3 (3)

PaulNewton
Shopify Partner
7721 678 1625

Use the orders transaction object and it's sub properties

https://shopify.dev/docs/api/liquid/objects/order#order-transactions   

 

https://www.google.com/search?q=shopify+liquid+credit+cart+last+4+digits 

https://stackoverflow.com/questions/67768209/how-do-i-print-the-last-4-numbers-of-a-credit-card-on-the-templates-customers-or  

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


MikeWeb
Visitor
2 0 2

Thanks Paul for the reply.

 

I tried inserting into the Order Confirmation Code

{% for transaction in order.transactions %}
card type: {{ transaction.payment_details.credit_card_company }} <br/>
card xxxx: {{ transaction.payment_details.credit_card_number }} <br/>
{% endfor %}


As well as trying (not sure if it makes a difference, didn't notice any)

{% for transaction in order.transactions %}
card type: {{ transaction_payment_details.credit_card_company }} <br/>
card xxxx: {{ transaction_payment_details.credit_card_number }} <br/>
{% endfor %}

In the preview I don't see anything so I thought maybe I should test with a credit card purchase on my site, so I then placed a test order on my site $1 credit card purchase, but it doesn't appear to be working.

Is there something else I should be doing or a certain exact spot in the line of the code I should be inserting this into?

Also how would I make it so this only appears for credit card payments, as opposed to manually collected payment methods which have no credit card info?

Oddly when I did do a manual payment order (no credit card info added), in the order confirmation it shows the following (see attached screenshot image).
where it shows
card type: 
card xxxx:
Manual
No payment details with the credit card test order though.

Screen Shot 2023-12-17 at 6.41.03 PM.png

CEC_Colorado
Visitor
1 0 0

I am trying to get the same thing. Ours shows the type of card but no digits. I haven't worked on code since before CSS became standard so I am not as savvy. This is what my customers see:

CEC_Colorado_0-1741131143614.png

And here is the code I am manipulating: 

CEC_Colorado_1-1741131198431.png

Any help is greatly appreciated.