首页 文章

将自定义购物车字段添加到woocommerce

提问于
浏览
0

这可能是一个菜鸟问题,但我已经google了很多,但没有找到答案 . 我已经将woocommerce购物车替换为我的子主题子文件夹 .

我正在尝试在woocommerce购物车中添加一个字段,因此它只显示购物车小计乘以我定义的数字 . 即,购物车小计是3,000.00,我想定义乘数3,因此我要显示的字段必须显示9.000,00 .

我已经将字段 Headers 添加到购物车:

<thead>
    <tr>
        <th class="product-remove">&nbsp;</th>
        <th class="product-quantity"><?php _e( 'Quantity', 'thefoxwp' ); ?></th>
        <th class="product-subtotal"><?php _e( 'Total', 'thefoxwp' ); ?></th>
        <th class="product-result"><?php _e( 'Total to be Received', 'thefoxwp' ); ?></th>

    </tr>
</thead>

我想配置的字段是 class="product-result" .

它不是输入字段,它只显示小计乘以我定义的数字 .

我需要将此信息与woocommerce电子邮件一起发送给客户,并保存在我的订单详细信息中 .

有谁知道怎么做?

谢谢

1 回答

  • 0

    可以搞清楚 .

    我在 Headers 中添加了两个类

    <thead>
        <tr>
            <th class="product-remove">&nbsp;</th>
            <th class="product-quantity"><?php _e( 'Quantity', 'thefoxwp' ); ?></th>
            <th class="product-subtotal"><?php _e( 'Total', 'thefoxwp' ); ?></th>
            <th class="product-tax"><?php _e( 'Exchange Tax', 'thefoxwp' ); ?></th>
            <th class="product-result"><?php _e( 'Total to be Received', 'thefoxwp' ); ?></th>
    
        </tr>
    </thead>
    

    然后添加了这段代码

    <!-- Exchange Tax -->
           <td class="product-tax">
           <?php
           $tax = 4.05;
           echo "R$ $tax";
           ?>
           </td>
    
          <!-- Product Result -->
          <td class="product-result">
            <?php
            $resultado = WC()->cart->subtotal;
            $mostrar = $resultado * $tax;
            echo "R$ "; echo number_format("$mostrar",2);
            ?>
          </td>
    

    所以它现在是 echo 购物车小计*交换税的结果 .

    但是现在,我如何才能将此变量发送到woocommerce发送的电子邮件和结帐页面上? echo

相关问题