• Resolved morvy

    (@morvy)


    I get a lot of these errors in the error log. Everything seems to be working fine, but errors drain my Sentry quota and I believe they should be handled silently if they don’t cause issues in API response.

    I can’t test without plugins or on storefront theme. Shop is connected to external system through API and I can’t connect dev to this system.

    ErrorException: Warning: Undefined array key "ignore_discounts"
    #14 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php(387): WC_REST_Shipping_Zone_Methods_V2_Controller::get_settings
    #13 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php(354): WC_REST_Shipping_Zone_Methods_V2_Controller::prepare_item_for_response
    #12 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php(146): WC_REST_Shipping_Zone_Methods_V2_Controller::get_items
    #11 /wp-includes/rest-api/class-wp-rest-server.php(1181): WP_REST_Server::respond_to_request
    #10 /wp-includes/rest-api/class-wp-rest-server.php(1028): WP_REST_Server::dispatch
    #9 /wp-includes/rest-api/class-wp-rest-server.php(442): WP_REST_Server::serve_request
    #8 /wp-includes/rest-api.php(410): rest_api_loaded
    #7 /wp-includes/class-wp-hook.php(308): WP_Hook::apply_filters
    #6 /wp-includes/class-wp-hook.php(332): WP_Hook::do_action
    #5 /wp-includes/plugin.php(565): do_action_ref_array
    #4 /wp-includes/class-wp.php(399): WP::parse_request
    #3 /wp-includes/class-wp.php(780): WP::main
    #2 /wp-includes/functions.php(1334): wp
    #1 /wp-blog-header.php(16): require
    #0 /index.php(17): null
Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi @morvy

    Thanks for reaching out!

    I’m sorry to hear that you’re experiencing an issue with your WooCommerce store.

    Based on the error logs, it appears that there might be an issue with the shipping zone methods in your WooCommerce installation. The error is related to the ignore_discounts array key not being defined in the class-wc-rest-shipping-zone-methods-v2-controller.php file.

    To help resolve this issue, please follow the steps below:

    1. First, ensure that you’re using the latest version of WooCommerce under Plugins > Installed Plugins. If an update is available, please update WooCommerce to the latest version.
    2. If you’re already using the latest version of WooCommerce or the issue persists after updating, try disabling all other plugins except for WooCommerce and switch to the default Storefront theme to see if there’s a conflict. If the issue is resolved, you can then enable the plugins one by one to identify the conflicting plugin.
    3. If none of the above steps resolve the issue, it’s possible that there’s a problem with the WooCommerce core files. In this case, I would recommend creating a backup of your website and then reinstalling WooCommerce.

    If the issue still persists after trying the solutions above, please share your System Status Report that you can find via WooCommerce > Status. Select Get system report and then Copy for support. Once you’ve done that, you can paste it into your reply here.

    Thanks!

    Thread Starter morvy

    (@morvy)

    Hi,

    as I wrote, I cannot afford switching theme or disable plugins to debug this issue which occurs only when communicating through REST API.

    Is there anything I can log so it will tell me where this “ignore_discounts” is missing? I can put some woo logger calls in the code, but I can’t find where it comes from. Only thing I found (and is missing since 2.6) is missing definition of this var in WC_Shipping_Free_Shipping class.

    HI @morvy

    as I wrote, I cannot afford switching theme or disable plugins to debug this issue which occurs only when communicating through REST API.

    I totally understand you here, hence, another workaround would be to cloning your site to a staging environment 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.

    Is there anything I can log so it will tell me where this “ignore_discounts” is missing? I can put some woo logger calls in the code, but I can’t find where it comes from. Only thing I found (and is missing since 2.6) is missing definition of this var in WC_Shipping_Free_Shipping class.

    This is a bit of a complicated topic that would need some customization to address. Unfortunately, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

    Thread Starter morvy

    (@morvy)

    Hello,

    as I wrote, I simply cannot test themes and plugins on/off on this site. I can do some logging, edit Woo files to log something more, but I cannot play around with it and I cannot use a staging site because that is not connected to the external service which uses the API.

    Is this even coming from Woo core, or is it possible that this variable should be set in every custom shipping method and this causes the issue?

    Saif

    (@babylon1999)

    Hello @morvy,

    because that is not connected to the external service which uses the API.

    I understand that you are unable to perform a conflict test at the moment since your site is currently serving customers. Could you please share with us the API implementation details so we can attempt to replicate this issue on our end?

    By API implementation, I am referring to the POST/GET calls being used, not the code of the plugin or service. You can take a look at the API documentation for more context.

    Additionally, the error mentioned above is just a warning, meaning it won’t break the site and is more of a reminder that things might go wrong in the future, but I understand how it can be concerning regardless.

    Look forward to hearing back from you.


    same here @morvy , did you solve this? please share!

    Thread Starter morvy

    (@morvy)

    Hi @tva3777 , no I’m still having the issue. It happens when the external system downloads new orders, I checked with them and they use the standard API functionality, no custom stuff.

    I found missing property definiton ($ignore_discounts) in free shipping class, but that doesn’t solve the issue.

    Thread Starter morvy

    (@morvy)

    @tva3777 just found something (maybe) useful.

    Try to open each Free Shipping method in each shipping zone and resave it (without any changes, just click SAVE). I just did this in my local installation and the error is gone.

    @xue28 @babylon1999 this API call is causing the issue (4 is ID of the zone I resaved and got rid of the error):
    /wp-json/wc/v3/shipping/zones/4/methods

    Hey there @morvy,

    Thank you so much for adding your input! Some of our customers might indeed find this guide helpful!

    We appreciate you being an active part of the community ??

    Does this also work on your store, @tva3777 ?

    Have a wonderful day, everyone!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘REST API: Undefined array key “ignore_discounts”’ is closed to new replies.