隐藏"免费试用"来自Woocommerce订阅价格的文字

时间:2018-02-22 20:21:58

标签: php wordpress woocommerce price woocommerce-subscriptions

我试图通过XX天免费试用取消""从我的产品,购物车和结帐页面。我需要让该功能仍然有效,而无需在产品细节中表达。

1 个答案:

答案 0 :(得分:1)

可以使用过滤器钩子'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文件中。

经过测试和工作。

相关问题