This is the VersaCommerce App Template build on Bootstrap 3. To get the ball rolling: It uses the VersaCommerce API GEM for accessing the VersaCommerce admin REST web services. It is build with the versacommerce_app generator which provides a module to ensure the API-Session.

Check out the code

Check out the home_controller

The controller in this demo application fetches the newest 5 orders and products and makes them available as instance variables @orders and @products

Take a look at index.html.erb

Index is the Ruby template you are currently viewing. Have a look at the markup and Ruby code to see how the VersaCommerce API is being used. It's located at views/home/index.html.erb

Check out the sessions_controller

The sessions-controller in this demo application makes sure, you are connected to a VersaCommerce Shop. If not, it asks you to register (install) your app with a shop. After authorisation it calls the action sessions#finalize. If you want to store the "registration-token" token for unattended usage, you can place your code right here.

Additional Documentation

<%= link_to 'API documentation', 'https://github.com/versacommerce/vc-api' %>
Learn what you can do with the VersaCommerce API

<%= link_to 'Bootstrap documentation', 'http://twitter.github.com/bootstrap/' %>
Find out what you can do with Twitter Bootstrap

About this Shop

Name

<%= current_shop.shop.name %>

URL

<%= current_shop.shop.url %>

Price includes tax

<%= current_shop.shop.price_includes_tax%>

Currency

<%= current_shop.shop.currency_code%>

Recent Orders

<% if @orders.blank? %>
There are no orders in your shop.
<% else %> <% @orders.each do |order| %> <% end %>
Order Customer Status Total
<%= link_to order.code, "https://#{current_shop.url}/admin/orders/#{order.id}", :target => 'blank' %> <%= "#{order.billing_address.firstname} #{order.billing_address.lastname}" %> <%= order.status %> <%= order.total %> <%= order.currency %>
<% end %>

New Products

<% if @products.blank? %>
There are no products in your shop.
<% else %>
<% @products.each_with_index do |product, index| %>

<%= product.title %> <%= product.price %> <%= current_shop.shop.currency_code %>

<%= image_tag( product.featured_image.medium, class: "pull-right" ) unless product.featured_image_url.blank? %>

SKU: <%= product.code %>

Category: <%= product.category %>

Vendor: <%= product.vendor %>

<%= raw(product.description_html) %>

Created at <%= product.created_on.strftime("%Y-%m-%d") %>


<%= link_to "Open this product in /admin", "http://#{current_shop.url}/admin/catalog/products/#{product.id}/edit", :target => 'blank', class: "btn btn-default" %>
<% end %>
<% end %>