Jump to content
Sign in to follow this  
autumn_sunset

Removing items from cart

Recommended Posts

I am beginner in opencart, realized adding two gift items to the cart, along with adding the first paid

if (!$json) {
				$this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);

			$cart_contents = $this->cart->countProducts();
			if ($cart_contents == 1) {
    			$this->cart->add('656', '1');
				$this->cart->add('657', '1');
			}
}

Help to implement the removal of these two products along with the last paid from the cart. Here is my attempt (doesn't work)

if (isset($this->request->post['key'])) {
			$this->cart->remove($this->request->post['key']);

 $cart_contents = $this->cart->countProducts();

		 if (isset($this->request->post['product_id'])) {
			 if ($cart_contents == 3) {
				 $this->cart->remove($this->request->post['product_id']);
    			 $this->cart->remove('656');
				 $this->cart->remove('657');
			 }
		 }


 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×