Remove item with $product_id - Woocommerce

前端 未结 2 976
礼貌的吻别
礼貌的吻别 2020-12-16 12:28

Made a function where the customer get a product added to the cart when they reach a specific amount.

Example of when customer reaches level 3 and get the

2条回答
  •  感动是毒
    2020-12-16 13:11

    Use this for latest versions of WooCommerce:

    $cartId = WC()->cart->generate_cart_id( 'PRODUCT ID' );
    $cartItemKey = WC()->cart->find_product_in_cart( $cartId );
    WC()->cart->remove_cart_item( $cartItemKey );
    

    replace PRODUCT ID with yours.

提交回复
热议问题