自定义由 WooCommerce 订阅所有事物插件生成的“订阅选项"字符串 [英] Customize “subsription option” string generated by WooCommerce Subscribe All The Things plugin

查看:17
本文介绍了自定义由 WooCommerce 订阅所有事物插件生成的“订阅选项"字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 functions.php 添加文本,就在 subscription-price">

I am trying to add text through functions.php just after subscription-price">

我可以通过直接编辑代码来做到这一点,但需要帮助才能通过 functions.php 应用过滤器,而无需更改原始文件.

I can do this with direct code editing, but need help to apply filter through functions.php without changing orignal files.

$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 变量的任何东西都会显示

This should suffice, basically anything you assign to the $option_descreption variable will be displayed

根据您的需要替换此答案中的您的新文本

Replace Your new text in this answer, depending on your needs

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 );

这篇关于自定义由 WooCommerce 订阅所有事物插件生成的“订阅选项"字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