dongtou8736 2016-01-29 00:06
浏览 7

Woocommerce订阅字符串

My site:

https://www.fytso.com/lifestyle

I have 3 subscription options:

  1. Monthly - Charged at $49.95 per month until customer cancels
  2. 3-Month - Charged $138.85 at signup and then $49.95 per month after those first 3 months have passed.
  3. 6-Month - Charged $274.70 at signup and then $49.95 per month after those first 6 months have passed.

Settings for (1) are straightforward. Simple $49.95 per month for all time.

Setting for (2 & 3) are:

$138.85 Signup Fee with a Free 3-month trial and then $49.95 monthly. For the 6-Month, it's $274.70 Signup Fee with a 6-month free trial and then $49.95 monthly.

It's the only way I could configure those settings for them to work the way I need them to.

Now, the 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string' display info by default that's just downright confusing for my customers. So this need to be modified.

I managed to eliminate the displayed prices and strings on the Home Page with a filter (and I can live with that) but my problem is, that if a customer adds the item to their cart, those prices also don't display on the Cart Page.

Screencap: https://imgur.com/bS7HIGf

So, even though this seems like a simple problem to solve, I can't get it done and need a bit of help.

The other alternative is to just display the subscription price on the Home Page. That however causes our Monthly option to display $0 since the settings that allow just the subscription price to display, is applied globally through the simple filter I'm using.

Targeting that by product (if possible) might solve it. But again, it's something that I'm having trouble with implementing.

The filter I'm using, I found here and it looks like this right now:

add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string', 10, 3 );

function my_subs_price_string( $subscription_string, $product, $include ) {

    /****
    var_dump($product); Various variables are available to us
    ****/

    return ' Renews at ' . wc_price( $product->subscription_price );
}

Obviously wrong as it stands. Help appreciated.

Ideally, these option would display:

  1. $49.95
  2. $138.85
  3. $274.70
  • 写回答

1条回答 默认 最新

  • dongqiang2069 2016-01-29 02:56
    关注

    The solution was actually simple. Staring me right in the face.

    I simply changed the Monthly option settings to:

    $49.95 Signup Fee with a 30-day free trial. So it's similar to the 3-month and 6-month options. Now my little filter looks like this:

    add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string', 10, 3 );
    
    function my_subs_price_string( $subscription_string, $product, $include ) {
    
        /****
        var_dump($product); Various variables are available to us
        ****/
    
        return '' . wc_price( $product->subscription_sign_up_fee );
    }
    

    My prices on the Home Page and in the cart are displaying correctly. I.e. the signup fee that they will be charged upon signup and my recurring charges will begin 30, 60 and 180 days after that first signup.

    Voila!

    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教