【发布时间】:2018-08-02 20:11:51
【问题描述】:
我正在尝试从我的产品、购物车和结帐页面中删除“免费试用 XX 天”。我需要让该功能仍然有效,而不必在产品详细信息中表达。
【问题讨论】:
标签: php wordpress woocommerce price woocommerce-subscriptions
我正在尝试从我的产品、购物车和结帐页面中删除“免费试用 XX 天”。我需要让该功能仍然有效,而不必在产品详细信息中表达。
【问题讨论】:
标签: php wordpress woocommerce price woocommerce-subscriptions
可以为这个钩子函数使用过滤器钩子'woocommerce_subscriptions_product_price_string',这样:
add_filter( 'woocommerce_subscriptions_product_price_string', 'subscriptions_custom_price_string', 20, 3 );
function subscriptions_custom_price_string( $price_string, $product, $args ) {
// Get the trial length to check if it's enabled
$trial_length = get_post_meta( $product->get_id(), '_subscription_trial_length', true );
if( $trial_length > 0 )
$price_string = $args['price'];
return $price_string;
}
代码进入您的活动子主题(或主题)的 function.php 文件中。
经过测试并且有效。
【讨论】: