Hide certain payment method

Hide certain payment method

biptu
Shopify Partner
8 0 0

I want to make an app with payment customization extension to hide a certain payment method (COD) for some customers. 

 

The customers are those who has an order with HIDE tag in last 30 days. How to achieve this.

Please help me on this  @garyrgilbert 

Reply 1 (1)

garyrgilbert
Shopify Partner
432 41 190

Hi @bipu,

 

Sorry for the late reply. 

 

first I would suggest following along with the payment customization tutorial that shopify has.

https://shopify.dev/docs/apps/build/checkout/payments/create-payments-function#step-1-create-the-pay...

 

Secondly I would seriously consider redesigning how you want to achieve this, instead of looking at all the orders the customer has and if any one of them in the last 30 days has a hide tag instead tag the customer, or even better create a metafield "hideCOD" and make it a date field. And instead of tagging the order with hide, you update the metafield of the customer with the order date.

 

then in the run input graphql you ask for that meta field as well as query the shop{localTime{date}} field and compare that to the metafield date taking your 30 day span into consideration, and hide the COD payment method if necessary.

 

You will not be able to use the function to query the customers orders in the last 30 days. This type of operation needs to be fast, thats why I said to put it all in metafield of the customer.

 

I hope this helps,

 

Cheers

Gary 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution