Hide Affirm for Certain SKUs (Shopify Plus only)
Retrait de checkout.liquidAs of August 2024, Shopify retires the checkout.liquid file for customizing payment methods.
Vous pouvez plutôt utiliser l'application de messagerie Affirm payez selon vos conditions de Shopify pour contrôler l'apparence des options de paiement d'Affirm lors du passage en caisse dans votre boutique Shopify. Pour obtenir plus de détails, consultez Gérer les paramètres de paiement personnalisés d'Affirm pour les boutiques Shopify.
Aperçu
Les commerçants qui utilisent Shopify Plus peuvent masquer Affirm comme option de paiement lorsque le panier du client contient des articles avec certaines SKUs.
Configuration
1. Go to the Shopify script editor
2. Click Create Script
3. Choose Payment Gateway for the script type
4. Choose Blank Template
5. Click Create Script
6. In the Title box, enter Affirm Hide Based on SKU as the script name
7. Click Code to open the Ruby source code console
8. Paste the following code into the console. Replace SKU-1234 with your SKUs and add as many as you need (this is a comma separated list).
available_gateways = Input.payment_gateways
cart = Input.cart
SKUS_TO_HIDE = ["SKU-1234", "..."]
cart.line_items.each do |item|
item.variant.skus.each do |sku|
if SKUS_TO_HIDE.include? sku
available_gateways = available_gateways.delete_if do |payment_gateway|
payment_gateway.name == "Affirm - Pay Over Time"
end
end
end
end
Output.payment_gateways = available_gateways9. Click Run Script
10.. Click Save and Publish
Balises
Ajoutez une balise à tous les produits que vous souhaitez masquer Affirm comme mode de paiement, par exemple : hide-affirm. Pour masquer l'option de paiement Affirm lorsque le panier du client contient des articles avec certaines étiquettes de produit :
1. Go to the Shopify script editor
2. Click Create Script
3. Choose Payment Gateway for the script type
4. Choose Blank Template
5. Click Create Script
6. In the Title box, enter Affirm Hide Based on SKU as the script name
7. Click Code to open the Ruby source code console
8. Paste the following code into the console and replace hide-affirm with the tag you created for the products you want to hide Affirm. You can add as many as you need (this is a comma-separated list).
available_gateways = Input.payment_gateways
cart = Input.cart
SKUS_TO_HIDE = ["hide-affirm", "..."]
cart.line_items.each do |item|
item.variant.product.tags.each do |tag|
if SKUS_TO_HIDE.include? tag
available_gateways = available_gateways.delete_if do |payment_gateway|
payment_gateway.name == "Affirm - Pay Over Time"
end
end
end
end
Output.payment_gateways = available_gateways9. Click Run Script
10.. Click Save and Publish
Mis à jour Il y a 17 jours