[英]How To Show Total Cart Order Amount In Desctiption Payment Method in WooCommerce
I want to add a HTML Description to a Payment Method in WooCommerce.我想在 WooCommerce 中的付款方式中添加 HTML 说明。
add_filter( 'woocommerce_gateway_description', 'rudr_change_payment_gateway_description', 25, 2 );
function rudr_change_payment_gateway_description( $description, $gateway_id ) {
if( 'pec_gateway_check' === $gateway_id ) {
?>
<div class="mcpec-text">
<span class="mcp-item">مبلغ پرداختی آنلاین شما:<span class="mcp-item-inner"> <!--1 total order * 35% --> </span></span>
<span class="mcp-item">مبلغ چک صیادی:<span class="mcp-item-inner"> <!--2 total order * 65% --> </span></span>
<span class="mcp-item">تاریخ چک صیادی:<span class="mcp-item-inner"> <!--3 The date is 40 days later --> </span></span>
</div>
<?php
$description = '';
}
return $description;
}
I want to display the total shopping cart in this description as below:我想在此描述中显示购物车总数,如下所示:
1- total order * 35% = amount+$ (example= 35,000$) 1- 订单总额 * 35% = 金额+$(示例= 35,000$)
2- total order * 65% = amount+$ (example= 65,000$) 2- 订单总额 * 65% = 金额+$(示例= 65,000$)
3- The date is 40 days later = today+40 days later (example= 2022/10/16) 3- 日期是 40 天后 = 今天 + 40 天后(示例 = 2022/10/16)
Try this code:试试这个代码:
add_filter( 'woocommerce_gateway_description', 'rudr_change_payment_gateway_description', 25, 2 );
function rudr_change_payment_gateway_description( $description, $gateway_id ) {
if( 'pec_gateway_check' === $gateway_id ) {
global $woocommerce;
$carttotal = $woocommerce->cart->total;
?>
<div class="mcpec-text">
<span class="mcp-item">مبلغ پرداختی آنلاین شما:<span class="mcp-item-inner"> <?php echo "35% is: " . number_format($carttotal*0.35, 2) . "$"; ?> </span></span>
<span class="mcp-item">مبلغ چک صیادی:<span class="mcp-item-inner"> <?php echo "65% is: " . number_format($carttotal*0.65, 2) . "$"; ?> </span></span>
<span class="mcp-item">تاریخ چک صیادی:<span class="mcp-item-inner"> <?php echo "40 days later is: " . date('Y/m/d', strtotime("+40 days")); ?> </span></span>
</div>
<?php
$description = '';
}
return $description;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.