woocommerce_shipping_chosen_methodwoocommerce_shipping_chosen_method alternative
-
Hi,
It seems that woocommerce_shipping_chosen_method hooks isn’t working anymore since a recent update of woocommerce ?
I was using
add_filter( ‘woocommerce_shipping_chosen_method’, ‘__return_false’, 99);
to have no shipping method selected by default on my shop, but it didn’t work anymore.
Is there any alternative ?
-
Hello,
To check better into this, please share a copy of your site’s System Status: You can find it by navigating through WooCommerce > Status. Select “Get system report” and then “Copy for support”.? Once you’ve done that, paste it here in your response.
Error Log: Share a copy of any fatal error log found under WooCommerce > System Status > Logs (if available).
Hello,
Tested on multiple installations of WordPress + WooCommerce, but almost tested on my test site ( only latest wordpress + woocommerce + elementor PRO + Storefront )
and discuted with other webmasters and everybody has the same issue.
my test site status + error log :
### WordPress Environment ### WordPress address (URL): https://test.gr3g.ca Site address (URL): https://test.gr3g.ca 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: 256 Mo WP Debug Mode: – WP Cron: ? Language: fr_FR External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 8.1.11 PHP Post Max Size: 8 Mo PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 7.71.0 OpenSSL/1.1.1p SUHOSIN Installed: – MySQL Version: 10.5.17-MariaDB Max Upload Size: 8 Mo 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: wpkk_ Taille totale de la base de données: 5.44MB Taille de la base de données: 3.29MB Taille de l’index: 2.15MB wpkk_woocommerce_sessions: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_woocommerce_api_keys: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_woocommerce_attribute_taxonomies: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_woocommerce_downloadable_product_permissions: Données?: 0.02MB + Index?: 0.06MB + Moteur InnoDB wpkk_woocommerce_order_items: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_woocommerce_order_itemmeta: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_woocommerce_tax_rates: Données?: 0.02MB + Index?: 0.06MB + Moteur InnoDB wpkk_woocommerce_tax_rate_locations: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_woocommerce_shipping_zones: Données?: 0.02MB + Index?: 0.00MB + Moteur InnoDB wpkk_woocommerce_shipping_zone_locations: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_woocommerce_shipping_zone_methods: Données?: 0.02MB + Index?: 0.00MB + Moteur InnoDB wpkk_woocommerce_payment_tokens: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_woocommerce_payment_tokenmeta: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_woocommerce_log: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_actionscheduler_actions: Données?: 0.02MB + Index?: 0.11MB + Moteur InnoDB wpkk_actionscheduler_claims: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_actionscheduler_groups: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_actionscheduler_logs: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_commentmeta: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_comments: Données?: 0.02MB + Index?: 0.09MB + Moteur InnoDB wpkk_e_events: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_e_notes: Données?: 0.02MB + Index?: 0.17MB + Moteur InnoDB wpkk_e_notes_users_relations: Données?: 0.02MB + Index?: 0.05MB + Moteur InnoDB wpkk_e_submissions: Données?: 0.02MB + Index?: 0.27MB + Moteur InnoDB wpkk_e_submissions_actions_log: Données?: 0.02MB + Index?: 0.11MB + Moteur InnoDB wpkk_e_submissions_values: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_links: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_options: Données?: 2.06MB + Index?: 0.06MB + Moteur InnoDB wpkk_postmeta: Données?: 0.13MB + Index?: 0.06MB + Moteur InnoDB wpkk_posts: Données?: 0.09MB + Index?: 0.06MB + Moteur InnoDB wpkk_termmeta: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_terms: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_term_relationships: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_term_taxonomy: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_usermeta: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_users: Données?: 0.02MB + Index?: 0.05MB + Moteur InnoDB wpkk_wc_admin_notes: Données?: 0.05MB + Index?: 0.00MB + Moteur InnoDB wpkk_wc_admin_note_actions: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_wc_category_lookup: Données?: 0.02MB + Index?: 0.00MB + Moteur InnoDB wpkk_wc_customer_lookup: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_wc_download_log: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_wc_order_coupon_lookup: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_wc_order_product_lookup: Données?: 0.02MB + Index?: 0.06MB + Moteur InnoDB wpkk_wc_order_stats: Données?: 0.02MB + Index?: 0.05MB + Moteur InnoDB wpkk_wc_order_tax_lookup: Données?: 0.02MB + Index?: 0.03MB + Moteur InnoDB wpkk_wc_product_attributes_lookup: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_wc_product_download_directories: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_wc_product_meta_lookup: Données?: 0.02MB + Index?: 0.09MB + Moteur InnoDB wpkk_wc_rate_limits: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_wc_reserved_stock: Données?: 0.02MB + Index?: 0.00MB + Moteur InnoDB wpkk_wc_tax_rate_classes: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB wpkk_wc_webhooks: Données?: 0.02MB + Index?: 0.02MB + Moteur InnoDB ### Post Type Counts ### attachment: 23 elementor_library: 1 page: 9 post: 2 product: 18 product_variation: 7 revision: 11 wp_global_styles: 1 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (3) ### Elementor Pro: par Elementor.com – 3.7.7 Elementor: par Elementor.com – 3.7.8 WooCommerce: par Automattic – 6.9.4 ### Inactive Plugins (0) ### ### Settings ### API Enabled: – Force SSL: – Currency: USD ($) 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 ### Base de la boutique: #6 - /boutique/ Panier: ? La page ne contient pas le code court [woocommerce_cart] ou le bloc woocommerce/cart. Commander: #8 - /commander/ Mon compte: #9 - /mon-compte/ Conditions générales de vente et d’utilisation: ? Page non définie ### Theme ### Name: Storefront Version: 4.1.3 Author URL: https://woocommerce.com/ Child Theme: ? – Si vous modifiez WooCommerce sur un thème parent que vous n’avez pas construit personnellement nous vous recommandons d’utiliser un thème enfant. Voir?: Comment créer un thème enfant WooCommerce Support: ? ### Templates ### Overrides: – ### 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-09-17 21:13:11 +00:00 Options: ? Notes: 33 Onboarding: skipped ### Action Scheduler ### Terminé: 33 Oldest: 2022-09-16 21:14:23 +0000 Newest: 2022-09-16 21:20:22 +0000 En attente: 3 Oldest: 2022-09-17 09:56:09 +0000 Newest: 2022-10-07 10:43:06 +0000 ### Status report information ### Generated at: 2022-10-10 15:05:38 +00:00
error log
2022-09-16T21:13:13+00:00 ERROR Spec is invalid because a rule is invalid in feed 2022-09-16T21:13:13+00:00 ERROR stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) 2022-09-16T21:13:13+00:00 ERROR stdClass Object ( [slug] => googlelistings_signals2022_hasGLA [type] => marketing [status] => unactioned [is_snoozable] => 0 [source] => woocommerce.com [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [title] => Show off your products with Ads on Google [content] => You’re ready to grow with ads. Google optimizes for performance across your products; you only pay for results. If you’re new to Google, you can earn up to $500 in ad credits (T&Cs apply). <a href="https://woocommerce.com/my-account/create-a-ticket/">Contact support</a> if you need guidance with Google Listings & Ads. ) ) [actions] => Array ( [0] => stdClass Object ( [name] => googlelistings_signals2022_hasGLA_click [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [label] => Connect Google Listings & Ads ) ) [url] => admin.php?page=wc-admin&path=marketing [url_is_admin_query] => 1 [is_primary] => 1 [status] => unactioned ) ) [rules] => Array ( [0] => stdClass Object ( [type] => publish_after_time [publish_after] => 2022-09-12 07:23:39 ) [1] => stdClass Object ( [type] => publish_before_time [publish_before] => 2022-10-12 23:59:00 ) [2] => stdClass Object ( [type] => plugins_activated [plugins] => Array ( [0] => google-listings-and-ads ) ) [3] => stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) [4] => stdClass Object ( [type] => product_count [operation] => > [value] => 76 ) [5] => stdClass Object ( [type] => order_count [operation] => > [value] => 38 ) [6] => stdClass Object ( [type] => total_payments_value [days] => last_year [value] => 3700 [operation] => > ) ) ) 2022-09-16T21:13:13+00:00 ERROR Spec is invalid because a rule is invalid in feed 2022-09-16T21:13:13+00:00 ERROR stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) 2022-09-16T21:13:13+00:00 ERROR stdClass Object ( [slug] => googlelistings_signals2022_noGLA [type] => marketing [status] => unactioned [is_snoozable] => 0 [source] => woocommerce.com [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [title] => Show off your products with Ads on Google [content] => You’re ready to grow with ads. Google optimizes for performance across your products; you only pay for results. If you’re new to Google, you can earn up to $500 in ad credits (T&Cs apply). <a href="https://woocommerce.com/my-account/create-a-ticket/">Contact support</a> if you need guidance with Google Listings & Ads. ) ) [actions] => Array ( [0] => stdClass Object ( [name] => googlelistings_signals2022_noGLA [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [label] => Connect Google Listings & Ads ) ) [url] => https://woocommerce.com/products/google-listings-and-ads/?utm_medium=product&utm_source=inbox_note&utm_campaign=googlelistings_signals2022_noGLA [url_is_admin_query] => [is_primary] => 1 [status] => unactioned ) ) [rules] => Array ( [0] => stdClass Object ( [type] => publish_after_time [publish_after] => 2022-09-12 07:27:46 ) [1] => stdClass Object ( [type] => publish_before_time [publish_before] => 2022-10-12 23:59:00 ) [2] => stdClass Object ( [type] => not [operand] => Array ( [0] => stdClass Object ( [type] => plugins_activated [plugins] => Array ( [0] => google-listings-and-ads ) ) ) ) [3] => stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) [4] => stdClass Object ( [type] => product_count [operation] => > [value] => 76 ) [5] => stdClass Object ( [type] => order_count [operation] => > [value] => 38 ) [6] => stdClass Object ( [type] => total_payments_value [days] => last_year [value] => 3700 [operation] => > ) ) ) 2022-09-16T21:13:15+00:00 ERROR Spec is invalid because a rule is invalid in feed 2022-09-16T21:13:15+00:00 ERROR stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) 2022-09-16T21:13:15+00:00 ERROR stdClass Object ( [slug] => googlelistings_signals2022_hasGLA [type] => marketing [status] => unactioned [is_snoozable] => 0 [source] => woocommerce.com [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [title] => Show off your products with Ads on Google [content] => You’re ready to grow with ads. Google optimizes for performance across your products; you only pay for results. If you’re new to Google, you can earn up to $500 in ad credits (T&Cs apply). <a href="https://woocommerce.com/my-account/create-a-ticket/">Contact support</a> if you need guidance with Google Listings & Ads. ) ) [actions] => Array ( [0] => stdClass Object ( [name] => googlelistings_signals2022_hasGLA_click [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [label] => Connect Google Listings & Ads ) ) [url] => admin.php?page=wc-admin&path=marketing [url_is_admin_query] => 1 [is_primary] => 1 [status] => unactioned ) ) [rules] => Array ( [0] => stdClass Object ( [type] => publish_after_time [publish_after] => 2022-09-12 07:23:39 ) [1] => stdClass Object ( [type] => publish_before_time [publish_before] => 2022-10-12 23:59:00 ) [2] => stdClass Object ( [type] => plugins_activated [plugins] => Array ( [0] => google-listings-and-ads ) ) [3] => stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) [4] => stdClass Object ( [type] => product_count [operation] => > [value] => 76 ) [5] => stdClass Object ( [type] => order_count [operation] => > [value] => 38 ) [6] => stdClass Object ( [type] => total_payments_value [days] => last_year [value] => 3700 [operation] => > ) ) ) 2022-09-16T21:13:15+00:00 ERROR Spec is invalid because a rule is invalid in feed 2022-09-16T21:13:15+00:00 ERROR stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) 2022-09-16T21:13:15+00:00 ERROR stdClass Object ( [slug] => googlelistings_signals2022_noGLA [type] => marketing [status] => unactioned [is_snoozable] => 0 [source] => woocommerce.com [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [title] => Show off your products with Ads on Google [content] => You’re ready to grow with ads. Google optimizes for performance across your products; you only pay for results. If you’re new to Google, you can earn up to $500 in ad credits (T&Cs apply). <a href="https://woocommerce.com/my-account/create-a-ticket/">Contact support</a> if you need guidance with Google Listings & Ads. ) ) [actions] => Array ( [0] => stdClass Object ( [name] => googlelistings_signals2022_noGLA [locales] => Array ( [0] => stdClass Object ( [locale] => en_US [label] => Connect Google Listings & Ads ) ) [url] => https://woocommerce.com/products/google-listings-and-ads/?utm_medium=product&utm_source=inbox_note&utm_campaign=googlelistings_signals2022_noGLA [url_is_admin_query] => [is_primary] => 1 [status] => unactioned ) ) [rules] => Array ( [0] => stdClass Object ( [type] => publish_after_time [publish_after] => 2022-09-12 07:27:46 ) [1] => stdClass Object ( [type] => publish_before_time [publish_before] => 2022-10-12 23:59:00 ) [2] => stdClass Object ( [type] => not [operand] => Array ( [0] => stdClass Object ( [type] => plugins_activated [plugins] => Array ( [0] => google-listings-and-ads ) ) ) ) [3] => stdClass Object ( [type] => wcadmin_active_for [operation] => > [months] => 11 ) [4] => stdClass Object ( [type] => product_count [operation] => > [value] => 76 ) [5] => stdClass Object ( [type] => order_count [operation] => > [value] => 38 ) [6] => stdClass Object ( [type] => total_payments_value [days] => last_year [value] => 3700 [operation] => > ) ) )
Hi there @himself ??
It seems that woocommerce_shipping_chosen_method hooks isn’t working anymore since a recent update of WooCommerce ?
I was using
add_filter( ‘woocommerce_shipping_chosen_method’, ‘__return_false’, 99);
to have no shipping method selected by default on my shop, but it didn’t work anymore.
Is there any alternative ?
Could you try with the following code snippet? It goes in the function.php file of your active/child theme. Tested and works, as mentioned in this thread, where it was originally posted.
// Validate shipping method fields and return an error if none is chosen add_action( 'woocommerce_checkout_process', 'shipping_method_validation', 20 ); function shipping_method_validation() { if ( ! isset( $_POST['shipping_method[0]'] ) ){ wc_add_notice( __( "You need to choose a shipping option.", "woocommerce" ), 'error' ); } }
Additionally, if the above does not work, could you try the suggestion in this GitHub issue, please?
Let us know how it goes!
Hi, thank you for your interest to this issue.
The both solution you suggest have nothing related to this issue.
The 1st on only add a notice if no shipping method is selected… !
The 2nd has no impact on this.We want that there is NO shipping method selected/checked by default.
But the link you give, brings me to this reply :
that says “without local pickup”, it works !
And yed, by deactivating local pickup, the original solution works ( given in my 1st post ).But how can we make it works even with local pickup activated ?
Hi @himself
I tested the snippet you used and verified that it not working on my site provided that the customer is not yet registered.
Cart page:
Image Link: https://snipboard.io/GXmten.jpg
Checkout page:
Image Link: https://snipboard.io/sEkKVT.jpg
However, this hook is not working for registered customers.
These forums are meant for general support with the core functionality of WooCommerce itself. What you want to achieve would require customization to do it. 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 Expert
- The topic ‘woocommerce_shipping_chosen_methodwoocommerce_shipping_chosen_method alternative’ is closed to new replies.