Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password reset workflow improvements #2393

Merged
merged 8 commits into from
Dec 18, 2023
53 changes: 53 additions & 0 deletions _includes/pbc/all/install-features/202403.0/enable-gift-cards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@


The Gift Cards feature is shipped with the following modules:

* **GiftCard**: implements the basic functionality of the Gift Cards feature as well as the Replacement value-checking strategy.

* **GiftCardBalance**: implements gift card Balance value-checking strategy<.

* **GiftCardMailConnector**: responsible for sending e-mails on gift cards usage (balance change) as well as gift cards codes delivery.

* **Nopayment**: implements payment methods if the price to pay is fully covered by a gift card.

To enable the gift cards in your project, do the following:

1. Make sure you have the correct versions of the required modules. To automatically update to the latest non-BC breaking versions, run `composer update "spryker/*"`
2. Require the modules in your `composer.json` by running:

```bash
composer require spryker/gift-card:"^1.0.0" spryker/gift-card-balance:"^1.0.0"
spryker/gift-card-mail-connector:"^1.0.0" spryker/nopayment:"^4.0.0"
spryker/product-management:"^0.12.0"
```

3. Enable necessary plugins. See the table below for information on available plugins, where to install them and value checking strategies they are used for.


| PLUGIN | DESCRIPTION | WHERE TO INSTALL | STRATEGY |
| --- | --- | --- | --- |
| `GiftCardCalculatorPlugin` | Splits applicable and non-applicable Gift Cards. Creates payment methods for applicable Gift Cards. |`CalculationDependencyProvider::getQuoteCalculatorPluginStack` | - |
| `GiftCardCurrencyMatchDecisionRulePlugin` |Doesn’t allow using a Gift Card with a different currency rather than the one the customer has used while performing the payment. | `GiftCardDependencyProvider::getDecisionRulePlugins` | - |
| `GiftCardIsActiveDecisionRulePlugin` | Doesn’t allow using inactive Gift Cards. |`GiftCardDependencyProvider::getDecisionRulePlugins` | - |
| `GiftCardDiscountableItemFilterPlugin` |Restricts using a Gift Card for another Gift Cards in a cart. The plugin filters out Gift Cards from discountable items. |`DiscountDependencyProvider::getDiscountableItemFilterPlugins` | - |
| `GiftCardIsUsedDecisionRulePlugin` | As a part of the replacement strategy, this plugin does not allow using a Gift Card twice. |`GiftCardDependencyProvider::getDecisionRulePlugins` | Replacement |
| `GiftCardMetadataExpanderPlugin` | Populates Gift Card information when it is in the cart. | `CartDependencyProvider::getExpanderPlugins` | - |
| `GiftCardCheckoutDoSaveOrderPlugin` | Saves a Gift Card with populated data when an order is placed. Keeps Gift Card as an order payment method. | `CheckoutDependencyProvider::getCheckoutOrderSavers` | - |
| `GiftCardPaymentMethodFilterPlugin` | Now, every payment method is compatible with a Gift Card in the cart. The plugin filters out all incompatible payment methods from available ones during checkout payment methods step. | `PaymentDependencyProvider::getPaymentMethodFilterPlugins` | - |
| `GiftCardCheckoutPreConditionPlugin` | Confirms that a Gift Card is not used at the moment and that payment method amount assigned to the Gift Card is no more than the Gift Card amount itself.. | `CheckoutDependencyProvider::getCheckoutPreConditions` | - |
| `GiftCardRecreateValueProviderPlugin` |For replacement: defines a Gift Card leftover. It’s simply a Gift Card amount for this strategy. | `GiftCardDependencyProvider::getValueProviderPlugin` | Replacement |
| `CreateGiftCardCommandPlugin` | It is an order management system command to create a Gift Card based on a paid order item (a Gift Card item). | `OmsDependencyProvider::extendCommandPlugins` | - |
| `ReplaceGiftCardsCommandPlugin` | For placement strategy: creates a new Gift Card based on leftover from the previous one. | `OmsDependencyProvider::extendCommandPlugins` | Replacement |
| `IsGiftCardConditionPlugin` | This plugin is used to define an order management system state machine process routing. | `OmsDependencyProvider::extendConditionPlugins` | - |
| `OnlyGiftCardShipmentMethodFilterPlugin` | Filters out shipment methods that are incompatible with Gift Cards. | `ShipmentDependencyProvider::getMethodFilterPlugins` | - |
| `BalanceCheckerApplicabilityPlugin` | For balance strategy: checks positive balance on a Gift Card. | `GiftCardDependencyProvider::getDecisionRulePlugins` | Balance |
| `BalanceTransactionLogPaymentSaverPlugin` | For balance strategy: persists a Gift Card during a payment processing. | `GiftCardDependencyProvider::getPaymentSaverPlugins` | Balance |
| `GiftCardBalanceValueProviderPlugin` | For balance strategy: provides available Gift Card amount. Gift Card amount equals to logged transactions. | `GiftCardDependencyProvider::getValueProviderPlugin` | Balance |
| `GiftCardDeliveryMailTypePlugin` | Sends an e-mail about a successfully issued Gift Card to a buyer. | `MailDependencyProvider::MAIL_TYPE_COLLECTION` | - |
| `GiftCardUsageMailTypePlugin` | Sends an e-mail on Gift Card usage to its user. | `MailDependencyProvider::MAIL_TYPE_COLLECTION` | - |
| `ShipGiftCardByEmailCommandPlugin` | An order management system command which triggers Gift Card electronic shipment. |`OmsDependencyProvider::extendCommandPlugins` | - |
| `NopaymentHandlerPlugin` | A payment method placeholder that is used when an order is paid by only a Gift Card without a real payment method. | `CheckoutDependencyProvider::extendPaymentMethodHandler` | - |
| `NopaymentCheckoutPreConditionPlugin` | Doesn’t allow placing an order with a price to pay more than 0 with a NoPayment payment method. | `CheckoutDependencyProvider::getCheckoutPreConditions` | - |
| `PriceToPayPaymentMethodFilterPlugin` | Filters payment methods based on cart totals. | `PaymentDependencyProvider::getPaymentMethodFilterPlugins` | - |
| `PaymentFormFilterPlugin` | Each payment method provides its subforms. The plugin filters them out based on an available payment method list. | `CheckoutDependencyProvider::getPaymentFormFilterPlugins` | - |
| `PaymentCalculatorPlugin` | Distributes total prices to payment methods. Calculates price to pay to quote totals. | `CalculationDependencyProvider::getQuoteCalculatorPluginStack` | - |
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@


