wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
644 stars 131 forks source link

Fetch Payment Gateways #665

Closed vorasudh closed 1 year ago

vorasudh commented 1 year ago

Describe the bug I have set up 2 payment methods - Cash on Delivery and RazorPay. RazorPay is available for all types of shipping methods whereas Cash on Delivery is available for only 1 type of shipping method - Free shipping. Now only the Razorpay method is returned with the below query (no matter what shipping method is used). If I remove the restriction of shipping method for Cash on Delivery, then both payment gateways are returned.

Can you guide me in case I have configured something wrong? Or is this a bug?

NOTE: The shipping methods get applied automatically based on the shipping address.

To Reproduce

query GetPaymentGateways {
  paymentGateways {
    nodes {
      id
      title
      icon
      description
    }
  }
}

Expected behavior With the above query, both razor pay and Cash on Delivery methods should be returned.

Plugin Versions

vorasudh commented 1 year ago

@kidunot89 any thoughts here?

kidunot89 commented 1 year ago

If I remember correctly, payment gateways are restricted by the current location of the end-user. This is determined by the shipping address saved for current user attached to the user session.

I think WooCommerce core get around this by using geolocation detection if no shipping address is set. WooGraphQL on the other hand, doesn't provided a pass-thru to use this functionality at the moment.

You'd have to do some kind geolocation detection on client and update the user shipping address with the retrieved field (typically country, state/province, and postcode/zip) using the updateCustomer mutation. Then on the following paymentGateways queries should have cod in the results if the end-user is within the correct shipping zone.

kidunot89 commented 1 year ago

@vorasudh Any updates on this?

kidunot89 commented 1 year ago

Since there has been no response on this, I'm closing this.