16 May Spree It is a present extension for Spree Commerce
In today’s blog post I wanted to give you a guide on how to create extensions for Spree Commerce, and to do that, I was going to base it on the extensión that my wife and I have created for Be Bellón, so that our clients can indicate whether they want to send our kits as a present and also add a dedication note to them, but as you can imagine only from reading this simple introduction, the post was getting veeeery long, so in the end, I decided to present you the extension today, and to go directly to the guide on how to create extensions for Spree Commerce in the next week.
What is Spree Commerce?
Spree Commerce is an open source e-commerce platform based on Ruby on Rails.
I think it is very complete, and if you are a Ruby on Rails developer, you can create e-commerce sites very quickly. In fact, it is the engine that Be Bellón is using.
Basically what Spree does is to provide all the functionalities you would typically want to have in an e-commerce platform, and on top of that, it is really easy to extend. First, because it is open-source, which as a developer allows you to contribute to the project, keep it alive, fix bugs or add some improvements to it, which is something I love to do. And second, it can be extended through Spree extensions.
What is an extension for Spree Commerce?
Extensions allow you to add specific functionalities that not every e-commerce store in every country would necessarily need, that is the reason why they are not included in the core. Examples of this can be: invoicing, choose which payment gateways you want to support, add different languages, etc.
Moreover, not only can we consume extensions, but also create our own, offering functionalities that we can share either within our company, or with the community so that everyone using Spree can install and use our extension, as it is our case.
In summary, as you can see, extensions follow Ruby gems’ concept, and in fact, they are gems, as we will see in this post’s last section.
Spree It is a present
Without further ado, let me introduce you the extension Spree It is a present, which is the one I will use as example in my next post, and let me tell you too why we decided to create it.
Very often at Be Bellón our clients buy presents for other people. If you already know Be Bellón, you will know we like to send you your kit to knit natural raffia within a customized box with your name on it. This is easy when the kit is for you, or when the shipping address is the same from the person who is getting the kit, but there are also many clients that prefer to receive the shipment at their home and then give the kit to the person receiving the present themselves.
Spree, by default, neither offers a way within the checkout form to indicate the name of the person who is getting your present nor a text field to enter a dedication note, so, after Maria found herself many times calling or sending out emails to clients to see whether their shipment was supposed to be a present, she asked me to add this to Spree.
The first thing I tried was to see if there was already an extension available, but as you can imagine I did not found any, so at this point the only option we had was to develop the code ourselves. The easiest option would have been to add that code directly to Be Bellón, but at that point we thought about all the extensions made by other people we were benefiting from, and concluded we had to build our own extension and share it for free with the world so that everyone could benefit from it. Also this was a chance to learn something new, which is always awesome. And that way is how the Spree It is a present extension was born.
As you can see in this post’s YouTube video, Spree It is a present adds a field to indicate the receipt’s name for your present and also lets you enter a dedication note within the shipping details checkout form in the store’s front end. Once you have finished your order, the information can be seen in the administration back end within the client’s section. Easy and simple.
How to install Spree It is a present
It is really easy.
If you have a Spree Commerce, store you only need to do the following:
1. Add the extension to your Gemfile with this line:
2. Install the gem with Bundler:
3. Copy and run migrations with this command:
bundle exec rails g spree_it_is_a_present:install
4. Restart your server.
That’s it, enjoy!
We would love to know that you are enjoying using our extension and that you find it useful. Also, as it is open source, in case you find something you think it should fixed or improved… we are looking forward to getting your issues and pull requests!
Next week I will tell you my experience step by step about how to create these wonders and also a few tips that do not come in the oficial guides.. Adiós!