Post by autumn_sunset » Sat Feb 16, 2019 1:04 am

Hello, i am beginner in opencart. I made it so that when user add a product, two more items are automatically added to it (that's are free gifts then costs 0). I want to realize - when user delete last paid item, this two gifts automatically removed from cart.

this is my adding

Code: Select all

 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');
			} 
And this my try to delete (don't work), please help with this, a try many times

Code: Select all

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');
			}
		}

Newbie

Posts

Joined
Sat Feb 16, 2019 12:50 am

Post by straightlight » Sat Feb 16, 2019 6:34 am

More info needed. Partial info posted only.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paid1234 » Wed Feb 20, 2019 6:00 am

You might get a better response if you let us know in what pages we can find these codes...

User avatar
Newbie

Posts

Joined
Thu Aug 01, 2013 8:37 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 16 guests