Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author ulihake

    (@ulih)

    Hello c00kiemon5ter.

    I will check this over the weekend…

    Regards.
    uh

    Plugin Author ulihake

    (@ulih)

    Please provide some additional information on that or a link. I cannot reproduce this problem.

    Thanks.

    uh

    Plugin Author ulihake

    (@ulih)

    Hello again.

    There were no other reports with label problems. Hopefully it’s working for you now. I will close this ticket but feel free to open another one if your problems persist.

    Regards.
    uh

    Can I add to this one? Getting the same problem, where the plain HTML is generated fine, but then there is a javascript that runs on the page localizing the fields back to the old version.

    eg. on my /checkout/ page, I removed all mentions of Zip code and the HTML generated is correctly just “Postcode”

    <p class="form-row form-row-last address-field validate-required validate-postcode" id="billing_postcode_field"><label for="billing_postcode" class="">Postcode <abbr class="required" title="required">*</abbr></label><input type="text" class="input-text " name="billing_postcode" id="billing_postcode" placeholder="Postcode" value=""/>

    Also generated in the html (beyond the footer) is this json object which is used by some javascript to rewrite all of the fields and hints.

    <script type='text/javascript'>//<![CDATA[
    var wc_address_i18n_params={"locale":"{\"default\":{\"country\":{\"type\":\"country\",\"label\":\"Country\",\"required\":true,\"class\":[\"form-row-wide\",\"address-field\",\"update_totals_on_change\"]},\"first_name\":{\"label\":\"First Name\",\"required\":true,\"class\":[\"form-row-first\"]},\"last_name\":{\"label\":\"Last Name\",\"required\":true,\"class\":[\"form-row-last\"],\"clear\":true},\"company\":{\"label\":\"Company Name\",\"class\":[\"form-row-wide\"]},\"address_1\":{\"label\":\"Address\",\"placeholder\":\"Street address\",\"required\":true,\"class\":[\"form-row-wide\",\"address-field\"]},\"address_2\":{\"placeholder\":\"Apartment, suite, unit etc. (optional)\",\"class\":[\"form-row-wide\",\"address-field\"],\"required\":false},\"city\":{\"label\":\"Town \\\/ City\",\"placeholder\":\"Town \\\/ City\",\"required\":true,\"class\":[\"form-row-wide\",\"address-field\"]},\"state\":{\"type\":\"state\",\"label\":\"State \\\/ County\",\"placeholder\":\"State \\\/ County\",\"required\":true,\"class\":[\"form-row-first\",\"address-field\"],\"validate\":[\"state\"]},\"postcode\":{\"label\":\"Postcode \\\/ Zip\",\"placeholder\":\"Postcode \\\/ Zip\",\"required\":true,\"class\":[\"form-row-last\",\"address-field\"],\"clear\":true,\"validate\":[\"postcode\"]}},\"AU\":{\"country\":{\"type\":\"country\",\"label\":\"Country\",\"required\":true,\"class\":[\"form-row-wide\",\"address-field\",\"update_totals_on_change\"]},\"first_name\":{\"label\":\"First Name\",\"required\":true,\"class\":[\"form-row-first\"]},\"last_name\":{\"label\":\"Last Name\",\"required\":true,\"class\":[\"form-row-last\"],\"clear\":true},\"company\":{\"label\":\"Company Name\",\"class\":[\"form-row-wide\"]},\"address_1\":{\"label\":\"Address\",\"placeholder\":\"Street address\",\"required\":true,\"class\":[\"form-row-wide\",\"address-field\"]},\"address_2\":{\"placeholder\":\"Apartment, suite, unit etc. (optional)\",\"class\":[\"form-row-wide\",\"address-field\"],\"required\":false},\"city\":{\"label\":\"Town \\\/ City\",\"placeholder\":\"Town \\\/ City\",\"required\":true,\"class\":[\"form-row-wide\",\"address-field\"]},\"state\":{\"type\":\"state\",\"label\":\"State \\\/ County\",\"placeholder\":\"State \\\/ County\",\"required\":true,\"class\":[\"form-row-first\",\"address-field\"],\"validate\":[\"state\"]},\"postcode\":{\"label\":\"Postcode \\\/ Zip\",\"placeholder\":\"Postcode \\\/ Zip\",\"required\":true,\"class\":[\"form-row-last\",\"address-field\"],\"clear\":true,\"validate\":[\"postcode\"]}}}","locale_fields":"{\"address_1\":\"#billing_address_1_field, #shipping_address_1_field\",\"address_2\":\"#billing_address_2_field, #shipping_address_2_field\",\"state\":\"#billing_state_field, #shipping_state_field\",\"postcode\":\"#billing_postcode_field, #shipping_postcode_field\",\"city\":\"#billing_city_field, #shipping_city_field\"}","i18n_required_text":"required"};
    //]]></script>

    This json object is built in /woocommerce/includes/class-wc-frontend-scripts.php L223 (in version 3.1.3). the lines are:

    wp_localize_script( 'wc-address-i18n', 'wc_address_i18n_params', apply_filters( 'wc_address_i18n_params', array(
                            'locale'                    => json_encode( WC()->countries->get_country_locale() ),
                            'locale_fields'             => json_encode( WC()->countries->get_country_locale_field_selectors() ),
                            'i18n_required_text'        => esc_attr__( 'required', 'woocommerce' ),
                    ) ) );

    I have not figured out how to use a filter/hook to bypass or use the correct “Poor Guy’s Swiss Knife” defaults for this, so I am for the time being just encoding an empty string for the locale property (ie replace WC()->countries->get_country_locale() with ”). That preserves the validation but stops the field names being replaced. Of course, it completely breaks internationalization of the checkout.

    I hope that helps someone.

    Ha, doing what I suggested makes the javascript that does replacement throw an exception and that goes on to break some other script on the page, so instead of replacing with an empty string, replacing the locale data with the following works a bit better for me.

    'locale' => json_encode( array('default' => array()) ),

    This is making me think that I am misusing your plugin for this purpose.

    Plugin Author ulihake

    (@ulih)

    Please update to 1.8.0. This should fix some of the issues with labels, etc.

    uh

    That’s perfect! I don’t need my hack any longer. Thank you ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Checkout billing/shipping labels not applying with WC 2.1.0’ is closed to new replies.