PHPackages                             setono/sylius-wishlist-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. setono/sylius-wishlist-plugin

ActiveSylius-plugin[Utility &amp; Helpers](/categories/utility)

setono/sylius-wishlist-plugin
=============================

Setono example plugin for Sylius.

v1.0.0(1w ago)05.9k[1 issues](https://github.com/Setono/sylius-wishlist-plugin/issues)[1 PRs](https://github.com/Setono/sylius-wishlist-plugin/pulls)MITPHPPHP &gt;=8.1CI passing

Since Feb 3Pushed 1w ago1 watchersCompare

[ Source](https://github.com/Setono/sylius-wishlist-plugin)[ Packagist](https://packagist.org/packages/setono/sylius-wishlist-plugin)[ GitHub Sponsors](https://github.com/Setono)[ RSS](/packages/setono-sylius-wishlist-plugin/feed)WikiDiscussions 1.x Synced 3d ago

READMEChangelog (2)Dependencies (97)Versions (6)Used By (0)

Wishlist Plugin for Sylius
==========================

[](#wishlist-plugin-for-sylius)

[![Latest Version](https://camo.githubusercontent.com/57793d7ec9ded54ffdc27ce57757eaed86ba89f3ed7095310f4a125b44328ed1/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f73796c6975732d776973686c6973742d706c7567696e2f762f737461626c65)](https://packagist.org/packages/setono/sylius-wishlist-plugin)[![Software License](https://camo.githubusercontent.com/199b510e59eaf385bb24761c1c9e5f92fbd270ef98be9f70a471ebc0f61113f0/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f73796c6975732d776973686c6973742d706c7567696e2f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/sylius-wishlist-plugin/workflows/build/badge.svg)](https://github.com/Setono/sylius-wishlist-plugin/actions)[![Code Coverage](https://camo.githubusercontent.com/106aa435c6ef741f876844e8f0307d3600864cc4811929019d71a4cd425be0ab/68747470733a2f2f636f6465636f762e696f2f67682f5365746f6e6f2f73796c6975732d776973686c6973742d706c7567696e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Setono/sylius-wishlist-plugin)[![Mutation testing](https://camo.githubusercontent.com/d4a43cb1088227565df7f554c2aeb73c0e5d5840ae41f8f2a2c3df9e3f53be28/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532465365746f6e6f25324673796c6975732d776973686c6973742d706c7567696e2532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/Setono/sylius-wishlist-plugin/master)

Add a **wishlist** (a.k.a. *favourites* / *save for later*) to your Sylius store. Visitors can save products whether or not they're logged in, the wishlist follows them from anonymous browsing into their account, and they can move everything to the cart in one click.

Features
--------

[](#features)

- 🛍️ **Guest *and* customer wishlists** – anonymous visitors get a wishlist tied to a cookie; logged-in customers get one tied to their account.
- 🔄 **Automatic hand-off on login** – when a guest with a wishlist logs in, their items are moved onto their customer wishlist, so nothing is lost.
- ❤️ **Drop-in toggle button** – a ready-made "heart" button that adds/removes a product (or a specific variant) over AJAX, plus a JS event you can hook into.
- 🛒 **Add the whole wishlist to the cart** in a single request.
- 📝 **Per-item notes** – shoppers can add a free-text note to each wishlist item (e.g. a size or colour preference), editable by the owner and visible to anyone they share the wishlist with.
- 🔗 **Shareable wishlists** – every wishlist has a UUID, so it can be viewed via a stable, shareable URL.
- 🧩 **Extensible** – all resources (models, repositories, factories) are overridable, and the "whose wishlist is this?" logic is a tagged service you can plug into.

> **Heads up:** the data model already supports *multiple wishlists per customer*, but the UI/flow for choosing between them is still a work in progress (the `select-wishlists` endpoint currently returns *Not implemented*).

How it works
------------

[](#how-it-works)

A few concepts are worth understanding before you integrate the plugin.

### Wishlists and items

[](#wishlists-and-items)

`Wishlist` is an abstract resource with two concrete subclasses:

ClassBelongs toIdentified by`GuestWishlist`an anonymous visitora `clientId` (cookie, see below)`UserWishlist`a logged-in `Sylius\…\User\Model\UserInterface`the userEach wishlist holds `WishlistItem`s. An item references either a **product** or a specific **product variant**(plus a quantity and an optional free-text note), and every wishlist exposes a `uuid` (UUID v7) used in its public, shareable URL.

### Who owns the current wishlist?

[](#who-owns-the-current-wishlist)

Everything in the plugin asks one service – `WishlistProviderInterface` – for *"the current visitor's wishlists"*. It's a composite built from two tagged providers, consulted by priority, returning the first non-empty result:

1. `UserWishlistProvider` – the wishlists of the logged-in customer (via Symfony Security).
2. `GuestWishlistProvider` – the guest wishlist for the current cookie client id.

The result is memoized for the duration of the request by a caching decorator. To add another source (e.g. a shared/team wishlist), implement `WishlistProviderInterface` and tag it – you never touch the composite itself.

### Guest identity

[](#guest-identity)

Anonymous visitors are identified through [`setono/client-bundle`](https://packagist.org/packages/setono/client-bundle), which assigns a stable client id stored in a cookie. That id keys the guest wishlist. When the visitor authenticates, a login subscriber (`ConvertGuestWishlistToUserWishlistSubscriber`) converts the guest wishlist into a user wishlist.

### Templates &amp; the toggle flow

[](#templates--the-toggle-flow)

The plugin exposes two Twig functions so your templates can react to wishlist state:

```
{# is this product (or variant) on the current visitor's wishlist? #}
{{ setono_sylius_wishlist_on_wishlist(product) }}   {# returns a bool #}

{# does the current visitor have any non-empty wishlist? #}
{{ setono_sylius_wishlist_has_wishlist() }}          {# returns a bool #}
```

Adding/removing happens against small JSON endpoints. The bundled `wishlist-action-handler.js` listens for clicks on `button.ssw-toggle`, calls the endpoint, flips the button state, and dispatches a `ssw:product-toggled` event you can listen to (e.g. to update a header counter).

Requirements
------------

[](#requirements)

PackageVersionPHP`^8.1`Sylius`^1.13`Symfony`^6.4`Twig`^3.8`Installation
------------

[](#installation)

### 1. Require the package

[](#1-require-the-package)

```
composer require setono/sylius-wishlist-plugin
```

### 2. Register the plugin

[](#2-register-the-plugin)

Add the bundle to `config/bundles.php` **before** `SyliusGridBundle`, otherwise you'll get a `You have requested a non-existent parameter "setono_sylius_wishlist.model.wishlist.class"` exception:

```
