We're Happier Together! NYC Devshop has joined the HappyFunCorp family! Learn more!


Devshop Blog

2 results returned for "ECommerce"

Monday, Nov 28th, 2016

Lizzie Healy

It's The Most Digital Time of the Year

We're making a list of E-Commerce Holiday Do's and Don'ts and checking it twice. Today marks the official online kick off of holiday shopping season with Cyber Monday, the web equivalent of Black Friday. This year more than ever, customers are avoiding the chaos of shopping in store and opting instead to hunt down bargains from the comfort of their couches. This holiday season, digital sales are expected to increase by a whopping 25%, leaving your brand with one crucial question: is your website ready? Tis the season....to prep your e-commerce site for the holidays.

DO: Be on the lookout for 2016 Marv & Harry's
The characters behind holiday hijinks now operate in a new realm: online. Cyber security needs to be a top priority for any website, but most importantly ones dealing with private consumer data like banking and credit card information.

DO: Complete a security audit.
One customer with a bad experience could destroy you with online reviews. Doing a security audit early on in the holiday shopping season ensures all transactions and access points are secured, and can prevent your customers having an experience that sends them running to Yelp.

DO: Reassure nervous shoppers.
Have yourself a merry little purchase. Include a trust seal for customers so that they can feel confident their online purchases are secure.

DO: Embrace the holidays.
The holidays overflowing with eggnog and themes (as if you couldn't tell from this blog post), and the perfect opportunity for marketers to get creative. Top retailers take advantage with specialty landing pages promoting holiday offers and products, and capitalizing on these easy themes.

DO: Include customer reviews.
The little drummer boy wants to purchase new drum sticks, and heads to two websites to compare products. One website has ample reviews, speaking to the quality of the drumsticks and providing a four-star rating. The other has no testimonials and he has no indication of the quality of said drum sticks. Which ones do you think the little drummer boy is going to purchase?

DON'T: Skimp on descriptions.
Do you hear what I hear? Customers might not understand how a product is described, so make sure there are enough pictures and information included included in every product listed. Providing accurate, informative, extensive information about products is crucial to making online sales.

DON'T: Lose customers at checkout.
I'll be home for Christmas and so will your presents. Many companies lose customers on the checkout page because of lengthy shipping times or high costs. Companies can benefit from charging lower costs for shipping or building that cost into the product. Don't pay the price of losing customers because you didn't want to pay the price of shipping.

DON'T: Forget to take into consideration the type of product your buyers are looking at. According to studies done by the Nielsen Group, shoppers looking at thumbnails of bookcases were studied carefully, while thumbnails of flat-panel TV's were pretty much ignored. The use for the product is different. One was studied for the look and feel, while the other was purely studied for function and the usefulness could be conveyed through text.

DON'T: Forget to provide a clear value proposition on your website.
Shoppers visit countless websites when shopping for holiday gifts. The items that stand out are ones that showcase their value! What can this product do for me? I don't want to purchase speakers, I want to be rocking around the Christmas Tree. I don't want wireless noise canceling headphones, I want a silent night. The crucial elements of a good value proposition are: clear, simple language that showcases the promise of value with a product. Shoppers need to understand the features, advantages, and benefits of the item!

Friday, Jul 25th, 2014

Jared Rader

A Shopping Cart For Your Web App

If you're looking to build an e-commerce web application, there is no shortage of tools you can use, from Spree to Shopify. However, it's not too difficult to build your own - which is something we were tasked with over the past week.

In this post, I'll cover creating a shopping cart that will keep track of products and their quantity and allow users to remove items.

Having read Agile Web Development with Rails 4, I decided to use that book's shopping cart implementation. I'd encourage you to go through the book, especially if you're new to Ruby on Rails, but I'll give you an outline of everything required to make a robust shopping cart for your web application.

At least four models are necessary for an e-commerce site: Products, Carts, Orders and Ordered Items (which is a join table between products and orders and products and carts).

Creating and retrieving our cart

Because setting a cart is functionality we'll need to access among different controllers, a great place to put it is inside the concerns folder provided by default in Rails 4. In here, you can create a module where you retrieve the right cart object based on the cart ID stored in the session, or you create the cart if it doesn't yet exist.

module CurrentCart

extend ActiveSupport::Concern
def set_cart
@cart = Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
@cart = Cart.create
session[:cart_id] = @cart.id

The astute reader may look at this and say, wait, what happens when a customer creates a cart but then abandons it? That's a great question, and there are a number of things you could do to handle this scenario. You could create a cron job that checks how old the cart is and determine an expiration date, upon which the job destroys those cart records. On the other hand, you may not want to destroy the carts, especially if you add users later on and associate carts with users. Abandoned carts will help you determine which users aren't checking out, which can be useful information.

Adding products to our cart

A good time to call our `set_cart` method would be at the moment a customer decides to add an item to their cart, or in terms of our web application's functionality, right before creating an Ordered Item record:

class OrderedItemsController < ApplicationController

include CurrentCart
before_action :set_cart, only: [:create, :update, :destroy]

def create
if @cart.save
render partial: 'carts/shopping_bag', locals: { order: @cart }
flash[:error] = 'There was a problem adding this item to your shopping bag.'
redirect :back

To include the current cart functionality, all you need to do is `include CurrentCart` in the controller. Then you can use a `before_action` filter to specify which actions need to retrieve or create a cart.

You probably also noticed the `add_product` method on cart. This is a special method we create on the cart model that allows us to create initial Ordered Items records, as well as keep track of the quantity of the same product. If we simply used `@cart.ordered_items.build`, we'd be creating individual records of the same product each time.

Let's take a look at the `add_product()` method:

class Cart < ActiveRecord::Base

def add_product(product_args)
current_item = ordered_items.find_by(product_id: product_args[:product_id])
if current_item
current_item.quantity += product_args[:quantity].to_i
current_item = ordered_items.build(product_args)

This method differed a bit from the one in Agile Web Development. In our application, users could choose the quantity of items they wanted to add, rather than adding them one at a time. So a quantity parameter was always being passed to the controller action inside of `product_args`.

`add_product()` checks for the existence of the Ordered Item record in the cart. If we have the same product in our cart, it simply updates the quantity and saves the record. Otherwise, we build the relationship and return the item.

Adding and removing products

Like most e-commerce sites, we built a page where customers can look at their cart and update the quantity of items or remove them entirely. This calls for two more actions in our Ordered Items controller: update and destroy:

class OrderedItemsController < ApplicationController

include CurrentOrder
before_action :set_cart, only: [:create, :update, :destroy]
before_action :set_ordered_item, only: [:update, :destroy]

# ...

def update
@ordered_item.update(quantity: params[:quantity]) if @ordered_item
if @ordered_item.save
render json: { itemPrice: @ordered_item.quantity * @ordered_item.product.price, subtotal: @cart.total_price }
flash.now[:error] = 'There was a problem updating your shopping bag.'

def destroy
render json: { order_total: "$%.2f" % @cart.total_price }

def set_ordered_item
@ordered_item = @cart.ordered_items.find_by(id: params[:item_id])

Now we have everything we need to keep track of items in a customer's cart.

In my next post, I'll cover how we handled check out and processing orders with ActiveMerchant and Authorize.net.