如何更改WooCommerce订阅中的价格字符串 [英] How do I change the price string in WooCommerce subscriptions

查看:124
本文介绍了如何更改WooCommerce订阅中的价格字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种更好的方法.

I need a better way to do this.

当前,我已经将代码直接添加到class-wc-subscriptions-product.php文件中的get_price_string函数中,因此,在设置免费试用版后,我可以更改要添加到价格字符串中的文本.

Currently, I have added code directly to the get_price_string function within class-wc-subscriptions-product.php file, so when a free trial is setup I can change the text being added to the price string.

这当然远非完美.

那么,有谁知道我需要添加到主题文件夹中的functions.php文件中的钩子才能执行相同的操作吗?

So, does anyone know what hook I need to add to the functions.php file in the theme's folder to be able to do the same thing?

推荐答案

这是我网站的非常简单的版本.我需要说每个季节"而不是每三个月".最简单的方法是创建一个插件:

Here is a VERY simple version for my site. I needed to have it say "per season" instead of "every 3 months". The simplest way was to create a plugin:

<?php
/**
 * Plugin Name: My Subscription Price Text
 * Description: Make it say "Every Season" instead of "Every 3 Months"
 * Author: green coder
 * Author URI: 
 * Version: 1.0
 * License: GPL v2
 */
function my_subs_price_string( $pricestring ) {

    $newprice = str_replace( 'every 3 months', 'per season', $pricestring );
return $newprice;

}
add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'my_subs_price_string' );

这篇关于如何更改WooCommerce订阅中的价格字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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