ecommerce

Open Source Contribution to Spree/Solidus

This was one of the open source contribution in 2015 to a major Rails project used by e-commerce companies.

It usually takes hours/days to understand the basic framework, goals, motivations, features vs limitations etc., to start contributing to an open source project based on the amount of domain knowledge (especially for matured projects).

Its usually hard to find and understand bugs in a very well mature framework or language. One of the good things about using open source libraries is you get to know both the code and get to know the eco system while getting paid on the job.

The Bug

I found a bug in the admin section of Spree. The images when re-ordered are not maintaining their position. I identified this issue while trying to work on a similar feature to order categories.

I made a fix locally to verify it has solved the issue and later fixed it

tl;dr

acts_as_list index starts from 1
Javascript is sending indices starting from 0.

acts_as_list has top_of_list defaulted as 1 - Source: https://github.com/swanandp/acts_as_list/blob/master/lib/acts_as_list/active_record/acts/list.rb#L38

Steps to reproduce the Issue:

1. Go to images under product.
2. Take any element after the 1st one to the top.
3. Edit the one at the top (that was just dragged)
4. Coming back to the index page shows it in the 2nd position.

What is happening in the frontend?

1. Javascript sends the indices starting 0.
2. The update_positions method in resource_controller just sets the positions as they were sent (with more stuff going on)
3. When element in the 0th position is modified. acts_as_list figures 1 is the top of the list and sets the value to 1 along with setting anything which is already in position 1 to 0.

The FIX

This fix will not modify existing positions, but will only fix those resources for new updates.

Other Solutions

Another solution could be to set the configuration for all models which use acts_as_list to top_of_list: 0 which could be an alternative solution which fixes this issue from re-occurring in the first place.

The Code Change

  • Though the code change was in Javascript, it was sending the data to the ruby backend which was using acts_as_list which uses to store the data using ActiveRecord based on indexes.
  • Link to commit on Github


Competition Monitoring

A book costs 11.36 Lakhs. Source: Silence on the Wire | BookAdda.com.

Screenshot:

Something like this happened between two sellers on Amazon.com few years ago. Both of them were thinking about buying the product from the other person and the script increased it thousands of dollars.


The Indian E-commerce - Part 2

There are lots of choices. Ruby on Rails is a famous choice in the US/England for fast development of websites. PHP is the most famous one for Indian startups (I think its mostly because of the number of people). There are many things that lead you to take the programming language for a startup / project lead. 

The ** Cart** on an e-commerce websites is the most important of all along with the **Wishlist**. Amazon.com used to use DynamoDB (not sure if they still do) for saving the shopping cart across millions of users. Simple: If you lose items from the cart, you lose the customer. You cannot show old data. (The paper on DynamoDB published in 2007 was famous because of the architecture it uses. DynamoDB is currently offered as a service as part of AWS).


The Indian E-commerce - Part 1

The current trend in India is e-commerce websites. MySmartPrice (a price comparison site for Indian e-commerce sites) compiled | a list of 343 websites (as of May 2012). There are more than 813 seller listings on Junglee.com. There are so many that are not listed

I found 24 websites(as of April 2013) which do the aggregation of prices from pretty old to the latest Indian e-commerce websites. I found all these through a quick 15 minute search. Well, Junglee is the most famous because its made by Amazon. A base for attracting customers towards amazon.in probably.

From my personal experiences of searching for books and buying in the last 2 months of around 10k spent in total.

Flipkart has a great service, Literally a 2-day delivery to Hyderabad. Though an incorrect pincode might lead it to a different city which you should ensure before clicking on ‘Order’.

SnapDeal spends a great fortune to speed up the site to everyone. Their customer service is a nightmare when you email them. They get back to you only after few days and they prefer to talk to you over phone for things that can be done on email. Adobe and Akamai services for their websites.

Infibeam still offers free shipping for any price and had a headstart on getting up 3rd party sellers.You cannot move an item from the cart to a wishlist.

BookAdda has a lot of books in stock which I needed (OReilly books and Pearson) for a fairly lower price tag and in availability. I had many bad experiences with the website like losing the items in the cart. 

BuyThePrice was shutdown about a month ago.

Shroff Publishers displays the wishlist (w/o truncating it) and items in cart on each and every page. The shipping costs you about 30% more to the value of items in your cart. They use DTDC ( the not-so great courier company which takes 2 days to deliver a package that is < 1km away from the target). You can create a wishlist even though you are not logged in. ( No other site Indian e-commerce does that currently)

The