public function removeCoupon($coupon_code, $fromId = false) { if (empty($this->coupons)) { return null; } if ($fromId) { $coupon_code = couponHandler::codeFromId($coupon_code); $coupon_code = $coupon_code['coupon_code']; } if (!in_array($coupon_code, $this->coupons)) { return null; } foreach ($this->coupons as $id => $cc) { if ($cc == $coupon_code) { unset($this->coupons[$id]); } } $cph = new couponHandler(); $cph->load($coupon_code); if (!empty($cph->coupon->id)) { $cph->decrementCount($this); } if (empty($this->usage)) { return; } $usage = explode('.', $this->usage); // Update old notation if (!isset($usage[1])) { $temp = $usage[0]; $usage[0] = 'p'; $usage[1] = $temp; } switch (strtolower($usage[0])) { case 'c': case 'cart': $cart = new aecCart(); $cart->load($usage[1]); $cart->removeCoupon($coupon_code); $cart->storeload(); break; } }