通过过滤器自定义WooCommerce请求报价消息(Customize WooCommerce Request a Quote message via filter)

编程入门 行业动态 更新时间:2024-10-26 14:30:50
通过过滤器自定义WooCommerce请求报价消息(Customize WooCommerce Request a Quote message via filter)

我正在尝试自定义WooCommerce Request-a-quote插件,我无法更改过滤器。 这个插件使用JS Ajax,以及PHP重新加载。

这是插件文件类中的代码,它不在templates文件夹中:

if ( $return == 'true' ) { $message = apply_filters( 'yith_ywraq_product_added_to_list_message', __( 'Product added!', 'yith-woocommerce-request-a-quote' ) ); } elseif ( $return == 'exists' ) { $message = apply_filters( 'yith_ywraq_product_already_in_list_message', __( 'Product already in the list.', 'yith-woocommerce-request-a-quote' ) ); } elseif ( count( $errors ) > 0 ) { $message = apply_filters( 'yith_ywraq_error_adding_to_list_message', $this->get_errors($errors) ); }

在主题function.php中,我把它放在:

function change_message() { $message = 'Enquiry Added!'; echo apply_filters( 'yith_ywraq_product_already_in_list_message', $message ); } add_filter('yith_ywraq_error_adding_to_list_message', 'change_message');

但我不能让它改变文本,它仍然是一样的。 我不明白我错过了什么,有人能指出它吗?

提前致谢。

阿迪

I am trying to customise WooCommerce Request-a-quote plugin, and i cannot get a filter to change. This plugin uses JS Ajax, as well as PHP reload.

This is the code in the plugin file class, which is not within the templates folder:

if ( $return == 'true' ) { $message = apply_filters( 'yith_ywraq_product_added_to_list_message', __( 'Product added!', 'yith-woocommerce-request-a-quote' ) ); } elseif ( $return == 'exists' ) { $message = apply_filters( 'yith_ywraq_product_already_in_list_message', __( 'Product already in the list.', 'yith-woocommerce-request-a-quote' ) ); } elseif ( count( $errors ) > 0 ) { $message = apply_filters( 'yith_ywraq_error_adding_to_list_message', $this->get_errors($errors) ); }

In the theme function.php, I have put this:

function change_message() { $message = 'Enquiry Added!'; echo apply_filters( 'yith_ywraq_product_already_in_list_message', $message ); } add_filter('yith_ywraq_error_adding_to_list_message', 'change_message');

But i cannot make it change the text, it remains the same. I do not see what I am missing, can anyone point to it ?

Thanks in advance.

Addy

最满意答案

你不是很远,你需要返回$ message,

function change_message() { $message = 'Enquiry Added!'; return $message; } add_filter('yith_ywraq_error_adding_to_list_message', 'change_message');

请注意,此操作只会更改错误消息。

You were not to far away, you need to return $message,

function change_message() { $message = 'Enquiry Added!'; return $message; } add_filter('yith_ywraq_error_adding_to_list_message', 'change_message');

Note with this action, you will only change the error message.

更多推荐

本文发布于:2023-07-28 23:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1310171.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   过滤器   消息   WooCommerce   Customize

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!