Persistent Cart Sharing feature integration

Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.

Install Feature Core

Prerequisites

To start feature integration, overview and install the necessary features:

Name Version
Spryker Core 201907.0
Resource Sharing 201907.0

1) Install the required modules using Composer

Run the following command(s) to install the required modules:

composer require spryker-feature/persistent-cart-sharing: "^201907.0" --update-with-dependencies
Verification
Make sure that the following modules were installed:
ModuleExpected Directory
`PersistentCartShare``vendor/spryker/persistent-cart-share`
`PersistentCartShareExtension``vendor/spryker/persistent-cart-share-extension`
### 2) Set up Transfer Objects Run the following commands to generate transfer changes: ```bash transfer:generate ```
Verification
Make sure that the following changes in transfer objects:
TransferTypeEventPath
`ResourceShareData.idQuote`propertyadded`src/Generated/Shared/Transfer/ResourceShareDataTransfer`
`ResourceShareData.ownerCompanyUserId`propertyadded`src/Generated/Shared/Transfer/ResourceShareDataTransfer`
`ResourceShareData.ownerCompanyBusinessUnitId`propertyadded`src/Generated/Shared/Transfer/ResourceShareDataTransfer`
## Install feature frontend ### Prerequisites Please overview and install the necessary features before beginning the integration step.
Name Version
Spryker Core 201907.0
Resource Sharing 201907.0
Customer Account Management 201907.0

1) Install the required modules using Composer

Run the following command(s) to install the required modules:

composer require spryker-feature/persistent-cart-sharing: "^201907.0" --update-with-dependencies
Verification
Make sure that the following modules were installed:
ModuleExpected Directory
`PersistentCartSharePage``vendor/spryker-shop/persistent-cart-share-page`
`PersistentCartShareWidget``vendor/spryker-shop/persistent-cart-share-widget`
### 2) Add Translations Append glossary according to your configuration:

src/data/import/glossary.csv

persistent_cart_share.error.resource_is_not_available,The cart you are trying to access is not available.,en_US
persistent_cart_share.error.resource_is_not_available,"Der Warenkorb, auf den Sie zugreifen möchten, ist nicht verfügbar.",de_DE
persistent_cart_share.error.quote_is_not_available,The cart you are trying to access is not available.,en_US
persistent_cart_share.error.quote_is_not_available,"Der Warenkorb, auf den Sie zugreifen möchten, ist nicht verfügbar.",de_DE
persistent_cart_share.share_options.external.PREVIEW,,en_US
persistent_cart_share.share_options.external.PREVIEW,,de_DE
persistent_cart_share.share_options.internal.READ_ONLY,Read Only,en_US
persistent_cart_share.share_options.internal.READ_ONLY,Schreibgeschützt,de_DE
persistent_cart_share.share_options.internal.FULL_ACCESS,Full Access,en_US
persistent_cart_share.share_options.internal.FULL_ACCESS,Ohne Einschränkung,de_DE
persistent_cart_share.copy,Copy,en_US
persistent_cart_share.copy,Kopieren,de_DE
persistent_cart_share.external_users,External Users,en_US
persistent_cart_share.external_users,Externe Benutzer,de_DE
persistent_cart_share.internal_users,Internal Users,en_US
persistent_cart_share.internal_users,Interne Benutzer,de_DE
persistent_cart_share.title,Share Cart via link,en_US
persistent_cart_share.title,Einkaufswagen per Link teilen,de_DE
clipboard.copy.success,Successfully copied to clipboard!,en_US
clipboard.copy.success,Erfolgreich in die Zwischenablage kopiert!,de_DE
clipboard.copy.error,Copying to clipboard is not supported by your browser. Try to copy the text manually.,en_US
clipboard.copy.error,Das Kopieren in die Zwischenablage wird von Ihrem Browser nicht unterstützt. Versuchen Sie den Text manuell zu kopieren.,de_DE
persistent_cart_share_page.preview,Preview: %title%,en_US
persistent_cart_share_page.preview,Vorschau: %title%,de_DE

Run the following console command to import data:

console data:import glossary
Verification
Make sure that in the database the configured data are added to the `spy_glossary` table.

3) Set up Behavior

Enable the following behaviors by registering the plugins:

Plugin Specification Prerequisites Namespace
CartPreviewRouterStrategyPlugin Redirects company user to the Cart Preview page if a cart was shared with Preview access. None SprykerShop\Yves\PersistentCartSharePage\Plugin
PreviewCartShareOptionPlugin Provides an external (preview) share option for the Share Cart via link widget. None Spryker\Client\PersistentCartShare\Plugin

src/Pyz/Yves/ResourceSharePage/ResourceSharePageDependencyProvider.php

<?php
 
namespace Pyz\Yves\ResourceSharePage;
 
