"Getting started with Sylius" training sessions now available in various cities in Europe!

Blog

Welcome to our blog, where we share news related to Sylius and post about technology & eCommerce.

Bartosz Pietrzak
23.11.2018 | 2 mins read

A simple way to cancel your orders in Sylius

Hello everyone! Another week means another official Sylius plugin discussed. Although the customer is now able to reorder a previously placed order and to refund it, there’s still plenty of order-related features that need to be covered. Have you ever placed an order, not paid for it yet and decided to resign from buying at all? If so, the next Sylius plugin seems to be a welcome extension to the e-commerce domain. So, without further ado…  here comes the Customer Order Cancellation Plugin!

Introduction

Don’t get me wrong – every unpaid order could and still can be canceled in Sylius. However, it used to require contacting the shop administrator and discussing details via phone or a bunch of e-mails.

The main desire that stood behind Customer Order Cancellation Plugin development was the improvement of shop user’s experience. The action of canceling the order is not always a proper behavior, however. In spite of the plugin being fully customizable, the default configuration forbids canceling once the order has already been either paid or shipped.

What is Customer Order Cancellation Plugin?

Most importantly, Customer Order Cancellation Plugin is an official Sylius extension developed by the Sylius Core Team. Let’s briefly look at its features:

  • Canceling unpaid and unshipped order
  • Being prevented from cancelling paid but unshipped order
  • Being prevented from cancelling shipped but unpaid order
  • Being prevented from cancelling paid and shipped order

How does it work code-wise?

The plugin itself is based on two mechanisms that are well-known among Sylius contributors:

  • Grids
  • State Machine

A grid configured for customer’s representation of the order defines actions that can be taken, such as ‘Pay’ or ‘Show’. The configuration needed to be extended by action ‘Cancel’ represented by the additional button in order’s Actions section. The button is linked to a route delivered by plugin’s code, and the controller’s responsibility is to apply a proper state machine transition to a given order.

How to get it?

Yes, you have guessed it – the plugin is free. You can see the source code on a public GitHub repository or attach it to your Sylius-Standard-based project using Composer. Let me notice that if you are familiar with Symfony Flex, the plugin’s installation requires just one command to make the magic happen. The only thing left for me to do is to wish you…

 

Happy canceling!

 

Bartosz Pietrzak
See my roles

Software developer fond of trying new technologies and challenges. A huge fan of clean code and applying multiple levels of application testing. After hours a keen alternative music listener and a guitarist - that's why you rarely see him without his headphones on. If you want to talk about programming or heavy guitar riffs - you've met a proper person.

Be the first to find out about new posts. Join to our newsletter!