我想更改 Woocommerce 在订单审核表中显示产品数量的方式。我希望数量在产品名称下方而不是在它之后。
我发现这篇文章有帮助,但代码只更改了可变产品的数量布局。
我怎样才能为每个产品更改它,即使是简单的产品?
我想更改 Woocommerce 在订单审核表中显示产品数量的方式。我希望数量在产品名称下方而不是在它之后。
我发现这篇文章有帮助,但代码只更改了可变产品的数量布局。
我怎样才能为每个产品更改它,即使是简单的产品?
这可以通过多种方式完成:
1)通过您的子主题覆盖模板checkout/review-order.php
。
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 文件中。
所有代码都经过测试并且可以工作。