Skip to content

Commit

Permalink
prevent error when coupon code is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Webwijs committed Nov 25, 2024
1 parent 6f6210d commit 2116d0d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Plugin/SelectPromotion.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ public function __construct(
public function afterExecute(CouponPost $subject, Redirect $result)
{
$request = $subject->getRequest();
$code = $request->getParam('coupon_code');

if ($request->getParam('remove') == 0 && $request->getParam('coupon_code') !== null) {

$coupon = $this->quoteDataHelper->getCouponByCode($request->getParam('coupon_code'));
$this->couponCode = $coupon->getCode();
if ($request->getParam('remove') == 0 && $code !== null) {
$coupon = $this->quoteDataHelper->getCouponByCode($code);
$this->couponCode = $code;
$this->couponId = $coupon->getId();
$dataLayer = $this->getDataLayer();
$this->session->setDataLayer($dataLayer);

}

return $result;
Expand Down

0 comments on commit 2116d0d

Please sign in to comment.