Download the PHP package setono/sylius-wishlist-plugin without Composer

On this page you can find all versions of the php package setono/sylius-wishlist-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-wishlist-plugin

Wishlist Plugin for Sylius

Latest Version Build Status Code Coverage Mutation testing

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

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

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

Wishlists and items

Wishlist is an abstract resource with two concrete subclasses:

Class Belongs to Identified by
GuestWishlist an anonymous visitor a clientId (cookie, see below)
UserWishlist a logged-in Sylius\…\User\Model\UserInterface the user

Each wishlist holds WishlistItems. 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?

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

Anonymous visitors are identified through 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 & the toggle flow

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

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

Package Version
PHP ^8.1
Sylius ^1.13
Symfony ^6.4
Twig ^3.8

Installation

1. Require the package

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:

3. Import the routing

If your shop doesn't use locales in the URL, import routes_no_locale.yaml instead:

4. Update your database

The plugin ships Doctrine mappings; generate and run a migration for your app:

5. Install the assets

The toggle button's stylesheet and script are injected into the shop layout automatically (via sylius_ui events), but the JS file still needs to be published:

Usage

Add a wishlist button to your product page

Include the bundled partial wherever you render a product (e.g. the product box or the product show page), passing the product and – optionally – the selected productVariant:

It renders a heart button.ssw-toggle whose data-url points at the correct add/remove route and whose state reflects setono_sylius_wishlist_on_wishlist(...). No extra wiring is needed – the CSS/JS are already on the page.

React to toggles in JavaScript

Every toggle dispatches a bubbling ssw:product-toggled event:

You can override the handler's defaults by setting window.sswWishlist before the script loads (e.g. to change the selector.toggle or provide your own callback.onToggle).

Link to the wishlist

The wishlist index and a single (shareable) wishlist are available at these routes:

Route name Method Path
setono_sylius_wishlist_shop_wishlist_index GET /wishlists
setono_sylius_wishlist_shop_wishlist_show GET, PATCH /wishlists/{uuid}
setono_sylius_wishlist_shop_wishlist_add_to_cart GET /wishlists/{uuid}/add-to-cart
setono_sylius_wishlist_shop_wishlist_item_remove GET /wishlists/{uuid}/remove-item/{id}
setono_sylius_wishlist_shop_wishlist_add_product GET /wishlist/add-product/{id}
setono_sylius_wishlist_shop_wishlist_remove_product GET /wishlist/remove-product/{id}

(The *_product_variant variants of the add/remove routes exist too.) Because a wishlist is addressed by its uuid, the _show URL can be shared with anyone.

Customization

Override a resource

Models, repositories and factories follow the standard Sylius Resource configuration. To swap in your own model:

Provide your own wishlists

Implement Setono\SyliusWishlistPlugin\Provider\WishlistProviderInterface and tag it; the composite provider picks it up automatically (higher priority is consulted first):

Edit authorization

Edit actions are guarded by WishlistVoter (the wishlist_edit attribute), which grants access only when the subject wishlist belongs to the current visitor. Override the voter if you need different rules.

Development

The repository contains a full test Sylius application under tests/Application used for integration testing.

License

This plugin is released under the MIT License.


All versions of sylius-wishlist-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
doctrine/collections Version ^1.6
doctrine/persistence Version ^2.0 || ^3.0
setono/client-bundle Version ^1.2
setono/composite-compiler-pass Version ^1.2
setono/doctrine-orm-trait Version ^1.1
sylius/core Version ^1.13
sylius/core-bundle Version ^1.13
sylius/order Version ^1.13
sylius/product-bundle Version ^1.13
sylius/resource-bundle Version ^1.11
sylius/user Version ^1.13
symfony/config Version ^6.4
symfony/dependency-injection Version ^6.4
symfony/event-dispatcher Version ^6.4
symfony/form Version ^6.4
symfony/http-foundation Version ^6.4
symfony/http-kernel Version ^6.4
symfony/options-resolver Version ^6.4
symfony/routing Version ^6.4
symfony/security-bundle Version ^6.4
symfony/security-core Version ^6.4
symfony/security-http Version ^6.4
symfony/translation-contracts Version ^2.0 || ^3.0
symfony/uid Version ^6.4
twig/twig Version ^3.8
webmozart/assert Version ^1.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package setono/sylius-wishlist-plugin contains the following files

Loading the files please wait ...