简体   繁体   English

如何在 WooCommerce 中的描述付款方式中显示总购物车订单金额

[英]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.

相关问题 应用于购物车的购物车折扣在Wordpress中使用Woocommerce的订单总额中未显示正确的金额 - Cart Discount when applied to the cart doesn't show the correct amount in Order Total using Woocommerce in wordpress 根据 Woocommerce 中的购物车总金额添加或删除支付网关 - add or remove payment gateways based on cart total amount in Woocommerce WooCommerce 中特定选定付款方式的购物车总数 - Round cart total for specific selected payment method in WooCommerce 根据 WooCommerce 上的总订单价值在购物车上显示消息 - Show message on cart based on total order value on WooCommerce 如何在Payeezy演示付款网关中传递总金额和订单明细 - How to pass total amount with order details in payeezy demo payment gateway 禁用基于 WooCommerce 购物车总数的付款方式 - Disable payment methods based on WooCommerce cart total 如何从购物车和结帐页面woocommerce中删除订单总额 - How to remove order total from cart and checkout page woocommerce WooCommerce:如果使用特定的付款方式,则在新订单电子邮件上显示通知 - WooCommerce: Show notice on new order email if specific payment method is used 总金额未从“购物车”中显示 - Total amount doesnt show from Shopping Cart Prestashop购物车和订购商品,如何“确认”购物车并使其成为来自外部付款方式的订单 - Prestashop cart and order lifesycle, how to “confirm” a cart and let it become an order coming from external payment method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM