php - 自定义 WooCommerce 订阅所有事物插件生成的“订阅选项”字符串
问题描述
我正在尝试在functions.php
之后添加文本subscription-price">
我可以通过直接代码编辑来做到这一点,但需要帮助才能在functions.php
不更改原始文件的情况下应用过滤器。
$option_description = apply_filters( 'wcsatt_single_product_subscription_option_description', '<span class="' . $option_price_class . ' subscription-price">Text Here' . $sub_price_html . '</span>', $sub_price_html, $has_price_filter, false === $force_subscription, $product, $subscription_scheme );
$option = array(
'class' => 'subscription-option',
'value' => $scheme_key,
'selected' => $default_subscription_scheme_option_value === $scheme_key,
'description' => $option_description,
'data' => $option_data
);
类似的东西
add_filter( 'wcsatt_single_product_subscription_option_description', 'add_custom_text_to_subscription_option');
function add_custom_text_to_subscription_option( $product) {
}
解决方案
这应该足够了,基本上你分配给$option_descreption
变量的任何东西都会显示出来
Your new text
根据您的需要替换此答案
function filter_wcsatt_single_product_subscription_option_description( $option_description, $sub_price_html, $has_price_filter, $force_subscription, $product, $subscription_scheme ) {
// Class
$option_price_class = 'subscription-option';
// New description
$option_description = '<span class="' . $option_price_class . ' subscription-price">Your new Text ' . $sub_price_html . '</span>';
return $option_description;
}
add_filter( 'wcsatt_single_product_subscription_option_description', 'filter_wcsatt_single_product_subscription_option_description', 10, 6 );
推荐阅读
- python - “无法加载图像”来自 Django 的媒体文件夹
- angular - ASP.NET Core 3 - Angular SPA PWA
- angular - 如何使用表单生成器以 Angular 8 获取系统日期
- python - pandas merge_asof:不明确的参数类型错误
- python - 如何在“for”循环中调节线程?
- c++ - c++看不懂string::iterator的语法
- firebase - 云消息(推送通知)
- c++ - 用字符串及其大小折叠表达式
- azure-sql-database - 如何从 Xamarin 应用程序同步 Azure 移动服务脱机同步
- react-native - 如何在 SwitchNavigator 中使用钩子