我想在结帐和购物车页面添加自定义文字 . 我需要写什么代码来写入function.php文件?旁边的“总”字 . 永远是静止的谢谢
https://i.hizliresim.com/nJ4dBR.jpg
image1
覆盖woocommerce checkout / review-order.php模板 .
您首先需要(如果没有)将位于woocommerce插件文件夹中的模板子文件夹复制到您的活动子主题(或主题)文件夹,并将其重命名为woocommerce . 完成您的活动主题后,转到woocommerce> checkout,然后打开/编辑review-order.php模板文件 .
在这个模板的末尾你有这个:
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?> <tr class="order-total"> <th><?php _e( 'Total', 'woocommerce' ); ?></th> <td><?php wc_cart_totals_order_total_html(); ?></td> </tr> <?php do_action( 'woocommerce_review_order_after_order_total' ); ?> </tfoot>
所以你会改变:
至:
现在你可以保存,你完成了......
希望这会对你有所帮助 . 欲获得更多信息,
您需要将 cart/cart-totals.php 和 checkout/review-order.php 模板文件从 woocommerce/templates 复制到 <your-theme's-folder>/woocommerce/ 的主题文件夹中 .
cart/cart-totals.php
checkout/review-order.php
woocommerce/templates
<your-theme's-folder>/woocommerce/
Template Path: <your-theme's-folder>/woocommerce/cart/cart-totals.php
<tr class="order-total"> <th><?php _e( 'Total', 'woocommerce' ); ?></th> <td data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"><?php wc_cart_totals_order_total_html(); ?></td> </tr>
Template Path: <your-theme's-folder>/woocommerce/checkout/review-order.php
<tr class="order-total"> <th><?php _e( 'Total', 'woocommerce' ); ?></th> <td><?php wc_cart_totals_order_total_html(); ?></td> </tr>
例如,编辑 <th><?php _e( 'Total', 'woocommerce' ); ?></th>
<th><?php _e( 'Total', 'woocommerce' ); ?></th>
<th><?php _e( 'Total', 'woocommerce' ); ?> <span> <?php _e('some text here', 'mm-woocommerce'); ?> </span></th>
我们添加了 <span> <?php _e('some text here', 'mm-woocommerce'); ?> </span>
<span> <?php _e('some text here', 'mm-woocommerce'); ?> </span>
2 回答
覆盖woocommerce checkout / review-order.php模板 .
您首先需要(如果没有)将位于woocommerce插件文件夹中的模板子文件夹复制到您的活动子主题(或主题)文件夹,并将其重命名为woocommerce . 完成您的活动主题后,转到woocommerce> checkout,然后打开/编辑review-order.php模板文件 .
在这个模板的末尾你有这个:
所以你会改变:
至:
现在你可以保存,你完成了......
希望这会对你有所帮助 . 欲获得更多信息,
您需要将
cart/cart-totals.php
和checkout/review-order.php
模板文件从woocommerce/templates
复制到<your-theme's-folder>/woocommerce/
的主题文件夹中 .然后修改以下模板 .
Template Path: <your-theme's-folder>/woocommerce/cart/cart-totals.php
Template Path: <your-theme's-folder>/woocommerce/checkout/review-order.php
修改示例
例如,编辑
<th><?php _e( 'Total', 'woocommerce' ); ?></th>
我们添加了
<span> <?php _e('some text here', 'mm-woocommerce'); ?> </span>