Restricting cart items to be from the same product category in WooCommerce

前端 未结 2 459
鱼传尺愫
鱼传尺愫 2020-12-07 02:26

I am using the code below to remove other WooCommerce product category items from the cart when there is an item with a special product category \'cat_x\' added in cart and

2条回答
  •  遥遥无期
    2020-12-07 03:25

    I just tried and i got a syntax error the array that i fixed this way:

    $terms_slugs = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'slugs'));
    

    just a comma after product_cat distraction, but maybe somebody would need it.

提交回复
热议问题