即日起在codingBlog上分享您的技术经验即可获得积分,积分可兑换现金哦。

woocommerce plugin remove item

栈溢出 Arsalan Azhar 99℃ 0评论
本文目录
[隐藏]

1.原始问题:woocommerce plugin remove item

i am new to woocommerce, actually i want to customize product display so i manually parse products from database i want to remove an item from woocommerce cart through product id, i have found this function,

$woocommerce->cart->get_remove_url($cart_item_key); in core woocommerce cart class, but i am unable to understand what i have to write in $cart_item_key, i have tried to product id or product url in it but its not removing product item from cart, can somebody help me please what i have write in this variable $cart_item_key,

/* Gets the url to remove an item from the cart.
*
* @return string url to page
*/

its description of that function, i have tried using full url of product page and also slug

Regards

Arsalan

2.被采纳答案

暂无被采纳答案,请参照下面其他答案。

3.其他高票答案

3.1.第1个答案

I know its an old post but it may help someone.

foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
  if($cart_item['product_id'] == $your_product_id)
  $woocommerce->cart->get_remove_url($cart_item_key); 
} 

Hope its helps..

转载请注明:CodingBlog » woocommerce plugin remove item

喜欢 (0)or分享 (0)
发表我的评论
取消评论

*

表情