Default payment method
-
I want to make Stripe the default payment method in preference to Paypal and I had this simple plugin that used to work when the site was using Avada. Our site now uses Storefront with Stripe and WP Express Checkout gateway. But the plugin no longer works. Can someone have a look at itplease
<?php /** * Plugin Name: Default Stripe Payment Method * Plugin URI: https://trapbarn.com * Description: Plugin which select Stripe payment menthod always as default * Version: 1.0 * Author: Alex Kantajevs (virus) * Author URI: https://virus707.me/ **/ add_action( 'template_redirect', 'define_default_payment_gateway' ); function define_default_payment_gateway(){ if( is_checkout() && ! is_wc_endpoint_url() ) { $default_payment_id = 'stripe'; WC()->session->set( 'chosen_payment_method', $default_payment_id ); } } ?>-
This topic was modified 3 years, 1 month ago by
cullachie.
The page I need help with: [log in to see the link]
-
This topic was modified 3 years, 1 month ago by
-
Hi @cullachie
The plugin you used to set Stripe as the default payment method seems no longer compatible with your current setup. I would recommend trying the following updated code for your plugin to see if it resolves the issue:
<?php /** * Plugin Name: Default Stripe Payment Method * Plugin URI: https://woocommerce.com * Description: Plugin which selects Stripe payment method always as default * Version: 1.1 * Author: Shameem Reza * Author URI: https://woocommerce.com **/ add_filter( "woocommerce_default_payment_gateway", "set_default_payment_gateway" ); function set_default_payment_gateway($default_gateway) { if (is_checkout() && !is_wc_endpoint_url()) { $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); $default_payment_id = "stripe"; if (isset($available_gateways[$default_payment_id])) { $default_gateway = $available_gateways[$default_payment_id]; } } return $default_gateway; } ?>To use the updated code, please follow these steps:
- Deactivate plugin.
- Copy the updated code above and replace with old code.
- Save the file and activate the plugin again.
This should set Stripe as the default payment method on your WooCommerce Storefront site.
Thanks!
Hi Shameen,
Did all exactly as you said but it didn’t work. I will leave it installed so that you can see neither Stripe and Paypal buttons are active.In this case, you can just rearrange the payment gateway according to your need (in your case Credit Card (Stripe) followed by Express Checkout gateway) so that the top one would always be selected per new session.
You can also check the solution mentioned here: https://ww.wp.xz.cn/support/topic/how-to-change-the-default-selected-payment-gateway/.
Hi @cullachie ,
Thanks for reaching out!
I understand that you would like to set Stripe as the default selected payment method on Checkout, is this correct?
Kindly note that you do not require a plugin for this as this is can be achieved with WooCommerce core.
To do this, you can navigate to WooCommerce β Settings β
Paymentsand simply move Stripe to the top and “Save changes”, like so:
This will make Stripe the default selected payment gateway on checkout. π
Cheers!
Hi Roxy,
‘ Been there and tried that but it didn’t work. I want the radio button for Stripe to be active when the checkout page opens. At present, neither Stripe or Paypal are active.
Dis you visit the site to see?Hi @cullachie ,
Thanks for providing clarity!
I have checked your site, and see what you mean:

