Skip Navigation

[Resolved] WC Button filters not applied on Toolset output

This support ticket is created 3 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by smileBeda 3 years, 12 months ago.

Assisted by: Waqar.

Author
Posts
#1862289

I am trying to:
Apply native WC woocommerce_product_single_add_to_cart_text filter to Add To Cart Button in Toolset Output Mode.

I expected to see:
Altered Add To Cart Button Text as per my filter

Instead, I got:
Button text as set by Block (Add To Cart Text setting in Toolset WC Add To Cart Button with Toolset output mode)

I am aware that Toolset effectively knocks out all native WC filters and for most I was able to find the Toolset "replacement" (it does this also on login forms and such, which is really a bit of a pain until one realises that for most native filters there is a toolset filter)

But for the button I was not able to find it.
Do you have a filter we can use?

Otherwise I'll just fallback to a lot of WPV Conditions which is not really ideal taking in account performance of WPV Conditional is not the best (compared to a simple and single filter..)

Thanks!

#1862565

Hi Beda,

Thank you for contacting us and I'd be happy to assist.

I've performed some tests and here and my findings:

1. I included the following code in the active theme's "functions.php" file for the "woocommerce_product_single_add_to_cart_text" filter:


add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_cat_add_to_cart_text' );
function custom_cat_add_to_cart_text( $default ) {
    $default = 'Some text';
    return $default;
}

2. Next, in the single product content template, I added the "Add to Cart Button" block and it showed the same "Some text" from the filtering function, as the button's text.
( with "Toolset’s Custom Output" selected in the block's settings )

3. After that I added, "Some more text" in the block's "Simple products: Add to Cart label" field, under the button section and it overrode the text from the filtering function and started showing, instead.

To me, this makes sense. If you'd like to use the text label from the filter, you can keep the "Simple products: Add to Cart label" field empty and if you'd like to show some different text, you can fill it in the field.

I hope this helps and please let me know if you're seeing different results.

regards,
Waqar

#1862625

Thanks Waqar, I indeed had a value saved in the "Simple products: Add to Cart label" setting and didn't consider removing it (I basically forgot I had saved the value there in the block during experimenting around).

Makes sense that it overwrites the filter.