0

I need to hide in google pay and apple pay certain delivery methods in plugin (https://wordpress.org/plugins/woocommerce-gateway-stripe/) Can I do it with a filter or something?

Some shipping methods i have can't use - they're unsupported with apple and google pay.

Support of WC Stripe plugin told me:"Google and Apple Pay uses whichever shipping method is available on the site for the Stripe payment gateway. There isn’t an inbuilt option to selectively hide certain shipping method from Google and Apple pay, and we’re not aware of a workaround as well. I recommend taking a lot at a similar discussion here (related to disabling shipping method based on the payment gateway)" but I don't know how I do that. –

Thanks for help.

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40
N3S4
  • 1
  • Apple Pay and Google Pay are different ways to pay with a card; why are some shipping methods incompatible? – Justin Michael Dec 26 '20 at 21:16
  • The "Zásilkovna" plugin used in the Czech Republic does not work in the apple pay and google pay dialog for selecting dispensing points. In the Woocommerce cash register, the selection of the dispensing point is displayed in a pop-up window, but the selection of the dispensing point is not displayed in google and apple pay. – N3S4 Dec 27 '20 at 19:49
  • Can you use the `wc_stripe_payment_request_params` filter and remove the shipping options you don't want at that point? Here's where that filter gets called: https://github.com/woocommerce/woocommerce-gateway-stripe/blob/2d7e3f2fa642a3d3fe427b9af7ba6c5c2a7e0375/includes/payment-methods/class-wc-stripe-payment-request.php#L507-L553 – Justin Michael Dec 27 '20 at 21:08
  • How i remove shipping options i want? – N3S4 Dec 28 '20 at 01:48
  • The `wc_stripe_payment_request_params` filter will provide the parameters that are about to be used with Stripe as an argument. You can examine those parameters and make changes (such as removing shipping options) based on your own custom logic/code. You can learn more about writing a filter here: https://developer.wordpress.org/plugins/hooks/filters/ – Justin Michael Dec 28 '20 at 18:06

1 Answers1

0

The answer of the above mentioned question is "Yes". We can hide the shipping methods only in Apple Pay Using Stripe. Currently, there is no settings both in Woo-commerce and Stripe to select the specific shipping methods. But you can achieve that functionality by adding custom code in the right file and function. Please follow all the steps:

Step1: The file url for Stripe is listed below: woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php

Step2: Look for the following function in the file public function get_shipping_options( $shipping_address, $itemized_display_items = false )

Step3: Remember that "STRIPE" by default uses the first Shipping method by default. So you need to check in that particular function, where that thing is happening.

Step4: Right before that specific IF condition -- "if ( isset( $data['shipping_options'][0] ) )"

Step5: Insert the Following Code before that IF condition

foreach($data['shipping_options'] as $index => $myshipping){
            if(strpos($myshipping['label'],'Select Future Date') !== false){
                unset($data['shipping_options'][$index]);
                $data['shipping_options']= array_values($data['shipping_options']);
            }
        }

Note: You can do by ID or any other element in an Array. You just need to match the shipping method ID and then Unset that ID. Please don't forget to update the array by using array_values() function.