How to Implement the Quickly Add to Cart Feature?

This feature allows users to quickly add products to their basket from the listing pages. A button is displayed on the bottom-right corner of each product, enabling users to view product variants without navigating to the detailed product page. Variants can then be selected and added to the cart directly. This functionality aims to streamline the shopping process, save time, and improve conversion rates and reduce drop-offs caused by lengthy navigation processes.

Technical Requirements and Prerequisites​

  • Compatibility: The feature is supported in @akinon/next versions between 1.43.0-rc.14 and 1.72.0.

Implementation Steps​

1. Adding the Button to Product Item​

To display the "Quickly Add to Cart" button on product items, add the following code block to the desired location in src/views/product-item/index.tsx:

2. Creating Components for Variants​

Color Variants Component​

A variants folder should be created within the src/views/product-item directory, and a color-variant.tsx file with the following code should be added inside it.

This component ensures that color variants are displayed on the listing page if available:

Show Variants Component​

A variants folder should be created within the src/views/product-item directory, and a show-variant.tsx file with the following code should be added inside it.

This component handles the display of size and color variants:

Size Variants Component​

A variants folder should be created within the src/views/product-item directory, and a size-variant.tsx file with the following code should be added inside it.

This component displays size variants for products:

3. Creating Variant Modal Component​

A variants folder should be created within the src/views/product-item directory, and a variant-modal.tsx file with the following code should be added inside it.

This modal is displayed when the "Quickly Add to Cart" button is clicked:

4. Creating Basket Drawer Component​

Create a basket-drawer.tsx file under src/views/basket with the following code.

This component displays the cart drawer that slides out when an item is added to the cart:

Last updated

Was this helpful?