woocommerce给购物车添加产品重量

本应写个插件,然后重载cart模板,觉得有点大材小用,直接改模板吧

\wp-content\plugins\woocommerce\templates\cart\cart.php

38行加表头

<th class="product-weight"><?php _e( 'Weight', 'woocommerce' ); ?></th>

120行加内容

<td class="product-weight" data-title="<?php esc_attr_e( 'Weight', 'woocommerce' ); ?>">
<?php echo apply_filters( 'woocommerce_cart_item_weight', $cart_item ); ?>
</td>

过滤器回调woocommerce_cart_item_weight写在woocommerce.php或主题functions中均可

猜你喜欢

转载自my.oschina.net/u/1240534/blog/1143140
今日推荐