首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在WooCommerce Subscripitons中更改整个产品字符串

在WooCommerce Subscripitons中更改整个产品字符串
EN

Stack Overflow用户
提问于 2018-11-09 03:30:28
回答 1查看 483关注 0票数 0

我想在WooCommerce订阅中更改文本和价格字符串的顺序。现在上面写着:

每月$35.00,为期11个月,签证费$35.00。

我想说:

:第一个方框为35.00美元,每月1日为35.00美元,为期11个月。

我找到了以下代码,可以用来将“注册费”更改为“用于第一个框”:

代码语言:javascript
复制
 /* WooCommerce Subscriptions Price String */

 function wc_subscriptions_custom_price_string( $pricestring ) {
    $newprice = str_replace( 'sign-up fee', 'for the first box', $pricestring );
    return $newprice;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );

现在它写着“每个月的每月$35.00,每个月11个月,第一个盒子$35.00。”

我怎样才能更改订单?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-09 14:50:56

只需重新排序字符串,就可以将原始数据炸成数组:

代码语言:javascript
复制
function wc_subscriptions_custom_price_string( $pricestring ) {
   $replace_price = str_replace( 'sign-up fee', 'for the first box', $pricestring );
   $aPrice = explode(" and a ", $replace_price);
   $newprice = $aPrice[1] . " and then " . $aPrice[0]; 
   $finalprice = str_replace(" on "," +shipping on ", $newprice);
   return finalprice;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );

请参阅:爆炸()

或者如果你想变的花哨

代码语言:javascript
复制
$newprice = implode(" and then ", array_reverse($aPrice));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53219447

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档