Table of Contents | ||
---|---|---|
|
...
Creating Editable Configurations
Note |
---|
Alternative check sanity payment method sort feature, having this map in LD or Sanity we can retrieve in the backend to add extra layer |
Sanity Option
We can create a new field on Sanity that will map the available payment methods with the flag TRUE or FALSE for isOnlinePayment question.
...
Code Block |
---|
{ "payment_methods": { "cash": false, "cc": true, "debit_online": true }, "rules": { "limit_first_order": { "active": true, "amount": 20, "amount_in_cents": 2000 }, "limit_total_amount": { "active": true, "amount": 50, "amount_in_cents": 5000 }, "limit_last_delivery_failed": { "active": false, "reasons_to_limit": { "customer_absence": true, "reason2": false, "reason3": true } } } } |
Rules Implementation
Rule 1 - First Order Physical Payment Limit
For the first order with a value >= X €, only online payment will be allowed, where X is configurable. The initial intention is to set it to 20 €.
Questions:
How can we identify the first order of a user? Is there any mechanism in place?
Solution
We can get advantage of gateway query getUserOrders, this query returns all orders from the logged user with a count. We query this when the browser loads the payment method screen. This is the response:
New user without any order.
...
Rule 2 - Physical Payment Amount Limit
...