use SprykerShop\Yves\PersistentCartSharePage\Plugin\CartPreviewRouterStrategyPlugin;
use SprykerShop\Yves\ResourceSharePage\ResourceSharePageDependencyProvider as SprykerResourceSharePageDependencyProvider;
 
class ResourceSharePageDependencyProvider extends SprykerResourceSharePageDependencyProvider
{
    /**
     * @return \SprykerShop\Yves\ResourceSharePageExtension\Dependency\Plugin\ResourceShareRouterStrategyPluginInterface[]
     */
    protected function getResourceShareRouterStrategyPlugins(): array
    {
        return [
            new CartPreviewRouterStrategyPlugin(),
        ];
    }
}

src/Pyz/Client/PersistentCartShare/PersistentCartShareDependencyProvider.php

<?php
 
namespace Pyz\Client\PersistentCartShare;
 
use Spryker\Client\PersistentCartShare\PersistentCartShareDependencyProvider as SprykerPersistentCartShareDependencyProvider;
use Spryker\Client\PersistentCartShare\Plugin\PersistentCartShare\PreviewCartShareOptionPlugin;
 
class PersistentCartShareDependencyProvider extends SprykerPersistentCartShareDependencyProvider
{
    /**
     * @return \Spryker\Client\PersistentCartShareExtension\Dependency\Plugin\CartShareOptionPluginInterface[]
     */
    protected function getCartShareOptionPlugins(): array
    {
        return [
            new PreviewCartShareOptionPlugin(),
        ];
    }
}
Verification
Make sure that when you followed cart share link with Preview access, you're redirected to the Cart Preview page.
Verification
Make sure, that you are able to share a cart with "Preview" access to external users from the cart page.

4) Enable Controllers

Route List

Register the following route provider plugins:

Provider Namespace
PersistentCartSharePageRouteProviderPlugin SprykerShop\Yves\PersistentCartSharePage\Plugin\Router
PersistentCartShareWidgetRouteProviderPlugin SprykerShop\Yves\PersistentCartShareWidget\Plugin\Router

src/Pyz/Yves/Router/RouterDependencyProvider.php

<?php

namespace Pyz\Yves\Router;

use Spryker\Yves\Router\RouterDependencyProvider as SprykerRouterDependencyProvider;
use SprykerShop\Yves\PersistentCartSharePage\Plugin\Router\PersistentCartSharePageRouteProviderPlugin;
use SprykerShop\Yves\PersistentCartShareWidget\Plugin\Router\PersistentCartShareWidgetRouteProviderPlugin;

class RouterDependencyProvider extends SprykerRouterDependencyProvider
{
    /**
     * @return \Spryker\Yves\RouterExtension\Dependency\Plugin\RouteProviderPluginInterface[]
     */
    protected function getRouteProvider(): array
    {
        return [
            new PersistentCartSharePageRouteProviderPlugin(),
            new PersistentCartShareWidgetRouteProviderPlugin(),
        ];
    }
}
Verification
Make sure, that when you proceed with `https://mysprykershop.com/cart/preview/xxx` link, you're redirected to the "404" page with "Resource is not found by provided UUID." error message.
Verification
Make sure, that when you're on a cart page, you can see the "Share Cart via Link" widget with an "External Users" radio button (if you logged in as company user
and when you click on it - the cart share link is generated successfully and placed in the appeared text box (requires `ShareCartByLinkWidget` to be enabled).)

5) Set up Widgets

Register the following plugins to enable widgets:

Plugin Descripton Prerequisites Namespace
ShareCartByLinkWidget Provides an ability to share a cart for External Users (Preview). None SprykerShop\Yves\PersistentCartShareWidget\Widget

src/Pyz/Yves/ShopApplication/ShopApplicationDependencyProvider.php

<?php
 
namespace Pyz\Yves\ShopApplication;
 
use SprykerShop\Yves\PersistentCartShareWidget\Widget\ShareCartByLinkWidget;
use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider;
 
class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider
{
    /**
     * @return string[]
     */
    protected function getGlobalWidgets(): array
    {
        return [
            ShareCartByLinkWidget::class,
        ];
    }
}

Run the following command to enable Javascript and CSS changes:

console frontend:yves:build
Verification
Make sure, that when you're on a cart page, you can see the "Share Cart via Link" widget with an "External Users" radio button (if you logged in as company user).
Verification
Login to Yves as Company User, add some product to the cart and go to the cart page.
Make sure, that you can see the "Share Cart via Link" widget on a cart page.
Make sure you can see an "External Users" radio button. Click on it.
Make sure, that you can see the generated link for Preview access.
Make sure, that you can see a "Copy" button near the link. Click on it.
Make sure, that the link was copied to the clipboard (or a message that it's impossible due to some browser limitations).
Copy the Cart Preview link and proceed with it. Make sure, that you are redirected to the Cart Preview page.