php - 更改结账表中的 Woocommerce 产品数量

标签 php wordpress woocommerce checkout product-quantity

我想更改 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/

相关文章:

wordpress - WooCommerce Hook 在购物车和结帐页面上的输出问题

php - 如果订单具有此特定类别,请更改 Woocommerce 电子邮件主题

php - Woocommerce 添加到购物车按钮重定向到结帐

wordpress - 重定向到另一个域

php - Gravity Forms post/get 从 mysql 数据库获取数据

php - Tinymce,禁用 numlist 下拉列表

php - 强制 PHP 循环每行显示 8 列

php - Nginx+php5-fpm+varnish+APC 上的 Wordpress 高 CPU 和内存使用率

PHP 输出缓冲

javascript - jqGrid 与 MySQL 中的相关表