CMS content widgets is a CMS feature for adding dynamic content to CMS pages/blocks.

For example, you can list a single product, product lists, product groups or product sets.

## Integration
First of all you need to install the `cms-content-widget` module with Composer (update composer.json with `"cms-content-widget": "^1.0.0"` or use Composer require).

To enable the feature, configure it in your project.

Integration of CMS widget consists of three main parts:

1. Registering twig function in Yves.
2. Providing configuration in module shared directory so that Yves and Zed can read it.
3. (Optionally) Providing CMS content function parameter mapper plugins.

### Step 1: Registering twig function in Yves.
The CMS content widget is a twig function. Therefore, twig syntax rules apply and must be followed when including the inside content.
For example, `{% raw %}{{{% endraw %} product(['012', '013', '321']) {% raw %}}}{% endraw %}` will include carousel component with three products.

To register a new function, you need to create a plugin which implements the `\Spryker\Yves\CmsContentWidget\Dependency\CmsContentWidgetPluginInterface` interface and place it in Yves application. Plugins are registered in `\Pyz\Yves\CmsContentWidget\CmsContentWidgetependencyProvider::getCmsContentWidgetPlugins` which is an array stored as key => value pairs,
where **key** is the function name you want to use in a template and **value** is a specific plugin instance. This plugin needs configuration which is explained in the next paragraph.

