Spree Admin Dashboard allows you easily extend existing pages and screens with your own code, without any need to modify the core codebase. This allows you to easily inject your custom UI elements without compromising the integrity of the core codebase. Which in effect allows you to safely update your Spree installation to the latest version.

How it works

The entire system works on the basis of injection points which are declared throughout the admin dashboard and allows you to push your own code there. Each injection point is identified by a key, eg. body_end_partials.

Let’s say you want to add a new footer to the admin dashboard. You’ll need to generate a template in your application:

  1. Ensure you have the proper directory to store your templates:

    mkdir -p app/views/spree/admin/shared
    
  2. Create a new partial template file (partial templates file names start with underscore)

    touch app/views/spree/admin/shared/_additional_footer.html.erb
    
  3. Add your own code to the partial

    <div class="mx-auto bg-light p-3 rounded-lg text-center w-10">
      Copyright <%= current_store.name %> <%= Time.current.year %>
    </div>
    
  4. Register your partial in config/initializers/spree.rb

    Rails.application.config.spree_admin.body_end_partials << 'spree/admin/shared/additional_footer'
    

    The key is the name of the injection point, eg. body_end_partials.

    Remember to use the correct path to your partial and skip the _ prefix.

  5. Restart your web server and you should see your new footer.

    Making further changes to the partial template will not require you to restart the web server. They will be picked up automatically.

Admin Dashboard injection points

Here’s a list of all places you can inject your custom code:

Layout

Dashboard

Orders

Products

Shipping Methods

Store Settings