2017 © Pedro Peláez
 

silverstripe-module silverstripe-shop-downloadable

Downloadable products for Silverstripe Shop module

image

markguinn/silverstripe-shop-downloadable

Downloadable products for Silverstripe Shop module

  • Wednesday, May 18, 2016
  • by markguinn
  • Repository
  • 3 Watchers
  • 1 Stars
  • 187 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Downloadable Products Submodule

For Silverstripe Shop

Allows Products and/or ProductVariations to have files attached that the customer can download once the product has been purchased and remain available on the user's account pages., (*1)

Requirements

  • Silverstripe 3.1+ (may work with 3.0, but hasn't been tested)
  • Shop Module 1.0 or master branch
  • ZipArchive must be enabled in php for full functionality

Features

  • Can be applied to a Product or ProductVariation or both
    • If a variation is purchased, all files from both variation and main product become available for download (can be overridden from the cms).
  • Any number and type of file can be associated with a Product
  • Downloads are available immediately on receipt screen if paying by credit card
  • Downloads are available on the order history
  • All historical downloads are available from a central screen in the account area
  • Can download files individually or any combination in a zip archive
    • We should keep the zip files around for a few days so we don't recreate them all the time
    • Cron job to delete old files
  • Download links should not be guessable
  • Download links should be different for each customer/order for the same file
  • Downloads should be logged
  • Compatible with markguinn/silverstripe-cloudassets module for storing downloads on CDN

Installation

  1. composer require markguinn/silverstripe-shop-downloadable dev-master
  2. Add Downloadable extension to Product and/or ProductVariation or only to certain subclasses.
  3. Run dev/build?flush
  4. Go add some files in the CMS (each product will have a "Files" tab)

YML example:, (*2)

Product:
  extensions:
    - Downloadable
ProductVariation:
  extensions:
    - Downloadable

File Download Process

  1. Once order is paid, files show up on the order screen. Links are generated by the Downloadable extension on the product.
  2. The link a user clicks is something like "http://example.com/downloads/FILE-HASH", which hits the DownloadController.
    • Hash is repeatable given an order ID and file ID (so it will work in emails too)
    • This step could also include a form submission with multiple files.
  3. DownloadController logs the download. If it's only for a single file and the file is small (default 100M, but configurable via yml) it will just output the mime type and use readfile to immediately initiate the download. If there is more than one file or if it's a large file, a temporary "Please wait" page will be displayed while the file is copied and/or zipped if more than one.
    • The temporary file will be cached in such a way that it can be re-used until it is deleted by a cron job.
    • The text of the temporary page can be taken from any page in the CMS via yml config
    • If one wants to disable the "pass through" behaviour entirely it can be easily done by setting the small_file_size to 0.
    • Supports X-Sendfile on servers that have it turned on. In such a case one could probably just set the small_file_size very very high since the file will never be in memory.
  4. If the temporary page is displayed, it will immediately redirect to another URL that will start the copy/zip task
  5. When the copy/zip task is complete it will redirect to the actual url of the temporary file

Configuration (YML options on Downloadable class)

  • tab_name: name of the tab for files in the CMS (default: Downloads)
  • source_folder: where are these files uploaded by default in the cms (default: product-files)
  • zip_folder: location of temporary zip files and large file copies (default: temp-order-files)
  • download_link_base: URL segment for links - e.g. http://example.com/downloads/filekey (default: downloads)
  • small_file_size: anything below this will be passed on directly via readfile or x-sendfile with no temp file created (default: 100M)
  • use_xsendfile: use the X-Sendfile header instead of readfile, must have mod_xsendfile (or equivalent) installed (default: false)
  • crunching_page: url segment/path of a page to display instead of the default while copying/zipping files
  • crunching_zombie_window: how many minutes before crunching is restarted on a zip file (default: 5)
  • delete_temp_files_after: how many hours before the temp files are ok to delete (default: 48)

TODO

  • Tests

Would be nice but I have no intention of doing the work myself anytime soon: - Translatable - Time limit on downloads, (*3)

Developer(s)

Contributions welcome by pull request and/or bug report. Please follow Silverstripe code standards., (*4)

License (MIT)

Copyright (c) 2013 Mark Guinn, (*5)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*6)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*7)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*8)

The Versions

18/05 2016

dev-master

9999999-dev

Downloadable products for Silverstripe Shop module

  Sources   Download

MIT

The Requires

 

silverstripe shop ecommerce downloads downloadable electronic delivery

18/05 2016

1.1.1

1.1.1.0

Downloadable products for Silverstripe Shop module

  Sources   Download

MIT

The Requires

 

silverstripe shop ecommerce downloads downloadable electronic delivery

09/05 2016

1.1.0

1.1.0.0

Downloadable products for Silverstripe Shop module

  Sources   Download

MIT

The Requires

 

silverstripe shop ecommerce downloads downloadable electronic delivery

24/06 2014

1.0.2

1.0.2.0

Downloadable products for Silverstripe Shop module

  Sources   Download

MIT

The Requires

 

silverstripe shop ecommerce downloads downloadable electronic delivery

11/06 2014

1.0.1

1.0.1.0

Downloadable products for Silverstripe Shop module

  Sources   Download

MIT

The Requires

 

silverstripe shop ecommerce downloads downloadable electronic delivery

05/02 2014

1.0.0

1.0.0.0

Downloadable products for Silverstripe Shop module

  Sources   Download

MIT

The Requires

 

silverstripe shop ecommerce downloads downloadable electronic delivery