To enable the feature for CMS blocks, you have to configure twig rendering plugin `\Spryker\Yves\CmsContentWidget\Plugin\CmsTwigContentRendererPlugin` and add it to `\Pyz\Yves\CmsBlock\CmsBlockDependencyProvider::getCmsBlockTwigContentRendererPlugin`. This will enable twig function rendering in CMS blocks.

### Step 2: Providing CMS content widget configuration.

Some information needs to be shared between Yves and Zed. Therefore, the configuration plugin must be placed in a shared namespace.

**The new plugin must implement:** `\Spryker\Shared\CmsContentWidget\Depedency\CmsContentWidgetConfigurationProviderInterface` which is used by Yves and Zed.

When used in Yves, inject this plugin directly to your plugin and use configuration when building twig callable. When used in Zed, it should be added to the `\Pyz\Zed\CmsContentWidget\CmsContentWidgetConfig::getCmsContentWidgetConfigurationProviders` plugin array where key is the function name and value is the plugin instance. Providing it to Zed allows rendering usage information below the content editor.

The configuration provider requires implementation of the following methods:

* `getFunctionName` is the name of function when used in CMS content.
* `getAvailableTemplates` is the list of supported templates, it's a key value pair where key is the template identifier which is passed to function and value is a path to twig template.
* `getUsageInformation` is a plain text usage information, displayed when rendering help pane below the content editor.

### Step 3: Function mapping plugins - optional.

When defining functions, you may want to accept "natural identifiers", such as "sku" for products or "set_key" for product sets. It is preferable that the content manager provides the identifiers instead of relying on surrogate keys. The problem arises when you need to read data from the Yves data store as the Yves data store uses "surrogate key/primary keys". Therefore, to read data, convert/map those natural identifiers to surrogate keys.

We provide mappers to help map the identifiers. Each mapper must implement: `\Spryker\Zed\CmsContentWidget\Dependency\Plugin\CmsContentWidgetParameterMapperPluginInterface` and be added to `\Pyz\Zed\Cms\CmsDependencyProvider::getCmsContentWidgetParameterMapperPlugins` where **key** is the function name and **value** is a specific mapper.

The mapper receives unmapped values where your plugin is responsible for mapping and returning it as an array. Mapper plugins are invoked by CMS and block collectors. To export this data, you must register two plugins one for CMS pages and one for CMS blocks.

For `CmsBlockCollector`, add plugin `\Spryker\Zed\CmsContentWidget\Communication\Plugin\CmsBlockCollector\CmsBlockCollectorParameterMapExpanderPlugin` to `\Pyz\Zed\CmsBlockCollector\CmsBlockCollectorDependencyProvider::getCollectorDataExpanderPlugins`.

For `CmsCollector`, add plugin `\Spryker\Zed\CmsContentWidget\Communication\Plugin\CmsPageCollector\CmsPageCollectorParameterMapExpanderPlugin` to `\Pyz\Zed\CmsCollector\CmsCollectorDependencyProvider::getCollectorDataExpanderPlugins`.

Make sure to update the `CmsBlockCollector` and `CmsCollector` modules as expander plugins were added during this feature release. It's exported to `\Spryker\Shared\CmsContentWidget\CmsContentWidgetConstants::CMS_CONTENT_WIDGET_PARAMETER_MAP`. You can access parameter mapping inside the ` $contex` variable when implementing the CMS content function plugin in Yves.

The `$context` is a special twig function variable that uses twig to pass the data you normally send to the template. This variable has a `cmsContent` key. This key has data from the Yves store. This can be either a CMS page or block data.

The parameter mapping can be read from:

```bash
$context['cmsContent'][CmsContentWidgetConstants::CMS_CONTENT_WIDGET_PARAMETER_MAP][$this->widgetConfiguration->getFunctionName()];
```

For example, you can use this method as a basis when implementing `\Spryker\Yves\CmsContentWidget\Dependency\CmsContentWidgetPluginInterface`.

