Set a price floor for checkout (Shopify Plus only)
Retirement of checkout.liquid
As of August 2024, Shopify retires the checkout.liquid file for customizing payment methods.
Instead, you can use the Affirm pay-over-time messaging Shopify app to control the appearance of the Affirm payment option at checkout for your Shopify store. For details, see Manage Affirm payment customizations for Shopify stores.
Overview
Merchants using Shopify Plus can set a price floor that displays Affirm as a payment option when the customer's cart exceeds a minimum dollar amount.
Configuration
- Go to the Shopify script editor.
- Click Create Script.
- Choose Payment Gateway for the script type.
- Choose Blank Template.
- Click Create Script.
- In the Title box, enter Affirm price floor as the script name.
- Click Code to open the Ruby source code console.
- Paste the following code into the console (250 sets the floor to $250. You can change it to your desired price floor):
available_gateways = Input.payment_gateways
cart = Input.cart
subtotal = cart.subtotal_price
unless cart.line_items.empty? or cart.discount_code.nil?
case cart.discount_code
when CartDiscount::Percentage
if cart.subtotal_price >= cart.discount_code.minimum_order_amount
subtotal = cart.subtotal_price * ((Decimal.new(100) - cart.discount_code.percentage) / 100)
else
subtotal = cart.subtotal_price
end
when CartDiscount::FixedAmount
if cart.subtotal_price >= cart.discount_code.minimum_order_amount
subtotal = cart.subtotal_price - cart.discount_code.amount
else
subtotal = cart.subtotal_price
end
else
subtotal = cart.subtotal_price
end
end
if subtotal < Money.new(cents:100) * 250
available_gateways = available_gateways.delete_if do |payment_gateway|
payment_gateway.name == "Affirm - Pay Over Time"
end
end
Output.payment_gateways = available_gateways
9. Click Run Script.
10. Click Save and Publish.
The price floor takes effect immediately. Test it by attempting a checkout for an item less than the price floor amount.
Updated 5 months ago