在结帐表中更改Woocommerce产品数量

时间:2018-01-12 18:58:30

标签: php wordpress woocommerce checkout product-quantity

我想改变Woocommerce在订单查看表中显示产品数量的方式。我希望数量在产品名称下面而不是在它之后。

我发现this post有所帮助,但代码只更改了变量产品的数量布局。

如何为每种产品更改它,甚至是简单产品?

1 个答案:

答案 0 :(得分:1)

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

1)覆盖template checkout/review-order.php via your child theme

2)自定义产品项目名称:

df
                                            Address
0          Wal-Mart Stores, Inc., Clinton, IA 52732
1         Benton Packing, LLC, Clearfield, UT 84016
2          North Coast Iron Corp, Seattle, WA 98109
3  Messer Construction Co. Inc., Amarillo, TX 79109

df['Zip'] = df.Address.map(lambda x: x.rsplit(' ', 1)[-1])
df['Name'], df['City'], df['State']= zip(*df.Address.map(lambda x: x.rsplit(' ', 1)[0].rsplit(',', 2)))

df
                                           Address    Zip  \
0           Wal-Mart Stores, Inc., Clinton, IA 5273   5273
1         Benton Packing, LLC, Clearfield, UT 84016  84016
2          North Coast Iron Corp, Seattle, WA 98109  98109
3  Messer Construction Co. Inc., Amarillo, TX 79109  79109

                           Name         City State
0         Wal-Mart Stores, Inc.      Clinton    IA
1           Benton Packing, LLC   Clearfield    UT
2         North Coast Iron Corp      Seattle    WA
3  Messer Construction Co. Inc.     Amarillo    TX

代码进入活动子主题(或活动主题)的function.php文件。

3)自定义产品项目数量最佳方式

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文件。

所有代码都经过测试并且有效。