• Resolved palactig

    (@palactig)


    Hi everyone,

    Recently I added this code to my functions.php:

    /**
     * Change the default country on the checkout for non-existing users only
     */
    add_filter( 'default_checkout_billing_country', 'change_default_checkout_country', 10, 1 );
    
    function change_default_checkout_country( $country ) {
        // If the user already exists, don't override country
        if ( WC()->customer->get_is_paying_customer() ) {
            return $country;
        }
    
        return 'NL'; // Override default to Netherlands
    }

    But now my logs get spammed with this:
    2021-08-17T00:07:07+00:00 DEBUG Billing Country is not valid.
    NL is a valid country code, so I don’t get what is going wrong here.

    Kind regards,
    Palactig

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @palactig,

    The message Billing Country is not valid. does not refer to NL as a country code but instead to an empty one. Otherwise, it would say Billing Country NL is not valid..
    So in this case, the function may cause the billing country to be empty in certain cases when the plugin performs some checks.
    We have plans to rework the logic behind this, but I will consult with our developers to learn about how the function impacts checks within the plugin.
    Without the if statement, the message will not appear in the logs it seems.
    I don’t think it causes any issues in general, but will let you know when I have more information.

    Kind regards,
    Niklas

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    We have tried a different filter, though it was causing the same log entries. But it does appear to work as intended with no negative side effects despite the log entries.
    On your production site, you may want to disable logging either way.
    So this behavior will probably only be resolved after we reworked this feature.
    I can’t quite tell when that will happen as this is not breaking anything as of now.

    If you have any further questions, please feel free to reopen this topic or create a new one.
    Thank you! ??

    Kind regards,
    Niklas

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Billing Country Not Valid’ is closed to new replies.