Javascript loading of payment methods fails to load PayPal checkout buttons
-
I have the following snippet in functions.php which shows payment methods only when the user selects a shipping method:
function bbloomer_gateway_disable_for_shipping_rate($available_gateways) { if (!is_admin()) { $session = WC()->session; if ($session) { $chosen_methods = $session->get('chosen_shipping_methods'); if (empty($chosen_methods[0])) { $available_gateways = []; } } } return $available_gateways; } add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_gateway_disable_for_shipping_rate' );
After storefront update, paypal buttons fail to show.
If F5 is pressed and the page properly reloads, the buttons are shown as it is happening without the above code snippet.
To test it, please add in cart the linked product and go to checkout.
* No payment methods are available
* Select “Ghana” as the country in the shipping address form.
* Shipping methods will appear.
* Select paypal -> No buttons.
* Hit F5 and select paypal -> Buttons exist.The only activated plugins are Woocommerce and WooCommerce PayPal Payments while using the default storefront theme with the addition of the above snippet.
The page I need help with: [log in to see the link]
-
Hi @raratiru
Thanks for reaching out!
I was able to replicate the issue on your site. Indeed, the PayPal buttons are not displaying initially, however, after hitting refresh, it will be displayed afterwards.
I’d like to understand your site properly, can you please share your System Status Report, that will help us further troubleshoot.
You can find it via
WooCommerce > Status
. SelectGet system report
and thenCopy for support
. Once you’ve done that, you can paste it into your reply here.If you could also provide the fatal error logs (if any) under
WooCommerce > Status > Logs
.Hallo, thank you for the prompt reply. I did not find any fatal error logs, I am pasting the system report:
### WordPress Environment ### WordPress address (URL): https://a.musicaloffering.gr Site address (URL): https://a.musicaloffering.gr WC Version: 6.9.4 REST API Version: ✔ 6.9.4 WC Blocks Version: ✔ 8.3.3 Action Scheduler Version: ✔ 3.4.0 Log Directory Writable: ✔ WP Version: 6.0.2 WP Multisite: – WP Memory Limit: 2 GB WP Debug Mode: – WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: nginx/1.23.1 PHP Version: 7.4.32 PHP Post Max Size: 100 MB PHP Time Limit: 1800 PHP Max Input Vars: 1000 cURL Version: 7.85.0 OpenSSL/1.1.1q SUHOSIN Installed: – MySQL Version: 5.5.5-10.6.10-MariaDB-1:10.6.10+maria~ubu2004 Max Upload Size: 100 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 6.9.4 WC Database Prefix: wp_ Total Database Size: 1487.57MB Database Data Size: 1254.56MB Database Index Size: 233.01MB wp_woocommerce_sessions: Data: 0.34MB + 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.05MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.41MB + Index: 0.20MB + 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.08MB + Index: 0.06MB + 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: 2.52MB + Index: 1.27MB + 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: 2.52MB + Index: 0.59MB + Engine InnoDB wp_burst_goals: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_burst_sessions: Data: 2.52MB + Index: 0.00MB + Engine InnoDB wp_burst_statistics: Data: 32.55MB + Index: 1.52MB + Engine InnoDB wp_cmplz_cookiebanners: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_cmplz_cookies: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_cmplz_dnsmpd: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_cmplz_services: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_cmplz_statistics: Data: 2.52MB + Index: 0.00MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.16MB + Index: 0.09MB + Engine InnoDB wp_icl_content_status: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_core_status: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_flags: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_languages: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_icl_languages_translations: Data: 0.19MB + Index: 0.09MB + Engine InnoDB wp_icl_locale_map: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_message_status: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_icl_mo_files_domains: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_node: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_reminders: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_strings: Data: 8.52MB + Index: 11.09MB + Engine InnoDB wp_icl_string_batches: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_string_packages: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_string_pages: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_icl_string_positions: Data: 1.52MB + Index: 0.14MB + Engine InnoDB wp_icl_string_status: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_string_translations: Data: 4.52MB + Index: 1.91MB + Engine InnoDB wp_icl_string_urls: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_translate: Data: 234.67MB + Index: 3.52MB + Engine InnoDB wp_icl_translate_job: Data: 2.52MB + Index: 1.52MB + Engine InnoDB wp_icl_translations: Data: 18.55MB + Index: 36.13MB + Engine InnoDB wp_icl_translation_batches: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_icl_translation_downloads: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_translation_status: Data: 367.61MB + Index: 1.52MB + Engine InnoDB wp_itsec_bans: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_itsec_dashboard_events: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_itsec_distributed_storage: Data: 4.50MB + Index: 0.02MB + Engine InnoDB wp_itsec_fingerprints: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_itsec_geolocation_cache: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_itsec_lockouts: Data: 0.02MB + Index: 0.08MB + Engine InnoDB wp_itsec_logs: Data: 0.11MB + Index: 0.11MB + Engine InnoDB wp_itsec_mutexes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_itsec_opaque_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_itsec_temp: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_itsec_user_groups: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_mailchimp_carts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_mailchimp_jobs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_netstudio_log: Data: 0.19MB + Index: 0.00MB + Engine InnoDB wp_nf3_actions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_action_meta: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_nf3_chunks: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_fields: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_field_meta: Data: 0.08MB + Index: 0.00MB + Engine InnoDB wp_nf3_forms: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_form_meta: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_nf3_objects: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_object_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_relationships: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_nf3_upgrades: Data: 0.08MB + Index: 0.00MB + Engine InnoDB wp_nxs_log: Data: 1.52MB + Index: 0.00MB + Engine InnoDB wp_nxs_query: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_options: Data: 2.52MB + Index: 0.13MB + Engine InnoDB wp_postmeta: Data: 259.80MB + Index: 90.20MB + Engine InnoDB wp_posts: Data: 186.67MB + Index: 18.09MB + Engine InnoDB wp_redirection_404: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_redirection_groups: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_redirection_items: Data: 2.52MB + Index: 1.22MB + Engine InnoDB wp_redirection_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_termmeta: Data: 10.52MB + Index: 10.03MB + Engine InnoDB wp_terms: Data: 19.55MB + Index: 17.09MB + Engine InnoDB wp_term_relationships: Data: 27.56MB + Index: 14.55MB + Engine InnoDB wp_term_taxonomy: Data: 49.58MB + Index: 10.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_toolset_associations: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_toolset_connected_elements: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_toolset_post_guid_id: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_toolset_relationships: Data: 0.02MB + Index: 0.08MB + Engine InnoDB wp_toolset_type_sets: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_notes: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + 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.11MB + Index: 0.08MB + Engine InnoDB wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 5.52MB + Index: 10.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_wpmailsmtp_debug_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wpmailsmtp_tasks_meta: Data: 0.02MB + 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 ### Post Type Counts ### attachment: 63793 is_search_form: 65 itsec-dash-card: 5 itsec-dashboard: 1 nav_menu_item: 64 page: 36 post: 1 product: 42552 shop_order: 92 wp_global_styles: 1 wp-types-group: 1 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (2) ### WooCommerce PayPal Payments: by WooCommerce – 1.9.3 WooCommerce: by Automattic – 6.9.4 ### Inactive Plugins (36) ### ARI Adminer: by ARI Soft – 1.1.12 Burst Statistics - Privacy-Friendly Analytics for WordPress: by Really Simple Plugins – 1.2.1 Change wp-admin login: by Nuno Morais Sarmento – 1.1.0 Classic Editor: by WordPress Contributors – 1.6.2 Complianz - Terms and Conditions: by Really Simple Plugins – 1.1.2 Complianz Privacy Suite (GDPR/CCPA) premium: by Really Simple Plugins – 6.3.4 Customizer Export/Import: by The Beaver Builder Team – 0.9.4 Email Inquiry & Cart Options for WooCommerce: by a3rev Software – 2.8.0 Fast Velocity Minify: by Raul Peixoto – 3.2.9 Featured Images in RSS for Mailchimp & More: by 5 Star Plugins – 1.5.9 Flexible Checkout Fields: by WP Desk – 3.4.2 Flexible Shipping: by Octolize – 4.14.2 iThemes Security: by iThemes – 8.1.2 Ivory Search: by Ivory Search – 5.4.8 Mailchimp for WooCommerce: by Mailchimp – 2.7.5 NextScripts: Social Networks Auto-Poster: by NextScripts – 4.3.30 Ninja Forms: by Saturday Drive – 3.6.14 Ninja Forms Multilingual: by OnTheGoSystems – 0.2.0 OMGF: by Daan from Daan.dev – 5.3.9 Payment Gateway Based Fees and Discounts for WooCommerce: by Tyche Softwares – 2.7.0 Redirection: by John Godley – 5.3.4 Redis Object Cache: by Till Krüss – 2.2.0 Robots.txt Editor: by Processby – 1.1.4 SEOPress: by The SEO Guys at SEOPress – 5.9.0.4 Simple Banner: by Ryan Petersen – 2.12.1 UpdraftPlus - Backup/Restore: by UpdraftPlus.Com DavidAnderson – 1.22.23 Virtual Robots.txt: by Marios Alexandrou – 1.10 WooCommerce Multilingual & Multicurrency: by OnTheGoSystems – 5.0.2 WooCommerce PDF Invoices & Packing Slips: by WP Overnight – 3.2.0 WordPress Importer: by wordpressdotorg – 0.8 WP-Optimize - Clean, Compress, Cache: by David Anderson Ruhani Rabin Team Updraft – 3.2.7 WP Mail SMTP: by WPForms – 3.5.2 WPML Media: by OnTheGoSystems – 2.7.1 WPML Multilingual CMS: by OnTheGoSystems – 4.5.11 WPML String Translation: by OnTheGoSystems – 3.2.2 WP Super Cache - FASTPATH.GR: by Automattic and Stathis Oureilidis FASTPATH IKE – 200.1.7.2 ### Settings ### API Enabled: – Force SSL: – Currency: EUR (€) 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: – ### WC Pages ### Shop base: #6 - / Cart: #7 - /cart/ Checkout: #8 - /checkout/ My account: #9 - /my-account/ Terms and conditions: #93251 - /terms-conditions/ ### Theme ### Name: Storefront Version: 4.1.3 Author URL: https://woocommerce.com/ Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme WooCommerce Support: ✔ ### Templates ### Overrides: – ### WooCommerce PayPal Payments ### Onboarded: ✔ Shop country code: GR WooCommerce currency supported: ✔ PayPal card processing available in country: – Pay Later messaging available in country: – Webhook status: – Vault enabled: ✔ Logging enabled: – Reference Transactions: – Used PayPal Checkout plugin: – Tracking enabled: – ### Admin ### Enabled Features: activity-panels analytics coupons customer-effort-score-tracks experimental-products-task experimental-import-products-task experimental-fashion-sample-products experimental-product-tour shipping-smart-defaults shipping-setting-tour homescreen 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 wc-pay-promotion wc-pay-welcome-page Disabled Features: minified-js new-product-management-experience settings Daily Cron: ✔ Next scheduled: 2022-10-06 03:15:31 +03:00 Options: ✔ Notes: 31 Onboarding: completed ### Action Scheduler ### Complete: 4,688 Oldest: 2022-09-04 22:44:46 +0300 Newest: 2022-10-05 11:20:40 +0300 Pending: 2 Oldest: 2022-10-06 01:10:03 +0300 Newest: 2022-10-10 15:35:09 +0300 ### Status report information ### Generated at: 2022-10-05 11:20:47 +03:00
Hello,
Thanks for sending your system report. May I ask is the issue still present if you add the custom code using a plugin like Code Snippets instead of adding the code directly on your functions.php file.
To learn mode you can check this article.
Does this make a difference? Let us know 🙂
Hallo,
Yes, I used
Code Snippets
to add the same piece of code -after removing it fromfunctions.php
– and the result is the same.In our live site, we use a child theme.
When that issue appeared, I created the staging site deactivating all plugins and themes to spot the issue.
Hi @raratiru
Thanks for your confirmation that the issue still persists even after deactivating all plugins and switching to the default Storefront theme.
These forums are meant for general support with the core functionality of WooCommerce itself. Since custom coding is outside our scope of support, I am leaving this thread open for a bit to see if anyone can chime in to help you out.
For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.
– WooCommerce Developer Resources Portal
– WooCommerce Advanced Facebook group
– WooCommerce Community Forum
– WooCommerce Developer Slack Channel.
– Hire a WooCommerce ExpertIf this is not a bug, that is OK with me, thank you!
Hello @raratiru,
Your PayPal and WooCommerce plugins are not running the latest version. Can you please update them?
Let us know how it goes.
Hallo!
The site is now updated.
The issue still remains.
Hello,
To check better, please share a copy of any fatal error log found under WooCommerce > System Status > Logs (if any).
Share screenshots of your shipping methods that are under WooCommerce > Settings > shipping > shipping zones.
For screenshots, you may want to use https://snipboard.io – please follow the instructions on that page, then paste the URL in this thread.
Thanks.
Hallo, thank you for the answer.
Currently there are no fatal error logs under WooCommerce > System Status > Logs.
The shipping method is a Flat Rate for Ghana:
Hello,
I apologize, custom code is not supported in our forum, I could not find an issue on the screenshots provided, my recommendation is to check the resources shared by xue28, so that you can get custom code assistance or a developer to help you with this.
- The topic ‘Javascript loading of payment methods fails to load PayPal checkout buttons’ is closed to new replies.