2017 © Pedro Peláez
 

sylius-plugin sylius-wishlist-bundle

Wishlist plugin for Sylius e-commerce platform.

image

webburza/sylius-wishlist-bundle

Wishlist plugin for Sylius e-commerce platform.

  • Wednesday, July 11, 2018
  • by ychanan
  • Repository
  • 2 Watchers
  • 16 Stars
  • 1,689 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 25 Forks
  • 11 Open issues
  • 11 Versions
  • 3 % Grown

The README.md

Sylius Wishlist Plugin

This bundle adds wishlist functionality to Sylius e-commerce platform. It can be configured to use single or multiple wishlists per user, which can be public or private., (*1)


, (*2)


Installation

  1. require the bundle with Composer:, (*3)

    $ composer require webburza/sylius-wishlist-plugin
    
  2. enable the bundle in app/AppKernel.php:, (*4)

    public function registerBundles()
    {
    $bundles = [
      // ...
      new \Webburza\SyliusWishlistPlugin\WebburzaSyliusWishlistPlugin(),
      // ...
    ];
    }
    
  3. add configuration to the top of app/config/config.yml:, (*5)

    imports:
      - { resource: "@WebburzaSyliusWishlistPlugin/Resources/config/config.yml" }
    

    Among other things, this provides configuration entries which can then be overriden in your app's config.yml., (*6)

    webburza_sylius_wishlist:
      multiple: true           # multiple wishlist mode
      default_public: false    # used for automatically created wishlists
    
  4. register routes in app/config/routing.yml, (*7)

    webburza_sylius_wishlist:
    resource: "@WebburzaSyliusWishlistPlugin/Resources/config/routing.yml"
    
  5. The bundle should now be fully integrated, but it still requires database tables to be created. For this, we recommend using migrations., (*8)

    $ bin/console doctrine:migrations:diff
    $ bin/console doctrine:migrations:migrate
    

    Or if you don't use migrations, you can update the database schema directly., (*9)

    $ bin/console doctrine:schema:update
    
  6. If you're integrating this bundle into an existing project, your existing users will not have any wishlists associated. This is not an issue as wishlists are automatically created when needed., (*10)

Integration on shop pages

Now that you've installed and integrated the bundle, the users can view their wishlists, create new ones, etc, depending on bundle configuration, but they still have no way of adding products to wishlists. Since each project will have custom product pages, this implementation is up to you. It can be done in two ways., (*11)

  1. Simple, (*12)

    Since 'add to wishlist' functionality is almost the same as adding items to cart, the simplest way to finalize integration is to add a new 'Add to wishlist' button next to the 'Add to cart' button in the existing form., (*13)

    Open the template containing your 'add to cart' form, most likely in: app/Resources/SyliusShopBundle/views/Product/Show/_addToCart.html.twig, (*14)

    Find the 'add to cart' button, by default:, (*15)

    <button type="submit" class="ui huge primary icon labeled button"><i class="cart icon"></i> {{ 'sylius.ui.add_to_cart'|trans }}</button>
    

    And under it, add the following line., (*16)

    {% include '@WebburzaSyliusWishlistPlugin/Shop/Misc/_addToWishlist.html.twig' %}
    

    This will include the 'Add to Wishlist' button, and all required functionality. It will also feature a dropdown if the user has more than one wishlist, to enable the user to select which wishlist they want to add the item to., (*17)

    The dropdown will only be rendered if the user has more than one wishlist., (*18)

  2. Custom AJAX implementation, (*19)

    An alternative is to implement your own, fully custom 'add to wishlist' functionality. To accomplish this, submit data to the webburza_wishlist_frontend_add_item route., (*20)

    $.ajax({
      url: '/wishlist/item',
      type: 'POST',
      data: {
          productVariantId: 123,
          wishlistId: 456 // optional
      },
      success: // ...
    });
    

    You can also submit the data in the same format as in the first example (the 'add-to-cart' form), both examples use the same route, and both accept variant data to be resolved (first example), or an already resolved productVariantId., (*21)

Wishlist badge

You might also want to feature a badge in your header which links to the wishlist and shows the current number of items added, similar to the existing cart badge., (*22)

To do this, just add this line to the bottom of the same file app/Resources/SyliusShopBundle/views/Cart/_widget.html.twig, (*23)

{% include '@WebburzaSyliusWishlistPlugin/Shop/Misc/_badge.html.twig' %}

Translations and naming

The bundle has multilingual support, and language files can be overridden as with any other bundle, by creating translation files in the app/Resources/WebburzaSyliusWishlistPlugin/translations directory., (*24)

To get started, check the bundle's main language file in: src/Resources/translations/messages.en.yml, (*25)

Running and testing the application manually

  • Initial installation and fixtures:, (*26)

    $ composer install
    
    $ (cd tests/Application && yarn install)
    $ (cd tests/Application && yarn run gulp)
    $ (cd tests/Application && bin/console assets:install web -e dev)
    
    $ (cd tests/Application && bin/console doctrine:database:create -e dev)
    $ (cd tests/Application && bin/console doctrine:schema:create -e dev)
    $ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
    
  • Start application:, (*27)

    $ (cd tests/Application && bin/console server:start -d web -e dev)
    
  • Stop application:, (*28)

    $ (cd tests/Application && bin/console server:stop)
    

Automated tests

  • Behat (non-Javascript scenarios), (*29)

    $ bin/behat --tags="~@javascript"
    
  • Behat (with Javascript scenarios), (*30)

    1. Download Chromedriver, (*31)

    2. Run Selenium server with previously downloaded Chromedriver:, (*32)

      $ bin/selenium-server-standalone -Dwebdriver.chrome.driver=/path/to/chromedriver
      
    3. Run test application's webserver on localhost:8080:, (*33)

      $ (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web -e test)
      
    4. Run Behat:, (*34)

      $ bin/behat
      

License

This bundle is available under the MIT license., (*35)

The Versions

12/01 2017

v0.4.2

0.4.2.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

12/01 2017

dev-master-1-0-beta

dev-master-1-0-beta

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

12/01 2017

dev-develop

dev-develop

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

12/01 2017

v0.4.1

0.4.1.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

11/01 2017

v0.4.0

0.4.0.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

06/09 2016

v0.3.0

0.3.0.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

09/06 2016

v0.2.0

0.2.0.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

09/06 2016

dev-feature/sylius-0-18

dev-feature/sylius-0-18

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

06/06 2016

v0.1.1

0.1.1.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza

06/06 2016

v0.1.0

0.1.0.0

Wishlist bundle for Sylius e-commerce platform.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sylius wishlist web.burza webburza