Skip to content

Commit

Permalink
Add Craft 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Oct 26, 2024
1 parent e872ac4 commit 06c4748
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 50 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.0.0 - 2024-10-25

### Changed
- Now requires Craft 5.0+.
- Now requires Craft Commerce 5.0+.

## 3.0.0 - 2024-10-25
> {note} The plugin’s package name has changed to `verbb/abandoned-cart`. Abandoned Cart will need be updated to 3.0 from a terminal, by running `composer require verbb/abandoned-cart && composer remove mediabeastnz/craft-commerce-abandoned-cart`.
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "verbb/abandoned-cart",
"description": "Send multiple email reminders to customers that have abandoned their carts.",
"type": "craft-plugin",
"version": "3.0.0",
"version": "4.0.0",
"keywords": [
"craft",
"cms",
Expand All @@ -29,10 +29,10 @@
}
],
"require": {
"php": "^8.0.2",
"craftcms/cms": "^4.0.0",
"craftcms/commerce": "^4.0.0",
"verbb/base": "^2.0.0"
"php": "^8.2",
"craftcms/cms": "^5.0.0",
"craftcms/commerce": "^5.0.0",
"verbb/base": "^3.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -42,7 +42,7 @@
"extra": {
"name": "Abandoned Cart",
"handle": "abandoned-cart",
"changelogUrl": "https://raw.githubusercontent.com/verbb/abandoned-cart/craft-4/CHANGELOG.md",
"changelogUrl": "https://raw.githubusercontent.com/verbb/abandoned-cart/craft-5/CHANGELOG.md",
"class": "verbb\\abandonedcart\\AbandonedCart"
}
}
6 changes: 3 additions & 3 deletions docs/get-started/requirements.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Requirements

## Craft CMS
Abandoned Cart requires Craft CMS 4.0 or greater.
Abandoned Cart requires Craft CMS 5.0 or greater.

## Craft Commerce
Abandoned Cart requires Craft Commerce 4.0 or greater.
Abandoned Cart requires Craft Commerce 5.0 or greater.

## PHP
Abandoned Cart requires PHP 8.0.2 or greater.
Abandoned Cart requires PHP 8.2 or greater.
2 changes: 0 additions & 2 deletions src/AbandonedCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public function init(): void

self::$plugin = $this;

$this->_setPluginComponents();
$this->_setLogging();
$this->_registerVariables();
$this->_registerCraftEventListeners();

Expand Down
55 changes: 17 additions & 38 deletions src/base/PluginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,35 @@

use Craft;

use yii\log\Logger;

use verbb\base\BaseHelper;
use verbb\base\LogTrait;
use verbb\base\helpers\Plugin;

trait PluginTrait
{
// Static Properties
// =========================================================================

public static AbandonedCart $plugin;

public static ?AbandonedCart $plugin = null;

// Public Methods
// Traits
// =========================================================================

public static function log(string $message, array $attributes = []): void
{
if ($attributes) {
$message = Craft::t('abandoned-cart', $message, $attributes);
}
use LogTrait;


Craft::getLogger()->log($message, Logger::LEVEL_INFO, 'abandoned-cart');
}
// Static Methods
// =========================================================================

public static function error(string $message, array $attributes = []): void
public static function config(): array
{
if ($attributes) {
$message = Craft::t('abandoned-cart', $message, $attributes);
}

Craft::getLogger()->log($message, Logger::LEVEL_ERROR, 'abandoned-cart');
Plugin::bootstrapPlugin('abandoned-cart');

return [
'components' => [
'carts' => Carts::class,
'service' => Service::class,
],
];
}


Expand All @@ -54,23 +52,4 @@ public function getService(): Service
return $this->get('service');
}


// Private Methods
// =========================================================================

private function _setPluginComponents(): void
{
$this->setComponents([
'carts' => Carts::class,
'service' => Service::class,
]);

BaseHelper::registerModule();
}

private function _setLogging(): void
{
BaseHelper::setFileLogging('abandoned-cart');
}

}
2 changes: 1 addition & 1 deletion src/services/Carts.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function markCartAsRecovered(Order $order): void
}
}

public function restoreCart(Order $order): void
public function restoreCart(Order $order): bool
{
if ($cart = $this->getCartByOrderId($order->id)) {
$expiry = AbandonedCart::$plugin->getSettings()->getRestoreExpiryHours();
Expand Down

0 comments on commit 06c4748

Please sign in to comment.