• Resolved thinkingcapstudios

    (@thinkingcapstudios)


    I want to hide the checkbox for a particular role.

    Placing the following line in the “woocommerce_checkout_fields” or “woocommerce_billing_fields” filter doesnt seem to make a difference.

    unset($fields[‘kl_newsletter_checkbox’]);
    or
    unset($fields[‘billing’][‘kl_newsletter_checkbox’]);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author klaviyo

    (@klaviyo)

    Hi @thinkingcapstudios

    There are a few options for how to remove the checkbox for a specific role. If you’d like to hook into the woocommerce_billing_fields filter just make sure you’re using a priority that is lower (higher integer) than 11 which Klaviyo uses when creating the custom field so the field exists before trying to unset it. Here’s an example:

    add_filter( 'woocommerce_checkout_fields', 'remove_kl_checkout_by_role', 12 );

    Using unset($fields['billing']['kl_newsletter_checkbox']); and then returning $fields will work as expected.

    Alternatively, you can remove the filter entirely. If you prefer this route please match the priority in the remove_filter call. Here’s an example:

    remove_filter( 'woocommerce_checkout_fields', 'kl_checkbox_custom_checkout_field', 11 );

    Please let us know if you encounter any other issues conditionally removing this custom field.

    Best,
    Scott

    Thread Starter thinkingcapstudios

    (@thinkingcapstudios)

    AH yes, forgot about priority – that works.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hiding checkbox for role’ is closed to new replies.