Giter VIP home page Giter VIP logo

syliustermsplugin's Introduction

Sylius terms and conditions plugin

Latest Version Software License Build Status Code Coverage

Will add a checkbox to the selects form(s) where the customer has to accept the terms and conditions before continuing.

This can be used to make sure the customer has accepted the terms and conditions before placing an order.

Screenshots

Shop

Before the customer can place order, he/she has to check the required terms

Screenshot showing shop checkout complete page

Admin

Here is a list of terms. Notice the terms_and_conditions which is associated with multiple channels.

Screenshot showing admin terms index page

Notice that you select the form where the terms are shown. As default only the Checkout > Complete form is available, but you can add more in the setono_sylius_terms.forms configuration option.

Screenshot showing admin terms update page

The Label field is the text shown on the complete order page. Notice you can use a placeholder ([link:Link text]) to tell where the link should be.

Screenshot showing admin terms translation update page

Installation

Step 1: Download the plugin

composer require setono/sylius-terms-plugin

Step 2: Enable the plugin

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

<?php
# config/bundles.php
return [
    // ...
    
    Setono\SyliusTermsPlugin\SetonoSyliusTermsPlugin::class => ['all' => true],
    
    // It is important to add plugin before the grid bundle
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    
    // ...
];

NOTE that you must instantiate the plugin before the grid bundle, else you will see an exception like You have requested a non-existent parameter "setono_sylius_terms.model.terms.class".

Step 3: Import routing

# config/routes/setono_sylius_terms.yaml

setono_sylius_terms:
    resource: "@SetonoSyliusTermsPlugin/Resources/config/routes.yaml"

There's also a version for non-localized stores: @SetonoSyliusTermsPlugin/Resources/config/routes_no_locale.yaml

Step 4: Update your database schema

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

Step 5: Override checkout complete form

Override the Sylius Form:

  • If you haven't your own templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig yet:

    $ cp vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Complete/_form.html.twig \
    templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig
  • If you already have it:

    Add terms field (exactly this conditional way):

    {# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #}
    {% if form.terms is defined %}
        {{ form_row(form.terms) }}
    {% endif %}

    So the final template will look like this:

    {# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #}
    {{ form_row(form.notes, {'attr': {'rows': 3}}) }}
    {% if form.terms is defined %}
        {{ form_row(form.terms) }}
    {% endif %}

Troubleshooting

  • If you see Neither the property "terms" nor one of the methods "terms()", "getterms()"/"isterms()"/"hasterms()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".

    Then see #13 and double-check you added terms field at template like described at Override checkout complete form section.

  • If you see Grid "setono_sylius_terms_terms" does not exists

    Then you forgot to import config from Step 3: Import config section.

syliustermsplugin's People

Contributors

4c0n avatar dsbe-ak avatar igormukhingmailcom avatar jacquesbh avatar loevgaard avatar nedac-sorbo avatar reyostallenberg avatar techbech avatar zales0123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

syliustermsplugin's Issues

Order fails, if channel does not use en_US

Hi,

The checkout process fails with an error message,

HTTP 404 Not Found
The "en_US" locale is unavailable in this channel.

if the channel is only configured for a single locale, that is not en_US (e.g. only de_DE has been configured)

As a workaround, adding "en_US" as secondary locale fixes this, but this is not always desired!

Add better URLs

When the root of the routes are /terms it looks stupid on non english websites. In Danish the word for conditions is betingelser so an URL would look like /terms/betingelser which in my opinion is a bit 'newbish'...

Order completion form rendering failing if no one Term configured for current Channel

Error:

Neither the property "terms" nor one of the methods "terms()", "getterms()"/"isterms()"/"hasterms()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".

Solution: Check for field at template

{# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #}
{{ form_row(form.notes, {'attr': {'rows': 3}}) }}

{% if form.terms is defined %}
    {% form_theme form.terms '@SetonoSyliusTermsPlugin/Shop/Form/termsTheme.html.twig' %}
    {{ form_row(form.terms) }}
{% endif %}

Blocking order completion in backend

Currently it seems that order completion is only blocked on a UI/Form level. More specifically the form cannot be submitted without accepting the terms.

It seems that tech savvy users could circumvent that measure by submitting the request directly (without using the UI) without truly accepting the terms.

In my opinion it would be great to add a feature that blocks the state machine transition if the terms are not (all) accepted. That can be done by adding a callback to the state machine, for example.

Version 1.0.7 is not installed for sylius 1.10

After executing
composer create-project sylius/sylius-standard acme

And then
composer require setono/sylius-terms-plugin

only version 1.0.6 is installed (because of dependencies?).

The admin template "SyliusAdminBundle:Crud" is then not found.

How can I install 1.0.7 for sylius 1.10?
Thanks!

Allow terms and conditions to be used in other forms as well

Some terms and conditions apply to the checkout process (terms and conditions of the website). Others might not be mandatory during checkout, but during register (privacy policy).

Others are just informatory and they do not require a check to be implemented in any form, but only the url being available somewhere (eg. cookie policy or return merchandise policy).

TL;DR:

  • hook this plugin into the registration process as well, to allow privacy policy to be checked mandatory during checkout as well
  • allow some terms and conditions to be excluded from any form, but available under their own url

wording typo

The german wording for setono_sylius_terms.form.terms_accept.terms_should_be_accepted (src/Resources/translations/messages.de.yaml) is "{{ name }} muss akzeptiert warden" but should be "{{ name }} muss akzeptiert werden"

Problem with translations

Currently when I try to make a terms and I don't fill out translation only for en_US translation, and both with the related US channel disabled and enabled, I get the following error.
image

Solution

We need some correct validation errors and also I don't think that it should force translations for locales that doesn't belong to one of the enabled channels.

Terms versioning

Hello @loevgaard, this plugin is a good idea because we often use CMS for this kind of pages. But I think it could be even better :)

Like cookies consent with GPDR, we should store the agreement between the customer and the company.

Terms and condition is similar to a contract signed between a customer and the company that run the website. A customer can complain on an order based on the previous year terms for example and as a company when a customer complain we should be sure what was the version of the terms he signed.

To improve the plugin I suggest to :

  • Add some versioning (disable editing on terms and only allow admin to create new versions) (maybe create a TermRevision Entity)
  • Store in each order the version of the term the user has "signed".
  • We may use a hash of the term content (md5 or other) on the TermRevision entity and store this hash in the order. The hash should ensure the term has not been modified.

NB : There are online services that warn their users when terms are changing, with this model this would be something doable if a sylius shop want to warn its customers when terms change...

Thank you for your work :)

partial url

Hi,

When i click on the terms link on the checkout complete page, i got the following error :
The controller for URI "/terms/my-slug/partial" is not callable: Controller "setono_sylius_terms.controller.terms:showAction" does neither exist as service nor as class.

I use symfony 6.3

EDIT: found the issue, the controller is called with :showAction and it needs ::showAction

Custom click strategy

Rework click strategies so we can add custom ones; remove ClickStrategy as it have fixed list of strategies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.