Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • The issue can be seen on the demo site too when the main shop page has only two items for example:

    https://themes.fruitfulcode.com/fruitful/shop/?min_price=10&max_price=12

    On the product category pages however, it seems fine to have 2 products.

    Also I found that if font size for ‘P’ is too big (like 18pt) I only get two products per row.

    Thanks for the theme!

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

    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.

    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.

Viewing 4 replies - 1 through 4 (of 4 total)