. * */ namespace Vvveb\Controller\Cart; use function Vvveb\__; trait CouponTrait { function coupon() { $coupon = $this->request->request['coupon'] ?? ''; if ($coupon) { if ($this->cart->addCoupon($coupon)) { $this->view->success['coupon'] = __('Coupon successfully applied!'); } else { $this->view->errors['coupon'] = __('Invalid or expired coupon!'); } } return $this->index(); } function removeCoupon() { $coupon = $this->request->request['coupon'] ?? ''; if ($coupon) { if ($this->cart->removeCoupon($coupon)) { $this->view->success['coupon'] = __('Coupon removed!'); } else { $this->view->errors['coupon'] = __('Could not remove coupon!'); } } return $this->index(); } }