• Resolved methnen

    (@methnen)


    Would be great if there were woocommerce_billing_fields and so forth style filter hooks available.

    I have a woocommerce_billing_fields filter that I’m using to dynamically set a default value and this plugin breaks it completely.

    Otherwise the plugin has been a great time saver!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    You can add the custom classes for the fields by providing it in the option Class and can add the style accordingly. You can provide the class with comma separation.

    Please refer to the below screen-shot.

    https://prnt.sc/p496ld

    Hope this help.

    If we have misunderstood your exact issue, please clarify us with more details.

    Thank you!

    Thread Starter methnen

    (@methnen)

    Yeah I wasn’t talking about styling things.

    I am dynamically setting the default values of some inputs based on some values in the URL using the woocommerce_billing_fields hook.

    Since your plugin will always override those values I set regardless of what priority I use on my filter it’s a problem.

    Adding a hook to your own code would fix this issue.

    Thread Starter methnen

    (@methnen)

    For example adding these lines to your plugin rectified the issue:

    Line 124 of class-thwcfd-checkout.php:

    $fields = $this->prepare_address_fields(get_option('wc_fields_billing'), $fields, 'billing', $country);
    return apply_filters( 'thwcfd_billing_fields', $fields );

    Line 133 of class-thwcfd-checkout.php:

    $fields = $this->prepare_address_fields(get_option('wc_fields_shipping'), $fields, 'shipping', $country);
    return apply_filters( 'thwcfd_shipping_fields', $fields );

    Line 160 of class-thwcfd-checkout.php:
    return apply_filters( 'thwcfd_checkout_fields', $fields );

    I was then able to add basically the same filter I had before to those hooks and was again able to set dynamic input values.

    • This reply was modified 5 years, 2 months ago by methnen.
    • This reply was modified 5 years, 2 months ago by methnen.
    Plugin Author ThemeHigh

    (@themehigh)

    You can use the default WooCommerce hooks to override the values. But you need to provide higher priority (a higher value greater than 1000) for your filter.

    Below is an example code to override the billing fields, placeholder value and default value.

    function modify_billing_fields($fields){
        $fields['billing_company']['label'] = 'Business Names';
        $fields['billing_company']['default'] = 'Google';
        
        return $fields;
    }
    add_filter('woocommerce_billing_fields', 'modify_billing_fields', 1001);

    Please note that you need to use the hook woocommerce_billing_fields to override billing fields and woocommerce_shipping_fields hook to override shipping fields and woocommerce_checkout_fields hook to override additional fields.

    Hope this help.

    Thank you

    Thread Starter methnen

    (@methnen)

    Would you believe I tried setting the priority all the way up to 999 and then gave up? ??

    That does indeed work. Thanks.

    Plugin Author ThemeHigh

    (@themehigh)

    Our default priority is 999 ??

    We are glad to hear that your issue is resolved.

    Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘need a woocommerce_billing_fields style filter hook’ is closed to new replies.