```php
namespace Spryker\Yves\Module\Plugin;

class CmsWidgetPlugin extends AbstractPlugin implements CmsContentWidgetPluginInterface
{
/**
* @return \Callable
*/
public function getContentWidgetFunction()
{
return function (Twig_Environment $twig, array $context, $parameters, $templateIdentifier = null) {
return $twig->render(
$this->resolveTemplatePath($templateIdentifier),
$this->getContent($context, $parameters)
);
};
}

/**
* @param null|string $templateIdentifier
*
* @return string
*/
protected function resolveTemplatePath($templateIdentifier = null)
{
return '@Module/partials/function_template.twig'
}

/**
* @param array $context
* @param array|string $parameters
*
* @return array
*/
protected function getContent(array $context, $parameters)
{
return []; //return data to be inserted into template
}

}
```

## Provided Plugins
We provide three CMS content widget plugins . All are currently implemented in the demoshop so you can take them from our repository and integrate in your project.

Plugin configuration is described below.

### Zed Plugins:

```php
namespace Pyz\Zed\CmsContentWidget;
class CmsContentWidgetConfig extends SprykerCmsContentConfig
{
/**
* {@inheritdoc}
*
* @return array|\Spryker\Shared\CmsContentWidget\CmsContentWidget\CmsContentWidgetConfigurationProviderInterface[]
*/
public function getCmsContentWidgetConfigurationProviders()
{
return [
\Spryker\Shared\CmsContentWidgetProductConnector\ContentWidgetConfigurationProvider\CmsProductContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Shared\CmsProductConnector\ContentWidgetConfigurationProvider\CmsProductContentWidgetConfigurationProvider(),
\Spryker\Shared\CmsContentWidgetProductSetConnector\ContentWidgetConfigurationProvider\CmsProductSetContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Shared\CmsProductSetConnector\ContentWidgetConfigurationProvider\CmsProductSetContentWidgetConfigurationProvider(),
\Spryker\Shared\CmsContentWidgetProductGroupConnector\ContentWidgetConfigurationProvider\CmsProductGroupContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Shared\CmsProductGroupConnector\ContentWidgetConfigurationProvider\CmsProductGroupContentWidgetConfigurationProvider(),
];
}
}
```

### Zed CMS Configuration Providers:

```php
namespace Pyz\Zed\CmsContentWidget;
class CmsContentWidgetConfig extends SprykerCmsContentConfig
{
/**
* {@inheritdoc}
*
* @return array|\Spryker\Shared\CmsContentWidget\CmsContentWidget\CmsContentWidgetConfigurationProviderInterface[]
*/
public function getCmsContentWidgetConfigurationProviders()
{
return [
\Spryker\Shared\CmsContentWidgetProductConnector\ContentWidgetConfigurationProvider\CmsProductContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Shared\CmsProductConnector\ContentWidgetConfigurationProvider\CmsProductContentWidgetConfigurationProvider(),
\Spryker\Shared\CmsContentWidgetProductSetConnector\ContentWidgetConfigurationProvider\CmsProductSetContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Shared\CmsProductSetConnector\ContentWidgetConfigurationProvider\CmsProductSetContentWidgetConfigurationProvider(),
\Spryker\Shared\CmsContentWidgetProductGroupConnector\ContentWidgetConfigurationProvider\CmsProductGroupContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Shared\CmsProductGroupConnector\ContentWidgetConfigurationProvider\CmsProductGroupContentWidgetConfigurationProvider(),
];
}
}
```

### Zed CMS Collector Parameter Mapper Plugins:

