🏢 Meet the Client
I built this setup for CrownTools. They use Affirm as a payment method and wanted to ensure that: "Affirm is hidden at checkout whenever a discount is applied. Whether it's a discount code or an automatic discount."
🚧 Pain Point
Protecting Profit Margins - Combining discounts with Affirm's financing can significantly reduce profit margins. Affirm typically charges merchants a fee ranging from 5% to 6% per transaction. When a customer applies a discount and chooses Affirm, CrownTools absorbs both the discount and the Affirm fee, which can substantially diminish profits.
🛠️ The Solution (What I Did)
Checkout UI Extension: Setting a Custom Attribute
- I developed a Checkout UI Extension that monitors the checkout process for any applied discounts. When a discount is detected, the extension sets a custom attribute on the cart to signal this condition.
Payment Customization Function: Hiding Affirm Based on Attribute
- Next, I created a Payment Customization Function that evaluates the cart's attributes during the checkout process. If the discount_applied
attribute is set to 'true'
, the function hides the Affirm payment method from the available options.