0
在产品页面中获取客户输入的字数。计算产品附加固定金额的金额为每500字以上额外10美元。Woocommerce根据客户在产品页面输入的金额计算金额
例如:530 正常价格+附加价格:$ 180 + $ 10 总计:$ 190
- 词数:1040 普通1.字数价格+附加价格:180 $ + 20 $ 总计:200 $
此过程为创建动态输入表格客户计算金额的价格和总金额。
`$extra_amount = (int)'10';
$amount = (int)'180'; // how to get amount from woocommerce data
if(isset($_POST['wordnumber'])){ // how to get this paramater form woocommerce post values
$test =$_POST['wordnumber'];
$original_amount = '';
if($test <= (int)'500'){
$original_amount = $amount;
}
elseif($test > (int)'500'){
$div_amount = $test/(int)'500';
$round = floor($div_amount);
//echo '<br/>';
$total_extra = $round*$extra_amount;
$original_amount = $amount+$total_extra;
}
echo $original_amount;
}`
请你分享一下你的代码,以便我们可以帮助你! –
这是我尝试嵌入到woocommerce中的代码 – nishanthi