Skip to content

Commit

Permalink
Craft 5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ttempleton committed Apr 6, 2024
1 parent ca7c3d8 commit 6f99d68
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Unreleased

### Added
- Added Craft 5 / Craft Commerce 5 compatibility

### Changed
- `spicyweb\reorder\enums\LineItemStatus` and `spicyweb\reorder\enums\OrderStatus` are now proper enums, rather than abstract classes

### Removed
- Removed Craft 4 / Craft Commerce 4 compatibility

## 2.0.1 - 2024-01-09

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ ReOrder makes it easy to allow users to quickly replicate an old order's line it

## Requirements

- Craft CMS 4.0.0 or later
- Craft Commerce 4.0.0 or later
- ReOrder 3.x requires Craft CMS 5 and Craft Commerce 5.

## Installation

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
"issues": "https://github.com/spicywebau/craft-reorder/issues"
},
"require": {
"craftcms/cms": "^4.0.0",
"craftcms/commerce": "^4.0.0",
"php": "^8.0.2"
"craftcms/cms": "^5.0.0",
"craftcms/commerce": "^5.0.0-beta.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function hasAvailableLineItems(Order $order, ?Order $cart = null, ?array
* @param Order|null $cart A cart, to check for the quantity of items already in the user's cart.
* @return string The line item status.
*/
private function _getLineItemStatus(LineItem $lineItem, ?Order $cart = null): string
private function _getLineItemStatus(LineItem $lineItem, ?Order $cart = null): LineItemStatus
{
$commerce = Commerce::getInstance();
$purchasable = $lineItem->getPurchasable();
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ReorderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function actionIndex(): ?Response
}

if ($error !== null) {
$translatedError = Craft::t('reorder', $error);
$translatedError = Craft::t('reorder', $error->value);

if ($isAjaxRequest) {
return $this->asJson([
Expand Down
20 changes: 10 additions & 10 deletions src/enums/LineItemStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
namespace spicyweb\reorder\enums;

/**
* Class LineItemStatus
* Line item status enum
*
* @package spicyweb\reorder\enums
* @author Spicy Web <[email protected]>
* @since 1.0.0
* @since 3.0.0
*/
abstract class LineItemStatus
enum LineItemStatus
{
public const Available = 'Available';
public const Deleted = 'Deleted';
public const Disabled = 'Disabled';
public const BelowMinQty = 'BelowMinQty';
public const AboveMaxQty = 'AboveMaxQty';
public const InsufficientStock = 'InsufficientStock';
public const OutOfStock = 'OutOfStock';
case Available;
case Deleted;
case Disabled;
case BelowMinQty;
case AboveMaxQty;
case InsufficientStock;
case OutOfStock;
}
12 changes: 6 additions & 6 deletions src/enums/OrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace spicyweb\reorder\enums;

/**
* Class OrderStatus
* Order status enum
*
* @package spicyweb\reorder\enums
* @author Spicy Web <[email protected]>
* @since 1.0.0
* @since 3.0.0
*/
abstract class OrderStatus
enum OrderStatus: string
{
public const DoesNotExist = 'The order does not exist';
public const Partial = 'Some items are not available';
public const NoItemsAvailable = 'No items available';
case DoesNotExist = 'The order does not exist';
case Partial = 'Some items are not available';
case NoItemsAvailable = 'No items available';
}

0 comments on commit 6f99d68

Please sign in to comment.