Solidus Product Attachments

This Solidus extension allows the administrator to upload PDF files to a product or to a variant.

Build Status Gem Version

Installation

Add solidus_product_attachments to your Gemfile:

gem 'solidus_product_attachments'

Bundle your dependencies and run the installation generator:

bundle
bundle exec rails g solidus_product_attachments:install

Usage

Backend

The usage of this extension is made very easy. All you have to do is to include it in your Gemfile and run the installer. After doing this, you can go to a product's page in the admin view and you'll notice a new Documents tab.

Product documents tab

The functionality of the documents upload is very similar to the images upload. You can upload a document per drag and drop or you can choose a file manually.

Frontend

This extension does not come with a frontend implementation of a download option for the users. It's completely up to you to add it, but you can inspire yourself from the following example:

Download option example

And the code (only for the product downloads, without css):

<% if @product.attachments.any? %>
  <div class="product-downloads">
    <h2>I18n.t('spree.product_download_title')</h2>
    <ul class="unstyled">
      <% @product.attachments.each do |attachment| %>
        <li>
          <%= link_to attachment.alt.presence || attachment.attachment_file_name, attachment.attachment.url, target: '_blank' %>
        </li>
      <% end %>
    </ul>
  </div>
<% end %>

Testing

First bundle your dependencies, then run bundle exec rake. This command will default to building the dummy app if it does not exist, then it will run the specs and Rubocop static code analysis. The dummy app can be regenerated by using bundle exec rake test_app.

bundle
bundle exec rake

When testing your application's integration with this extension, you may use its factories. In order to do this, simply add this require statement to your spec_helper:

require 'solidus_product_attachments/factories'

Copyright (c) 2019 Renuo AG, released under the New BSD License.