Shopify functions to hide payment gateway on country code based

Shopify functions to hide payment gateway on country code based

boski1
Shopify Partner
8 2 0

Shopify functions to hide payment gateway on country code based.

 

I have installed the app and added the example code to hide payment method on cart total bases but now I want to hide them country code

 

Replies 3 (3)

Kai33
Excursionist
18 1 2

Hi @boski1 ,

 

I think that in the past you could only do this by being a Shopify Plus merchant and using scripts, but now you can achieve this with apps like the Kip: Customize Payment Methods app, which lets you hide payment gateways based on conditions like country, language, location, etc. 

 

is country code.png

 

I hope you find this helpful!

 

KabirDev
Shopify Partner
248 61 75

Hi @boski1 , you can try KlinKode PayRules app to hide any payment methods based on country.

 

It's the most easiest one out there. You can check the below video to know how to use the app.

- Control payment methods visibility at checkout by KlinKode PayRules app.
- Contact me directly at shahriar@kabirdev.com

oliverjenks
Shopify Partner
4 0 1

 

 

I came across this  while trying to solve the same problem.   If you are following the Shopify tutorial, then you need to add localization to you input and filter it accordingly.

 

 

query Input {
  localization {
    country {
      isoCode
    }
  }
  paymentMethods {
    id
    name
  }
  paymentCustomization {
    metafield(
      namespace: "$app:payment-customization"
      key: "function-configuration"
    ) {
      value
    }
  }
}

 

 

Then within run.rs, perform a similar check to the tutorial

    let country = input.localization.country.iso_code.to_string();

    // If the country is not US, we don't need to hide the payment method
    if country != "US" {
        // You can use STDERR for debug logs in your function
        eprintln!("Country is not US, no need to hide the payment method.");
        return Ok(no_changes);
    }