Hello @talharafique,
I have no experience with the Klaviyo plugin but seems like your findings are correct, the woocommerce_checkout_fields hook is not fired when the checkout page is handled via blocks.
I’m afraid this falls under customization which is not within our scope of support.
If you have experience with PHP you can replace the hook above with conditional logic using is_checkout() which will work with the checkout page regardless.
Alternatively, you can ask the Klaviyo team to add support for WooCommerce blocks by utilizing one of the mentioned hooks in this guide: https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/third-party-developers/extensibility/README.md#hooks-actions-and-filters
Hope this helps! :)
Thread Starter
Talha
(@talharafique)
if (isset($klaviyo_settings['klaviyo_subscribe_checkbox']))
{
// Add the checkbox field
add_filter('woocommerce_checkout_fields', 'kl_checkbox_custom_checkout_field', 11);
// Post list request to Klaviyo
add_action('woocommerce_checkout_update_order_meta', 'kl_add_to_list');
}
This is how they add checkboxes at the end of billing_feild.
the use Filter function on ‘woocommerce_checkout_fields’ hook.
are you not using this hook in this plugin ????
-
This reply was modified 2 years, 11 months ago by
Talha. Reason: simplifies the code for better understand how they are using filter on checkout feilds
Hello,
While I understand you are looking for a solution, please note, development topics are out of our scope of support. However, I’m going to leave the thread open for a bit to see if anyone is able to chime in to help you out.
I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.
You can visit as well the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack, to get more information, or a developer to work with you.
Kind regards.
Hi,
We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.
Best.