Hide part in order confirmation based on payment method

asalklar
New Member
5 0 0

Hi everybody,

I am currently customizing my order confirmation template. So far I am doing just great. However, I am wondering if there is the possibility to hide/show a certain static text in the template based on the chosen payment method by the user. 

 

For example I do have the payment method pre-payment. I now want to show in the order confirmation the bank details, etc. but only if the user has chosen the payment method pre-payment. If he has chosen another one, I would like to hide this part.

Is this possible and if yes, how to implement this?

I look forward to your help and answers.

David

Replies 7 (7)
DP_Development
Pathfinder
82 11 17

It should work, if you write your own Liquid code using the transaction object. It contains a payment_details object to identify the payment method. With this objects you should be able to show the bank details only if the paypment method was pre-payment. 

Software Engineer and Frontend Developer
Fast, cheap and straightforward solutions! Shall I do this for you? Just send me a message!
Please click on like and "accepted solution" if my answer helped you.
asalklar
New Member
5 0 0
Thanks for your answer. Could you make an example on this might look like? I am new to this and I am only able to make basic stuff. I would really appreciate it.
DP_Development
Pathfinder
82 11 17

I just checked it again but the payment_details object is only available through notifications. You should use this object instead:

{{ transaction.gateway }}

 This should do the trick if you use it with simple liquid if else conditions. 

Software Engineer and Frontend Developer
Fast, cheap and straightforward solutions! Shall I do this for you? Just send me a message!
Please click on like and "accepted solution" if my answer helped you.
asalklar
New Member
5 0 0

Thanks again for your help. so if I add 

{{ transaction.gateway }}

into the notification template it should work? Or how do I check whether it is pre-payment or not?

 

Sorry to ask again but I am bloody news to this.

 

 

DP_Development
Pathfinder
82 11 17

No, because the notification templates have only relevance for notifications. But the object transaction.payment_details is only accessable through the notifications, so you wont be able to use it in the liquid order confirmation page at the end of the order. This is why i posted transaction.gateway as an accessable object. 

I think you have at least two quite good options:

1) modify the order confirmation page

2) modify the order notification mail

In both cases you will have to write if/else conditions which will show/not show your bank details in dependency of the payment method.

Software Engineer and Frontend Developer
Fast, cheap and straightforward solutions! Shall I do this for you? Just send me a message!
Please click on like and "accepted solution" if my answer helped you.
asalklar
New Member
5 0 0

Yes, I understand this And I want to modify the notification template - this is what I am working on almost all day already. But just in terms of design and simple variable insertion. 

In the notification template I do have a section where the bank details are written in statis. This part I want to hide when the payment is pre-payment. You can see in the attachment the only two payment methods (manual ones) I do have installed in my shop. 

 

So now I need a statement to say that if the payment method is "Barzahlung bei Abholung" the static text for the bank details is shown. Else if it should not be displayed. 

asalklar_0-1636223884708.png

If I understand correctly the statment must be something like this

{{ if transaction.payment_details = ???? }}
STATIC TEXT
{{ elseif }}
[blank]
{{ endif }}

 

Or how should this look like in the notification template? How can I select the payment method through the statement?

DP_Development
Pathfinder
82 11 17

You can use the transaction object only if you iterate through it:

{% for transaction in transactions %}

When iterating through the transaction array, you can check, if transaction.gateway gives you the specific term for preorder (it will, but I dont know the exact phrase). If the specific text value is in transaction.gateway you can show your bank details, otherwise not.

Software Engineer and Frontend Developer
Fast, cheap and straightforward solutions! Shall I do this for you? Just send me a message!
Please click on like and "accepted solution" if my answer helped you.