我想在WooCommerce订阅中更改文本和价格字符串的顺序。现在上面写着:
每月$35.00,为期11个月,签证费$35.00。
我想说:
:第一个方框为35.00美元,每月1日为35.00美元,为期11个月。
我找到了以下代码,可以用来将“注册费”更改为“用于第一个框”:
/* 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。”
我怎样才能更改订单?
发布于 2018-11-09 14:50:56
只需重新排序字符串,就可以将原始数据炸成数组:
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' );请参阅:爆炸()
或者如果你想变的花哨
$newprice = implode(" and then ", array_reverse($aPrice));https://stackoverflow.com/questions/53219447
复制相似问题