Skip to content

Commit

Permalink
Added the CouponUtilized event
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Aug 24, 2024
1 parent e81ca5b commit 8f8fdc0
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 22 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- `hasAnyCoupon()`
- `getPromotionsAmount()`
- `setPromotionsAmount()`
- Added the following events:
- `CouponAdded` (to checkout)
- `CouponRemoved` (from checkout)
- `CouponUtilized` (after a successful checkout converted to an order)

## 4.1.0
##### 2024-07-11
Expand Down
8 changes: 8 additions & 0 deletions Contracts/CouponEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Vanilo\Checkout\Contracts;

interface CouponEvent extends CheckoutEvent
{
public function getCouponCode(): string;
}
34 changes: 34 additions & 0 deletions Events/BaseCouponEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

/**
* Contains the BaseCouponEvent class.
*
* @copyright Copyright (c) 2024 Vanilo UG
* @author Attila Fulop
* @license MIT
* @since 2024-08-24
*
*/

namespace Vanilo\Checkout\Events;

use Vanilo\Checkout\Contracts\Checkout;
use Vanilo\Checkout\Contracts\CouponEvent;

abstract class BaseCouponEvent extends BaseCheckoutEvent implements CouponEvent
{
public readonly string $couponCode;

public function __construct(Checkout $checkout, string $couponCode)
{
parent::__construct($checkout);
$this->couponCode = $couponCode;
}

public function getCouponCode(): string
{
return $this->couponCode;
}
}
13 changes: 2 additions & 11 deletions Events/CouponAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Contains the CouponAdded class.
* Contains the CouponAdded event class.
*
* @copyright Copyright (c) 2024 Vanilo UG
* @author Attila Fulop
Expand All @@ -14,15 +14,6 @@

namespace Vanilo\Checkout\Events;

use Vanilo\Checkout\Contracts\Checkout;

class CouponAdded extends BaseCheckoutEvent
class CouponAdded extends BaseCouponEvent
{
public readonly string $couponCode;

public function __construct(Checkout $checkout, string $couponCode)
{
parent::__construct($checkout);
$this->couponCode = $couponCode;
}
}
13 changes: 2 additions & 11 deletions Events/CouponRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Contains the CouponRemoved class.
* Contains the CouponRemoved event class.
*
* @copyright Copyright (c) 2024 Vanilo UG
* @author Attila Fulop
Expand All @@ -14,15 +14,6 @@

namespace Vanilo\Checkout\Events;

use Vanilo\Checkout\Contracts\Checkout;

class CouponRemoved extends BaseCheckoutEvent
class CouponRemoved extends BaseCouponEvent
{
public readonly string $couponCode;

public function __construct(Checkout $checkout, string $couponCode)
{
parent::__construct($checkout);
$this->couponCode = $couponCode;
}
}
19 changes: 19 additions & 0 deletions Events/CouponUtilized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/**
* Contains the CouponUtilized Event class
*
* @copyright Copyright (c) 2024 Vanilo UG
* @author Attila Fulop
* @license MIT
* @since 2024-08-24
*
*/

namespace Vanilo\Checkout\Events;

class CouponUtilized extends BaseCouponEvent
{
}

0 comments on commit 8f8fdc0

Please sign in to comment.