Cart feature integration

Edit on GitHub

The following feature integration guide expects the basic feature to be in place.

The current feature integration guide only adds the Add product to cart from the Catalog page functionality.

Install feature core

Prerequisites

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

Name Version
Spryker Core 202108.0

1) Install the required modules using Composer

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

composer require spryker-feature/cart 202108.0 --update-with-dependencies

2) Add translations

Append glossary according to your configuration:

src/data/import/glossary.csv

global.add-to-cart,In den Warenkorb,de_DE
global.add-to-cart,Add to Cart,en_US
cart_page.error_message.unexpected_error,Unexpected error occurred.,en_US
cart_page.error_message.unexpected_error,Ein unerwarteter Fehler aufgetreten.,de_DE

Run the following console command to import data:

console data:import glossary
Verification

Make sure that above keys and corresponding translations are present in the spy_glossary_key and spy_glossary_translation tables.

Install feature frontend

Prerequisites

Please overview and install the necessary features before beginning the integration step.

NAME VERSION
Spryker Core 202108.0

1) Install the required modules using Composer

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

composer require spryker-feature/cart 202108.0 --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
CartPage vendor/spryker-shop/cart-page

2) Set up widgets

Register the following widgets:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
ProductAbstractAddToCartButtonWidget Displays a button for adding the product abstract to the cart in case the product is eligible. None SprykerShop\Yves\CartPage\Widget

src/Pyz/Yves/ShopApplication/ShopApplicationDependencyProvider.php

<?php

namespace Pyz\Yves\ShopApplication;

use SprykerShop\Yves\CartPage\Widget\ProductAbstractAddToCartButtonWidget;
use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider;

class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider
{
    /**
     * @return string[]
     */
    protected function getGlobalWidgets(): array
    {
        return [
            ProductAbstractAddToCartButtonWidget::class,
        ];
    }
}

Run the following command to enable Javascript and CSS changes:

console frontend:yves:build
Verification

Navigate to catalog and find an abstract product with single concrete. You should see a button for adding this concrete product to the cart right from the catalog page.