Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 更改签出表中的商品数量_Php_Wordpress_Woocommerce_Checkout_Product Quantity - Fatal编程技术网

Php 更改签出表中的商品数量

Php 更改签出表中的商品数量,php,wordpress,woocommerce,checkout,product-quantity,Php,Wordpress,Woocommerce,Checkout,Product Quantity,我想更改Woocommerce在订单审核表中显示产品数量的方式。我希望数量在产品名称下面,而不是后面 我发现这很有帮助,但代码只改变了可变产品的数量布局 如何更改每种产品,即使是简单的产品?这可以通过多种方式完成: 1) 压倒一切的 2) 自定义产品项名称: add_filter( 'woocommerce_cart_item_name', 'customizing_checkout_item_name', 10, 3); function customizing_checkout_item_n

我想更改Woocommerce在订单审核表中显示产品数量的方式。我希望数量在产品名称下面,而不是后面

我发现这很有帮助,但代码只改变了可变产品的数量布局


如何更改每种产品,即使是简单的产品?

这可以通过多种方式完成:

1) 压倒一切的

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;
}
add_filter('woocommerce_cart_item_name','customize_checkout_item_name',10,3);
自定义\结帐\项目\名称($item\名称、$cart\项目、$cart\项目\键)的函数{
if(is_checkout())
$item_name.='
'; 返回$item_name; }
代码进入活动子主题(或活动主题)的function.php文件

3) 定制产品项目数量(最佳方式):

add_filter('woocommerce_checkout_cart_item_quantity','customize_checkout_item_quantity',10,3);
函数自定义\结帐\项目\数量($quantity\ html、$cart\项目、$cart\项目\键){
$quantity_html='
“.”数量:“”.$cart\u项目['Quantity'.”; 返回$quantity\u html; }
代码进入活动子主题(或活动主题)的function.php文件


所有代码都经过测试并正常工作。

非常感谢!这太棒了!我可以再问你一件事吗(我不确定我是否应该开始一个新的问题):在我上面链接的帖子中,你还提供了从产品互动程序中删除属性并将其显示在下面的代码。是否可以只从标题中删除属性,而不在下面显示它们?我使用“重量”作为属性,我有没有属性的单一产品,这样简单的产品下面就不会显示重量,这会让客户感到困惑…所以我建议根本不要显示属性。谢谢Loic。我尝试了第一种适合我的方法。我认为重写模板php文件是最好的方法。正如原始文件所述:可以通过将该模板复制到yourtheme/woocommerce/checkout/review-order.php来覆盖该模板。是否有任何方法仅在数量大于1时显示数量?
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;
}