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

CC-13685: Updated product quantity and total in Mini Cart Widget from catalog AJAX add-to-cart action. #2799

Merged
merged 5 commits into from
Sep 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ Make sure the following modules have been installed:

Set up the following configuration:

| CONFIGURATION | SPECIFICATION | NAMESPACE |
|----------------------------------------------------------------|--------------------------------------------------|---------------------------|
| CartPageConfig::IS_CART_CART_ITEMS_VIA_AJAX_LOAD_ENABLED | Enables the loading of cart items via AJAX. | SprykerShop\Yves\CartPage |
| CartPageConfig::IS_LOADING_UPSELLING_PRODUCTS_VIA_AJAX_ENABLED | Enables the loading of upselling products via AJAX. | SprykerShop\Yves\CartPage |
| CartPageConfig::IS_CART_ACTIONS_ASYNC_MODE_ENABLED | Enables the performing of cart actions via AJAX. | SprykerShop\Yves\CartPage |
| CONFIGURATION | SPECIFICATION | NAMESPACE |
|----------------------------------------------------------------|----------------------------------------------------------------------|------------------------------|
| CartPageConfig::IS_CART_CART_ITEMS_VIA_AJAX_LOAD_ENABLED | Enables the loading of cart items via AJAX. | SprykerShop\Yves\CartPage |
| CartPageConfig::IS_LOADING_UPSELLING_PRODUCTS_VIA_AJAX_ENABLED | Enables the loading of upselling products via AJAX. | SprykerShop\Yves\CartPage |
| CartPageConfig::IS_CART_ACTIONS_ASYNC_MODE_ENABLED | Enables the performing of cart actions via AJAX. | SprykerShop\Yves\CartPage |
| CatalogPageConfig::IS_MINI_CART_ASYNC_MODE_ENABLED | Enables async rendering of mini cart during AJAX add to cart action. | SprykerShop\Yves\CatalogPage |

**src/Pyz/Yves/CartPage/CartPageConfig.php**

Expand Down Expand Up @@ -130,18 +131,42 @@ class CartPageConfig extends SprykerCartPageConfig
*/
protected const IS_CART_ACTIONS_ASYNC_MODE_ENABLED = true;
}

```

{% info_block warningBox "Verification" %}

Make sure the following applies:
Make sure the following applies (in Cart page):
- Cart items are loaded via AJAX.
- Upselling products are loaded via AJAX.
- Cart actions, like changing item quantity or removing an item, are performed via AJAX.

{% endinfo_block %}

**src/Pyz/Yves/CatalogPage/CatalogPageConfig.php**

```php
<?php

namespace Pyz\Yves\CatalogPage;

use SprykerShop\Yves\CatalogPage\CatalogPageConfig as SprykerCatalogPageConfig;

class CatalogPageConfig extends SprykerCatalogPageConfig
{
/**
* @var bool
*/
protected const IS_MINI_CART_ASYNC_MODE_ENABLED = true;
}
```

{% info_block warningBox "Verification" %}

Make sure the following applies (in Catalog page):
- Cart actions, like changing item quantity or removing an item, are performed via AJAX.

{% endinfo_block %}

### 3) Enable controllers

Register the following route providers on the Storefront:
Expand Down Expand Up @@ -199,7 +224,67 @@ class RouterDependencyProvider extends SprykerRouterDependencyProvider

{% endinfo_block %}

### 4) Set up widgets
### 4) Set up behavior

Activate the following plugins:

| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
|--------------------------------------|------------------------------------------------------------------|---------------|-------------------------------------------|
| CartBlockMiniCartViewExpanderPlugin | Expands the provided `MiniCartView.content` with mini cart view. | None | SprykerShop\Yves\CartPage\Plugin\CartPage |

**src/Pyz/Yves/Router/RouterDependencyProvider.php**

```php
<?php

namespace Pyz\Yves\CartPage;

use SprykerShop\Yves\CartPage\CartPageDependencyProvider as SprykerCartPageDependencyProvider;
use SprykerShop\Yves\CartPage\Plugin\CartPage\CartBlockMiniCartViewExpanderPlugin;

class CartPageDependencyProvider extends SprykerCartPageDependencyProvider
{
/**
* @return array<\SprykerShop\Yves\CartPageExtension\Dependency\Plugin\MiniCartViewExpanderPluginInterface>
*/
protected function getMiniCartViewExpanderPlugins(): array
{
return [
new CartBlockMiniCartViewExpanderPlugin(),
];
}
}
```

{% info_block warningBox "Verification" %}

It's an optional step. Only B2C Demo Shop uses this plugin due to custom mini cart implementation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like verification

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you right, do you have any suggestion where I could left such information?

For the B2C setup you should also specify the following configuration:

**src/Pyz/Yves/CartPage/CartPageConfig.php**

```php
<?php

namespace Pyz\Yves\CartPage;

use SprykerShop\Yves\CartPage\CartPageConfig as SprykerCartPageConfig;

class CartPageConfig extends SprykerCartPageConfig
{
/**
* @var string
*/
protected const CART_BLOCK_MINI_CART_VIEW_TEMPLATE_PATH = '@ShopUi/components/organisms/navigation-top-async/navigation-top-async.twig';
}
```

Make sure the following applies (in Cart page):
- Cart actions, like changing item quantity or removing an item, are reflected in the mini cart.

{% endinfo_block %}

### 5) Set up widgets

1. Register the following widgets:

Expand Down
Loading