-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #618 from extcode/615-allow-fevariant-to-have-a-price
[TASK] Allow FeVariant to have a price
- Loading branch information
Showing
10 changed files
with
119 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Extcode\Cart\Domain\Model\Cart; | ||
|
||
interface FeVariantInterface | ||
{ | ||
public function getId(): string; | ||
|
||
public function getVariantData(): array; | ||
|
||
public function getTitle(): string; | ||
|
||
public function getSku(): string; | ||
|
||
public function getValue(): string; | ||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace Extcode\Cart\Domain\Model\Cart; | ||
|
||
interface FeVariantWithPriceInterface extends FeVariantInterface | ||
{ | ||
public function getPrice(): float; | ||
} |
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
50 changes: 50 additions & 0 deletions
50
Documentation/Changelog/9.4/Feature-615-AllowFeVariantToHaveAPrice.rst
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 @@ | ||
.. include:: ../../Includes.rst.txt | ||
|
||
=============================================== | ||
Feature: #615 - Allow FeVariant to have a price | ||
=============================================== | ||
|
||
See `Issue 615 <https://github.com/extcode/cart/issues/615>`__ | ||
|
||
Description | ||
=========== | ||
|
||
The default `FeVariant` implementation cannot have a price. In order to be able | ||
to process own `FeVariant`s with a price, the method arguments should use a | ||
`FeVariantInterface` instead. | ||
|
||
The `FeVariantWithPriceInterface` extends the `FeVariantInterface` with a | ||
`getPrice()` method. | ||
The price calculation of a product then takes into account whether the | ||
`FeVariant` implements the `FeVariantWithPriceInterface` to add this price as | ||
well. | ||
|
||
To create an own `FeVariant` for a `Product`, you have to replace the | ||
`CreateCartFrontendVariants` EventListener. | ||
|
||
.. code-block:: yaml | ||
:caption: EXT:my_extension/Configuration/Services.yaml | ||
Extcode\CartProducts\EventListener\Create\CreateCartFrontendVariants: null | ||
MyVendor\MyExtension\EventListener\Create\CreateCartFrontendVariants: | ||
tags: | ||
- name: event.listener | ||
identifier: 'cart-products--create--create-cart-frontend-variants' | ||
event: Extcode\CartProducts\Event\RetrieveProductsFromRequestEvent | ||
after: 'cart-products--create--load-product' | ||
This is very flexible. You can implement `FeVariant`s as checkboxes and add some | ||
surcharge for some options. Another idea is to calculate the price markup | ||
depending on the number of characters entered.How you can use this is up to you. | ||
However, you should test carefully whether the price calculation for the product | ||
price then fits, especially if you use more than one front-end variant with a | ||
price for a product. | ||
|
||
Impact | ||
====== | ||
|
||
No Impact. | ||
|
||
.. index:: Frontend, API |
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,20 @@ | ||
.. include:: ../../Includes.rst.txt | ||
|
||
9.4 Changes | ||
=========== | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 1 | ||
|
||
Features | ||
-------- | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:titlesonly: | ||
:glob: | ||
|
||
Feature-* |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ ChangeLog | |
:maxdepth: 5 | ||
:titlesonly: | ||
|
||
9.4/Index | ||
9.3/Index | ||
9.1/Index | ||
9.0/Index | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
'title' => 'Cart', | ||
'description' => 'Shopping Cart(s) for TYPO3', | ||
'category' => 'plugin', | ||
'version' => '9.3.0', | ||
'version' => '9.4.0', | ||
'state' => 'stable', | ||
'author' => 'Daniel Gohlke', | ||
'author_email' => '[email protected]', | ||
|