Download the PHP package setono/sylius-variant-link-plugin without Composer

On this page you can find all versions of the php package setono/sylius-variant-link-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-variant-link-plugin

Sylius Variant Link Plugin

Latest Version Build Status Code Coverage

In a standard Sylius shop it is not possible to link directly to variants. That problem is what this plugin solves.

Screenshots

CLICK TO SEE ![Screenshot showing products list with variants links](docs/images/shop-product-list-with-variant-links.png) ![Screenshot showing product show page with variant selected](docs/images/shop-product-show-variant.png)

Installation

Step 1: Download the plugin

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the plugin

Then, enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php file of your project:

Step 3: Import routing

Step 4: Install assets

Step 5: Override product show template

Start by copying the file vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Product/show.html.twig to templates/bundles/SyliusShopBundle/Product/show.html.twig

Here are two commands that will do just that (only do this if you haven't overridden this template yet):

In the template we need three things:

  1. Include a template
  2. Include a javascript file
  3. Run a javascript function

1. Include variant links template

Add this twig line within the content block: {% include '@SetonoSyliusVariantLinkPlugin/_variantLinks.html.twig' with {'variants': product.variants} %}

2 and 3. Include javascript file and run function

In the javascripts block append this:

See this file for an example of these three changes.

Usage

Link to a variant

See example.

View a product

If you have a product with slug product-1 which has a variant with code variant-code-1 the above twig statement will return /en_US/products/product-1/variant-code-1 on a default Sylius installation.

So try and go to that URL and you will see the respective variant is selected and the price is correct for the respective variant.

Output variant values instead of product values

On the product show page (/en_US/products/slug) the product code is outputted, but let's say you want to output the variants code instead. Then you just do it like this:

If you want to do that multiple places you can of course set the product variant like so:

Easy peasy!

Extending

I want to use something else than variant code for the URL

Let's say you have a store with clothes and you want to use the size of clothes in the URL to determine the variant. You want to end up with URLs like /en_US/products/product-1/medium.

To do this you need to implement two interfaces:

Implementing ProductVariantFromIdentifierResolverInterface

Now define the service:

Implementing ProductVariantUrlGeneratorInterface

Now define the service:

Notice that if you're using autowiring you only need the aliases.


All versions of sylius-variant-link-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
psr/link Version ^1.0
sylius/resource-bundle Version ^1.6
symfony/config Version ^5.4 || ^6.0
symfony/dependency-injection Version ^5.4 || ^6.0
symfony/event-dispatcher Version ^5.4 || ^6.0
symfony/http-foundation Version ^5.4 || ^6.0
symfony/http-kernel Version ^5.4 || ^6.0
symfony/routing Version ^5.4 || ^6.0
symfony/web-link Version ^5.4 || ^6.0
twig/twig Version ^2.0 || ^3.0
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-variant-link-plugin contains the following files

Loading the files please wait ....