czwartek, 5 czerwca 2014

Drupal Commerce: Kupony rabatowe dla całego zamówienia ( Drupal coupons for the order during checkout process)

Zastanawiałem się jak w miarę szybko w moim sklepie uruchomić kody rabatowe. Przeczytałem, że nie potrzeba instalować żadnych dodatkowych modułów:
Tutorial "Discounts and Coupons"

Niestety w tym tutorialu kod rabatowy jest przypisany do produktu. Ja chciałem mieć rabat na całe zamówienie. Co prawda jest napisane:
Using Drupal Commerce Core, it is very possible to allow users to add coupons via line item (when someone clicks an add to cart link) or via Checkout. To do the checkout method, you can follow the same principles as outlined in our "Simple Coupon" exercise, however you will need to add the field to your Order type via code and expose it on the checkout pane using Commerce Fieldgroup Panes.
 Niestety, o ile dodanie nowego pola do zamówienia jest proste, to skonstruowanie dobrej reguły jest już problematyczne. Mimo różnych prób nie udało mi się uzyskać właściwego działania.

Ponadto bardzo prosty mechanizm kuponów jest rozwiązaniem doraźnym. W dalszej perspektywie dobrze mieć np. możliwość użycia tego samego kodu rabatowego określoną liczbę razy, definiować typy rabatów, w jednym miejscu trzymać ewidencję kodów itp.

W celu rozwiązania mojego problemu zdecydowałem się w końcu na zainstalowanie modułu Commerce Coupon. Jak się potem przekonałem była to dobra decyzja.

Instalują się tak naprawdę dwa moduły: Commerce Coupon i Commerce Coupon UI.
W dokumentacji modułu znalazłem przykład, który okazał się rozwiązaniem mojego problemu (brakowało jeszcze modułu Commerce Coupon Percentage - musiałem go doinstalować):

1) Install modules

   Install:
   - Commerce Coupon
   - Commerce Coupon UI
   - Commerce coupon percentage

2) Create a 'Percentage coupon' coupon

   Go to: Home > Administration > Store > Coupons

   Click 'Create Coupon'

   Choose 'Create Percentage coupon'
   (if you have no other coupon types clicking 'Create Coupon' will redirect to
    the 'Create Percentage coupon' form)

   Create a percentage coupon with the following:

   - Coupon Code: 10%OFF
   - Number of Uses: 1 (change as necessary)
   - Percentage Amount: 10
   - Active: Yes

   Save

3) Enable the 'Coupons' area on one of your Commerce checkout panes

   Go to: Home > Administration > Store > Configuration > Checkout settings

   Move the 'Coupons' item into one of the checkout panes

   Save

4) Test it!





Brak komentarzy:

Prześlij komentarz