-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
357 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
docs/manual/developer/hooks/addProductToCollection/_index.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: "addProductToCollection" | ||
--- | ||
|
||
The `addProductToCollection` hook is triggered every time a product is added to the cart. | ||
It allows manipulating the number of items added to the cart. | ||
|
||
## Parameters | ||
|
||
1. \Isotope\Interfaces\IsotopeProduct `$product` | ||
|
||
The product that is added to the collection. | ||
|
||
2. int `$quantity` | ||
|
||
The quantity of the product that is added to the collection. | ||
|
||
3. \Isotope\Interfaces\IsotopeProductCollection `$collection` | ||
|
||
The collection the product is added to. | ||
|
||
4. array `$config` | ||
|
||
The model configuration. | ||
|
||
## Example | ||
|
||
```php | ||
// src/EventListener/Isotope/AddProductToCollectionListener.php | ||
namespace App\EventListener\Isotope; | ||
|
||
use Isotope\Interfaces\IsotopeProduct; | ||
use Isotope\Interfaces\IsotopeProductCollection; | ||
use Isotope\ServiceAnnotation\IsotopeHook; | ||
|
||
/** | ||
* @IsotopeHook("addProductToCollection") | ||
*/ | ||
class AddProductToCollectionListener | ||
{ | ||
public function __invoke(IsotopeProduct $product, int $quantity, IsotopeProductCollection $collection, array $config): int | ||
{ | ||
// example for allowing max 5 items per product | ||
if ($quantity > 5) { | ||
return 5; | ||
} | ||
return $quantity | ||
} | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [\Isotope\Model\ProductCollection#L1053-L1059](https://github.com/isotope/core/blob/2.8/system/modules/isotope/library/Isotope/Model/ProductCollection.php#L1053-L1059) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: "generateProduct" | ||
--- | ||
|
||
The `generateProduct` hook is called when the product page (reader) is rendered. It allows to add custom information to the product page. | ||
|
||
## Parameters | ||
|
||
1. \Isotope\Template `$template` | ||
|
||
The template object. | ||
|
||
1. \Isotope\Interfaces\IsotopeProduct `$product` | ||
|
||
The product model. | ||
|
||
## Example | ||
|
||
```php | ||
// src/EventListener/Isotope/GenerateProductListener.php | ||
namespace App\EventListener\Isotope; | ||
|
||
use Isotope\Model\Product\AbstractProduct; | ||
use Isotope\ServiceAnnotation\IsotopeHook; | ||
use Isotope\Template; | ||
|
||
/** | ||
* @IsotopeHook("generateProduct") | ||
*/ | ||
class GenerateProductListener | ||
{ | ||
public function __invoke(Template $template, IsotopeProduct $product): void | ||
{ | ||
$template->customMessage = 'We currently have more orders than usual. Please expect longer waiting times.'; | ||
} | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [\Isotope\Model\Product\Standard#L643-L647](https://github.com/isotope/core/blob/2.8/system/modules/isotope/library/Isotope/Model/Product/Standard.php#L643-L647) |
50 changes: 50 additions & 0 deletions
50
docs/manual/developer/hooks/postAddProductToCollection/_index.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: "postAddProductToCollection" | ||
--- | ||
|
||
The `postAddProductToCollection` hook is triggered after a product is added to the cart and can be used to perform additional actions. | ||
|
||
|
||
## Parameters | ||
|
||
1. \Isotope\Interfaces\IsotopeProduct `$product` | ||
|
||
The product that was added to the collection. | ||
|
||
2. int `$quantity` | ||
|
||
The quantity of the product that was added to the collection. | ||
|
||
3. \Isotope\Interfaces\IsotopeProductCollection `$collection` | ||
|
||
The collection the product was added to. | ||
|
||
4. array `$config` | ||
|
||
The model configuration. | ||
|
||
## Example | ||
|
||
```php | ||
// src/EventListener/Isotope/PostAddProductToCollectionListener.php | ||
namespace App\EventListener\Isotope; | ||
|
||
use Isotope\Interfaces\IsotopeProduct; | ||
use Isotope\Interfaces\IsotopeProductCollection; | ||
use Isotope\ServiceAnnotation\IsotopeHook; | ||
|
||
/** | ||
* @IsotopeHook("postAddProductToCollection") | ||
*/ | ||
class PostAddProductToCollectionListener | ||
{ | ||
public function __invoke(IsotopeProduct $product, $quantity, IsotopeProductCollection $collection, array $config): void | ||
{ | ||
// Do something … | ||
} | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [\Isotope\Model\ProductCollection#L1112-L1118](https://github.com/isotope/core/blob/2.8/system/modules/isotope/library/Isotope/Model/ProductCollection.php#L1112-L1118) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: "postCheckout" | ||
--- | ||
|
||
The `postCheckout` hook is called after the checkout process is finished. | ||
|
||
## Parameters | ||
|
||
1. \Isotope\Model\ProductCollection\Order `$order` | ||
|
||
The order object. | ||
|
||
2. `array $tokens` | ||
|
||
The notification center tokens. | ||
|
||
## Example | ||
|
||
```php | ||
// src/EventListener/Isotope/PostCheckoutListener.php | ||
namespace App\EventListener\Isotope; | ||
|
||
use Isotope\Model\ProductCollection\Order; | ||
use Isotope\Module\Checkout; | ||
use Isotope\ServiceAnnotation\IsotopeHook; | ||
|
||
/** | ||
* @IsotopeHook("postCheckout") | ||
*/ | ||
class PostCheckoutListener | ||
{ | ||
public function __invoke(Order $order, array $tokens): void | ||
{ | ||
// Do something ... | ||
} | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [\Isotope\Module\Checkout#L236-L245](https://github.com/isotope/core/blob/2.8/system/modules/isotope/library/Isotope/Module/Checkout.php#L236-L245) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: "preCheckout" | ||
--- | ||
|
||
The `preCheckout` hook is called before the checkout process is started. | ||
It allows to abort the checkout process. | ||
|
||
## Parameters | ||
|
||
1. \Isotope\Model\ProductCollection\Order|null `$order` | ||
|
||
The order object. | ||
|
||
1. \Isotope\Module\Checkout `$module` | ||
|
||
The checkout module. | ||
|
||
## Return Values | ||
|
||
The hook must return a boolean value. If `false` is returned, the checkout process is aborted. | ||
|
||
## Example | ||
|
||
```php | ||
// src/EventListener/Isotope/PreCheckoutListener.php | ||
namespace App\EventListener\Isotope; | ||
|
||
use Isotope\Model\ProductCollection\Order; | ||
use Isotope\Module\Checkout; | ||
use Isotope\ServiceAnnotation\IsotopeHook; | ||
|
||
/** | ||
* @IsotopeHook("preCheckout") | ||
*/ | ||
class PreCheckoutListener | ||
{ | ||
public function __invoke(?Order $order, Checkout $module): bool | ||
{ | ||
if (!$order) { | ||
return true; | ||
} | ||
|
||
if (count($order->getItems()) > 5) { | ||
// only allow max 5 articles per order | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [\Isotope\Model\ProductCollection\Order#L235-L244](https://github.com/isotope/core/blob/2.8/system/modules/isotope/library/Isotope/Model/ProductCollection/Order.php#L235-L244) |
54 changes: 54 additions & 0 deletions
54
docs/manual/developer/hooks/preOrderStatusUpdate/_index.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: "preOrderStatusUpdate" | ||
--- | ||
|
||
The `preOrderStatusUpdate` hook is called before the order status is updated. | ||
|
||
## Parameters | ||
|
||
1. \Isotope\Model\ProductCollection\Order `$order` | ||
|
||
The order model. | ||
|
||
2. \Isotope\Model\OrderStatus `$newStatus` | ||
|
||
The new order status. | ||
|
||
3. `array $updates` | ||
|
||
The order status updates. | ||
|
||
## Return Values | ||
|
||
Return `true` to cancel the order status change. | ||
|
||
## Example | ||
|
||
```php | ||
// src/EventListener/Isotope/PreOrderStatusUpdateListener.php | ||
namespace App\EventListener\Isotope; | ||
|
||
use Isotope\Model\OrderStatus; | ||
use Isotope\Model\ProductCollection\Order; | ||
use Isotope\ServiceAnnotation\IsotopeHook; | ||
|
||
/** | ||
* @IsotopeHook("preOrderStatusUpdate") | ||
*/ | ||
class PreOrderStatusUpdateListener | ||
{ | ||
public function __invoke(Order $order, OrderStatus $newsStatus, array $updates): bool | ||
{ | ||
// Cancel the order status change if the order is not paid. | ||
if (!$order->isPaid()) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [\Isotope\Model\ProductCollection\Order#L308-L318](https://github.com/isotope/core/blob/2.8/system/modules/isotope/library/Isotope/Model/ProductCollection/Order.php##L308-L318) |
Oops, something went wrong.