• Resolved WordPress-Thinking

    (@gregthegreg5)


    Hello everyone!

    This is something specific for the choose the province in Canada/State in the USA during the checkout process.

    Currently in Canada for example; on the dropdown menu, it shows us

    “Alberta”

    How can we edit the text for this to show something else? Like, Alberta – AB

    or if in the USA, instead of “Arizona” – for it to show = Arizona – AZ

    Basically editing it, so it shows something else (custom) versus the default settings.

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @gregthegreg5

    To achieve this, you would need to use a filter to alter the state names. Here is a code snippet shared that you can use to accomplish this: https://woocommerce.com/document/addmodify-states/

    I hope this helps! Let us know if you have any other questions.

    Thread Starter WordPress-Thinking

    (@gregthegreg5)

    Hello @shameemreza

    Thanks for the information! Would this work for Canadian Websites? Canada has “Provinces” not states.

    For example, currently it says “Ontario” on the province section where we choose them from. Can we change this to “Ontario – ON”?

    Is it possible for you to share an example on what this would look like (in terms of the code which is on the link you shared)?

    Thank you once again for your help and support!

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @gregthegreg5

    Yes, the same principle applies to Canadian provinces as well. You can certainly change “Ontario” to “Ontario – ON” using the same filter. Here’s an example of how the code would look:

    add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
    function custom_woocommerce_states( $states ) {
    $states['CA'] = array(
    'ON' => __( 'Ontario - ON', 'woocommerce' ),
    // Add other provinces here...
    );
    return $states;
    }

    This code will replace the default province name with your custom one. You can add more provinces to the array in the same format. Remember to place this code in your child theme’s functions.php file.

    Please note that writing or providing custom code is not within the scope of our support policy. If you are still having problems, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

    Thread Starter WordPress-Thinking

    (@gregthegreg5)

    Thanks @shameemreza, will test it out.

    Will this however effect the taxes that it calculates?

    Thanks once again for your support!

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @gregthegreg5

    That code snippet will only change the visual representation of the provinces or states on your website; it will not affect how taxes are calculated. The taxes are calculated based on the underlying value, not the label displayed, so you should not experience any issues with tax calculations.

    However, as always, it’s a good idea to thoroughly test any changes you make to ensure they’re working as expected. Please don’t hesitate to reach out if you encounter any issues or need further assistance.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Editing the provinces/state drop down menu section (checkout page)’ is closed to new replies.