It appears that there may be a plugin that is adding the “Select Stripe for Bank cards or select PayPal below” option, which may be affecting the way that the default payment gateway/method is selected.
Before suggesting a conflict test, would you please share a copy of your sites System Status Report, so that we can get a better understanding of your sites current environment.
You can find this via WooCommerceΒ βΒ Status. SelectΒ
Get system reportΒ and thenΒCopy for support.Once you have this, please share the results in your response here so that we can take a closer look.
Cheers!
Hi, Thanks for having a look at it. Here is the status report
` ### WordPress Environment ### WordPress address (URL): https://www.trapbarn.com Site address (URL): https://www.trapbarn.com WC Version: 7.6.0 REST API Version: β 7.6.0 WC Blocks Version: β 9.8.4 Action Scheduler Version: β 3.5.4 Log Directory Writable: β WP Version: 6.2 WP Multisite: β WP Memory Limit: 950 MB WP Debug Mode: β WP Cron: β Language: en_GB External object cache: β ### Server Environment ### Server Info: Apache PHP Version: 7.4.33 PHP Post Max Size: 950 MB PHP Time Limit: 300 PHP Max Input Vars: 2500 cURL Version: 7.86.0 OpenSSL/1.1.1s-fips SUHOSIN Installed: β MySQL Version: 5.5.5-10.4.26-MariaDB-log Max Upload Size: 950 MB Default Timezone is UTC: β fsockopen/cURL: β SoapClient: β DOMDocument: β GZip: β Multibyte String: β Remote Post: β Remote Get: β ### Database ### WC Database Version: 7.6.0 WC Database Prefix: wp_ Total Database Size: 21.68MB Database Data Size: 18.59MB Database Index Size: 3.09MB wp_woocommerce_sessions: Data: 0.13MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_actions: Data: 0.16MB + Index: 0.14MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.13MB + Index: 0.14MB + Engine InnoDB wp_aioseo_cache: Data: 0.11MB + Index: 0.03MB + Engine InnoDB wp_aioseo_notifications: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_aioseo_posts: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_blc_filters: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_blc_instances: Data: 0.08MB + Index: 0.05MB + Engine InnoDB wp_blc_links: Data: 0.48MB + Index: 0.06MB + Engine InnoDB wp_blc_synch: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_db7_forms: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_ddp_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_fusion_forms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_fusion_form_entries: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_fusion_form_fields: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_fusion_form_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_gglcptch_allowlist: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_ms_snippets: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_mystickymenu_contact_lists: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_odb_logs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_options: Data: 4.14MB + Index: 0.08MB + Engine InnoDB wp_postmeta: Data: 1.52MB + Index: 0.48MB + Engine InnoDB wp_posts: Data: 3.25MB + Index: 0.14MB + Engine InnoDB wp_redirects: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_rtafar_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_snippets: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_usermeta: Data: 0.19MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.05MB + Index: 0.02MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woo_shippment_provider: Data: 0.11MB + Index: 0.00MB + Engine InnoDB wp_wpil_report_links: Data: 0.08MB + Index: 0.05MB + Engine InnoDB wp_wplnst_urls_status: Data: 0.08MB + Index: 0.23MB + Engine InnoDB wp_wpml_mails: Data: 6.52MB + Index: 0.00MB + Engine InnoDB wp_wt_iew_action_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wt_iew_cron: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wt_iew_ftp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wt_iew_mapping_template: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_yoast_indexable: Data: 0.06MB + Index: 0.09MB + Engine InnoDB wp_yoast_indexable_hierarchy: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_yoast_seo_links: Data: 0.06MB + Index: 0.03MB + Engine InnoDB wp_yoast_seo_meta: Data: 0.09MB + Index: 0.00MB + Engine InnoDB ### Post Type Counts ### attachment: 203 custom_css: 2 customize_changeset: 20 nav_menu_item: 39 page: 54 post: 1 product: 9 product_variation: 27 revision: 442 shop_order: 11 ### Security ### Secure connection (HTTPS): β Hide errors from visitors: β ### Active Plugins (20) ### Change DropDown name to Quantity: by Jim Grant β 0.1 Delay emails for 2 mins: by Damien Carbery β 0.5 TCs checked by default: by Patrick Rauland β 1.0 * Tracking Info to WooCommerce order: by Damien Carberry and Jim Grant β All-in-One WP Migration: by ServMask β 7.73 CMB2: by CMB2 team β 2.10.1 Code Snippets: by Code Snippets Pro β 3.3.0 301 Redirects: by WebFactory Ltd β 2.73 Head, Footer and Post Injections: by Stefano Lissa β 3.2.5 Stripe Payment Plugin for WooCommerce: by WebToffee β 3.7.6 Perfect Brands WooCommerce: by QuadLayers β 3.0.5 PWA: by PWA Plugin Contributors β 0.7.1 Optimize Database after Deleting Revisions: by CAGE Web Design | Rolf van Gelder Eindhoven The Netherlands β 5.0.110 Title Toggle for Storefront Theme: by Wooassist β 1.2.5 Advanced Editor Tools: by Automattic β 5.9.0 WooCommerce: by Automattic β 7.6.0 Yoast SEO: by Team Yoast β 20.5 Asset CleanUp: Page Speed Booster: by Gabe Livan β 1.3.9.1 WP Express Checkout: by Tips and Tricks HQ β 2.3.0 WP Fastest Cache: by Emre Vona β 1.1.4 ### Inactive Plugins (16) ### Asset CleanUp Pro: Page Speed Booster: by Gabriel Livan β 1.1.8.2 Broken Link Checker: by WPMU DEV β 2.0.0 Converter for Media: by matt plugins β 5.8.5 Default Stripe Payment Method: by Shameem Reza β 1.1 Disable & Remove Google Fonts: by Fonts Plugin β 1.5.4 Max Mega Menu: by megamenu.com β 3.2 Max Mega Menu - StoreFront Integration: by megamenu.com β 1.0.3 Meks Quick Plugin Disabler: by Meks β 1.0 myStickymenu: by Premio β 2.6.2 REST API Log: by Pete Nelson β 1.6.9 StoreCustomizer: by Kaira β 2.5.0 WordPress Importer: by wordpressdotorg β 0.8 WP Cerber Security, Anti-spam & Malware Scan: by Cerber Tech Inc. β 9.0 WP Mail Logging: by WP Mail Logging Team β 1.11.0 Yoast Duplicate Post: by Enrico Battocchi & Team Yoast β 4.5 Yoast Test Helper: by Team Yoast β 1.17 ### Must Use Plugins (1) ### StackCache: by Stack CP β ### Settings ### API Enabled: β Force SSL: β Currency: GBP (Β£) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: β Enforce Approved Product Download Directories: β Order datastore: WC_Order_Data_Store_CPT ### WC Pages ### Shop base: β Page not set Basket: #17523 - /basket/ Checkout: #17524 - /checkout/ My account: β Page not set Terms and conditions: β Page not set ### Theme ### Name: Child theme Version: 4.2.0.1680276726 Author URL: https://woocommerce.com/ Child Theme: β Parent Theme Name: Storefront Parent Theme Version: 4.2.0 Parent Theme Author URL: https://woocommerce.com/ WooCommerce Support: β ### Templates ### Overrides: β ### Admin ### Enabled Features: activity-panels analytics coupons customer-effort-score-tracks import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing multichannel-marketing mobile-app-banner navigation onboarding onboarding-tasks remote-inbox-notifications remote-free-extensions payment-gateway-suggestions shipping-label-banner subscriptions store-alerts transient-notices woo-mobile-welcome wc-pay-promotion wc-pay-welcome-page Disabled Features: block-editor-feature-enabled minified-js new-product-management-experience product-variation-management settings Daily Cron: β Next scheduled: 2023-04-18 12:54:44 +01:00 Options: β Notes: 46 Onboarding: completed ### Action Scheduler ### Complete: 475 Oldest: 2023-03-18 12:54:48 +0000 Newest: 2023-04-17 14:55:41 +0100 Failed: 25 Oldest: 2023-03-18 15:34:45 +0000 Newest: 2023-04-14 08:51:34 +0100 Pending: 1 Oldest: 2023-04-18 07:11:30 +0100 Newest: 2023-04-18 07:11:30 +0100 ### Status report information ### Generated at: 2023-04-17 15:46:03 +01:00 `Hi @cullachie
Thanks for sharing the requested information above.
I replicated the scenario on my personal site running on the default Storefront theme where Stripe is at the top of the list of my payment methods, however, I am unable to reproduce the issue on my end.


For us to investigate this further, can you please try to switch to the default Storefront theme and only WooCommerce plugin is enabled and see if this works?
If so, then this kind of problem is usually caused by your theme or a third-party plugin present on your site. We can run a conflict test to verify this. Iβd recommend cloning your site to a staging environment and performing the tests described on this guide without modifying your live site or impacting customers. Many hosts provide staging facilities, so itβs worth checking in with them. Itβs also possible to do it using the free WP Staging plugin.
If this was caused by a third-party plugin present on your site, it would be best to reach out to the developers for further assistance here.
If this did not resolve the issue, please provide the fatal error logs (if any) under
WooCommerce > Status > Logs.You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.
Let us know how it goes!
Hi @cullachie
We havenβt heard back from you in a while, so Iβm going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.
Thanks!
The topic ‘Default payment method’ is closed to new replies.