• Resolved Alex

    (@doctor-doubledrop)


    Hello, I’m having issue with the paypal payment method in my site and I see that the conflict is caused by my theme.
    I wrote them and they said me:

    “There is js error – TypeError: Cannot read properties of undefined (reading ‘country_code’) – we would recommend you to contact the plugin support about this error.”

    And they send me this screen:
    https://postimg.cc/V0SfxHJz

    Can you kindly assist me with it?

    Thanks in advance for the support.

    Best Regards
    Alessandro

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Alex

    (@doctor-doubledrop)

    Update

    Theme support tell me this:
    “From the error, you can see that country_code is needed, and when Storefront is activated there are next fields available.?How you disable the country from checkout? Please enable it back and check paypal payments after that.”

    In this way the issue disappear, I always use my shop without the address fields because I sell digital products and I really don’t need them and I’m sure that is boring for a costumer write all that not necessary details.

    Also, guest costumers doesn’t need to insert them and paypal works well. Any suggestion about this thing? Is it normal? if yes, any way to bypass this allowing logged in users to make the order without the address fields?

    Thanks in advance

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @doctor-doubledrop

    In some instances, hiding the billing country field via CSS may provide better results compared to unsetting it with PHP:

    .woocommerce-checkout #billing_country_field {
        display: none;
    }

    Beyond this, configuring a Default customer location with Shop/country/region in the General WooCommerce settings may help in certain configurations, especially when unsettling the billing country field:

    Some payment providers may require billing data, but PayPal is not among them. However, the data sometimes may be structured in a format where PayPal expects it and then potentially throws an error when the expectations are not met (e.g. billing country field disabled).

    I don’t know if it helps in this case, but you could alternatively also try to just add this filter to your child theme functions.php file:

    add_filter( 'woocommerce_paypal_payments_basic_checkout_validation_enabled', '__return_true' );

    I hope this helps! Please let us know if the issue persists when using any of the suggestions above. Thanks!

    Kind regards,
    Niklas

    Thread Starter Alex

    (@doctor-doubledrop)

    Hello and thanks for the support.

    The filter doesn’t affect the checkout in any way.

    Hide the fields with css didn’t solve the problem, when I try to procede with the payment the site reports me that country, street, postcode, town and province are required fields.
    In addiction to those css I’ve added this filter:

    function unrequire_checkout_fields( $fields ) {
    $fields[‘billing’][‘billing_company’][‘required’] = false;
    $fields[‘billing’][‘billing_city’][‘required’] = false;
    $fields[‘billing’][‘billing_postcode’][‘required’] = false;
    $fields[‘billing’][‘billing_country’][‘required’] = false;
    $fields[‘billing’][‘billing_state’][‘required’] = false;
    $fields[‘billing’][‘billing_address_1’][‘required’] = false;
    $fields[‘billing’][‘billing_address_2’][‘required’] = false;
    return $fields;
    }

    And all seems to work fine now, I hope to have fixed the issue!

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @doctor-doubledrop

    If it works according to your needs, then it’s fine. I suggest thoroughly testing it (e.g. as guest or logged in user, new buyer, or repeat customer, etc.).
    This filter you mentioned adjusts the backend logic to allow certain checkout fields to be empty. But in the front, the fields are still marked as required with an asterisk.
    So to make it more clear these fields are optional, you could consider adding some custom CSS:

    /* Remove asterisk from specific checkout fields */
    #billing_company_field .required,
    #billing_city_field .required,
    #billing_postcode_field .required,
    #billing_country_field .required,
    #billing_state_field .required,
    #billing_address_1_field .required,
    #billing_address_2_field .required {
        display: none;
    }
    

    But that being said, normally PayPal Payments should also work fine in a setup where all of these fields are unset. But in that case, configuring a?Default customer location?with?Shop/country/region?in the General WooCommerce settings is often the preferred option.

    Since you mentioned it works for you now, I’ll mark this thread resoled, but feel free to reopen it if you have any additional questions. Thanks!

    Kind regards,
    Niklas

    Thread Starter Alex

    (@doctor-doubledrop)

    Hello and thanks for the update, if I understand well the last code you provided me is for remove asterisk in the checkout page which is viewed by the customer. So I don't need it since the costum css I told you I used for hide the fields is the following:
    
    .woocommerce-checkout #billing_address_1_field {
    display: none;
    }
    .woocommerce-checkout #billing_address_2_field {
    display: none;
    }
    .woocommerce-checkout #billing_country_field {
    display: none;
    }
    .woocommerce-checkout #billing_postcode_field {
    display: none;
    }
    .woocommerce-checkout #billing_state_field {
    display: none;
    }
    .woocommerce-checkout #billing_city_field {
    display: none;
    }
    
    About the "Default customer location".. if selected, will it appears in any area like costumer's invoice or e-mail? 
    
    Thanks in advance for your time.
    
    
    • This reply was modified 1 year, 6 months ago by Alex.
    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Yes, when you are hiding the fields, the CSS I mentioned would not be needed!

    When a default customer location is selected, it may be saved in the order and, subsequently, potentially in order confirmation emails or invoices. But it depends on your specific setup as this information could also be suppressed.

    I hope it all works as intended now. Please let us know if anything else is unclear.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Theme conflict’ is closed to new replies.