• Resolved Jayden Lawson

    (@jaydenl)


    Hi guys,

    How do you solve this common requirement:

    1. allow billing from any country
    2. restrict shipping to one country

    Currently – if shipping is restricted to one country, a customer is able to enter their billing details from any country (great), but then un-tick the “Deliver to a different address?” checkbox, and then they are able to submit the order (not great).

    I need them to be forced to enter a shipping address, which is then restricted to the one country.

    Seems simple, but doesn’t appear to be possible with standard options. Unless I’m wrong – please let me know.

    • This topic was modified 2 years, 5 months ago by Jayden Lawson.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Roxy

    (@roxannestoltz)

    Hi @jaydenl ,

    Thanks for reaching out!

    I understand that you are facing issues with shipping restrictions.

    Currently – if shipping is restricted to one country, a customer is able to enter their billing details from any country (great)

    This is not the default behavior for WooCommerce when selling to specific countries, as you should only be able to select the countries which have been included in the countries you sell to.

    As a first step, please check that the settings are correct by navigating to WooCommerce > Settings > General tab, scroll down to General options and check the following:

    Selling location(s) has Sell to specific countries selected
    – The required countries have been added in the Sell to specific countries box,
    Shipping location(s) has Ship to all countries you sell toselected, as seen in the screenshot below:

    https://snipboard.io/SBLYK4.jpg

    If these settings are correct, please share a copy of your sites System Status report by navigating to WooCommerce > Status. Select ‘Get system report’ and then ‘Copy for support’.

    Once you do this, you can paste your response here.

    Thanks!

    Thread Starter Jayden Lawson

    (@jaydenl)

    Thanks, Roxanne ??

    The issue is that some people wish to buy gifts for those in another country. For example, we only ship to Australia, but people from New Zealand buy gifts for their Australian relatives and friends.

    How can we make this happen?

    Roxy

    (@roxannestoltz)

    Hi @jaydenl ,

    Ah, I understand, thanks for providing clarity!

    In that case, what you could do is add the following snippet to your site:

    add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true' );

    This code will enable the checkbox to be checked. You need to add the code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the?Code snippets?plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

    Next, you can add custom CSS that modifies the pointer-events, which disables the checkbox function from being changed, so the user is forced to enter the shipping information. This CSS would be based around your site, however, would look something like this:

    label.woocommerce-form__label.woocommerce-form__label-for-checkbox.checkbox {
        pointer-events: none;
    }

    Please let me know how this goes ??

    Thread Starter Jayden Lawson

    (@jaydenl)

    Thank you. The snippet worked great, but I had trouble with the CSS code. This worked for me, and note that I changed the shipping heading, so it’s customised for Australia:

    #ship-to-different-address {
        pointer-events: none;
        cursor: not-allowed !important;
    }
    
    label[for=ship-to-different-address-checkbox] {
        visibility: hidden;
    }
    
    label[for=ship-to-different-address-checkbox]:after {
        content:'Australian Delivery Address'; 
        visibility: visible;
        display: block;
        color: #3fa9f5;
        font-family: "Open Sans", sans-serif;
        font-size: 20px;
    }
    
    #ship-to-different-address-checkbox {
        display: none;
    }
    • This reply was modified 2 years, 4 months ago by Jayden Lawson.
    Roxy

    (@roxannestoltz)

    Hi @jaydenl ,

    You are very welcome, glad to hear the snippet worked for you!

    This worked for me, and note that I changed the shipping heading, so it’s customised for Australia

    Awesome work with this, and thanks for sharing the code, it could be very helpful for others looking for the same fix ??

    Since this is now resolved, should you need any further help, please feel free to create a new topic.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Billing/Shipping logic not logical’ is closed to new replies.