我想更改 Woocommerce 在订单审核表中显示产品数量的方式。我希望数量位于产品名称下方而不是后面。
我找到了this post这有帮助,但代码仅更改可变产品的数量布局。
如何为每个产品(甚至是简单的产品)更改它?
最佳答案
这可以通过多种方式完成:
1) 覆盖 template checkout/review-order.php
via your child theme .
2) 自定义产品项目名称:
add_filter( 'woocommerce_cart_item_name', 'customizing_checkout_item_name', 10, 3);
function customizing_checkout_item_name( $item_name, $cart_item, $cart_item_key ) {
if( is_checkout() )
$item_name .= '<br>';
return $item_name;
}
代码位于事件子主题(或事件主题)的 function.php 文件中。
3) 自定义产品项目数量(最佳方法):
add_filter( 'woocommerce_checkout_cart_item_quantity', 'customizing_checkout_item_quantity', 10, 3);
function customizing_checkout_item_quantity( $quantity_html, $cart_item, $cart_item_key ) {
$quantity_html = ' <br>
<span class="product-quantity">' . __('Quantity:') . ' <strong>' . $cart_item['quantity'] . '</strong></span>';
return $quantity_html;
}
代码位于事件子主题(或事件主题)的 function.php 文件中。
所有代码都经过测试并且可以工作。
关于php - 更改结账表中的 Woocommerce 产品数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48232454/