```php
namespace Pyz\Zed\CmsContentWidget;

class CmsContentWidgetDependencyProvider extends SprykerCmsContentWidgetDependencyProvider
{

/**
* {@inheritdoc}
*
* @param \Spryker\Zed\Kernel\Container $container
*
* @return array|\Spryker\Zed\CmsContentWidget\Dependency\Plugin\CmsContentWidgetParameterMapperPluginInterface[]
*/
protected function getCmsContentWidgetParameterMapperPlugins(Container $container)
{
return [
\Spryker\Shared\CmsProductConnector\ContentWidgetConfigurationProvider\CmsProductContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Zed\CmsProductConnector\Communication\Plugin\Cms\CmsProductSkuMapperPlugin(),
\Spryker\Shared\CmsProductSetConnector\ContentWidgetConfigurationProvider\CmsProductSetContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Zed\CmsProductSetConnector\Communication\Plugin\Cms\CmsProductSetKeyMapperPlugin(),
\Spryker\Shared\CmsProductGroupConnector\ContentWidgetConfigurationProvider\CmsProductGroupContentWidgetConfigurationProvider::FUNCTION_NAME => new \Spryker\Zed\CmsProductConnector\Communication\Plugin\Cms\CmsProductSkuMapperPlugin(),
];
}

}
```

### Yves Plugin Dependencies

```php
namespace Pyz\Zed\CmsContentWidget;

use Spryker\Shared\CmsContentWidgetProductConnector\ContentWidgetConfigurationProvider\CmsProductContentWidgetConfigurationProvider;
use Spryker\Shared\CmsContentWidgetProductGroupConnector\ContentWidgetConfigurationProvider\CmsProductGroupContentWidgetConfigurationProvider;
use Spryker\Shared\CmsContentWidgetProductSetConnector\ContentWidgetConfigurationProvider\CmsProductSetContentWidgetConfigurationProvider;
use Spryker\Zed\CmsContentWidget\CmsContentWidgetConfig as SprykerCmsContentConfig;

class CmsContentWidgetConfig extends SprykerCmsContentConfig
{
/**
* {@inheritdoc}
*
* @return array|\Spryker\Shared\CmsContentWidget\Dependency\CmsContentWidgetConfigurationProviderInterface[]
*/
public function getCmsContentWidgetConfigurationProviders()
{
return [
CmsProductContentWidgetConfigurationProvider::FUNCTION_NAME => new CmsProductContentWidgetConfigurationProvider(),
CmsProductSetContentWidgetConfigurationProvider::FUNCTION_NAME => new CmsProductSetContentWidgetConfigurationProvider(),
CmsProductGroupContentWidgetConfigurationProvider::FUNCTION_NAME => new CmsProductGroupContentWidgetConfigurationProvider(),
];
}
}
```

<!--
### Demoshop - Add Twig Function for Your Application Scope

Open your YvesBootstrap `src/Pyz/Yves/AApplication/YvesBootstrap.php` and add the `CmsContentWidgetServiceProvider` provider to `registerServiceProviders`:

```php
namespace Pyz\Yves\Application;

...

class YvesBootstrap
{

...

/**
* @return void
*/
protected function registerServiceProviders()
{
...
$this->application->register(new CmsContentWidgetServiceProvider());
}
}
```
-->

### Version Check When Using the Widget for CMS Blocks
If you use this widget for CMS Blocks, then check that you have proper versions of your modules as follows: `cms-block >= 1.2.0, cms-block-collector >= 1.1.0, cms-block-gui >= 1.1.0`.

<!-- Last review date: Sep 20, 2017 -->

[//]: # (by Denis Turkov)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


The integration guides provide step-by-step instructions on how to enable individual Spryker features for your project.

Please keep in mind, that since Spryker Commerce OS is a highly modular system, you have total freedom in choosing what features to add to your project. When making a decision to install new features, we recommend not to bloat your project by installing everything, but opt for the features that are really justified in terms of your business needs.

If you have spotted an issue with either of the guides, please feel free to [create an issue](https://github.com/spryker/spryker-docs/issues) or pull request by using the Edit on GitHub option.

Not found an integration guide you are looking for? Let us know about it by [creating an issue on Github](https://github.com/spryker/spryker-docs/issues) or dropping an email to [documentation@spryker.com](mailto:documentation@spryker.com).
Loading
Loading