https://github.com/madetech/order_reporting
https://github.com/madetech/order_reporting
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/madetech/order_reporting
- Owner: madetech
- License: bsd-3-clause
- Created: 2016-07-05T14:07:11.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-09T10:12:58.000Z (almost 10 years ago)
- Last Synced: 2024-04-24T23:22:08.450Z (about 2 years ago)
- Language: Ruby
- Size: 57.6 KB
- Stars: 1
- Watchers: 49
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Order Reporting for Spree and Solidus
[](https://travis-ci.org/madetech/order_reporting)
Automatically sends lists of orders via email based on criteria.
## Installing in Spree app
Add this to your Gemfile:
```
gem 'spree_order_reporting'
```
## Installing in Solidus app
Add this to your Gemfile:
```
gem 'solidus_order_reporting'
```
## Setup
Three steps to configure:
1. Create mailer and template
2. Create query object for selecting orders
3. Setup gem with initializer
### 1. Create mailer and template
```ruby
class OrderReportMailer < ActionMailer::Base
def exported_orders(orders)
@orders = orders
mail(to: 'cs@shop.com', subject: 'Exported Orders')
end
end
```
### 2. Create query object for selecting orders
```ruby
class ExportedOrdersQuery
def orders
Spree::Order.exported.where('completed_at > ?', 24.hours.ago)
end
end
```
### 3. Setup gem with initializer
Create an application initializer in `config/initializers/order_reporting.rb`:
``` ruby
OrderReporting.mailer_class = OrderReportMailer
OrderReporting.scheduler = OrderReporting::DelayedJobScheduler.new
OrderReporting.define_report :exported_orders do |config|
config.send_every = 24.hours
config.query = ExportedOrdersQuery.new
end
```
## Development
Run spree tests:
```
rm -rf spec/dummy/
BUNDLE_GEMFILE=Gemfile.spree.rb bundle
BUNDLE_GEMFILE=Gemfile.spree.rb bundle exec rake
```
Run solidus tests:
```
rm -rf spec/dummy/
BUNDLE_GEMFILE=Gemfile.solidus.rb bundle
BUNDLE_GEMFILE=Gemfile.solidus.rb bundle exec rake
```
## Publishing
Before publishing you will need to have created a new release. To do so update `lib/order_reporting/version.rb` to new version number and commit this change as "New release vx.x.x". Then tag this commit with ```git tag vx.x.x``` and push it `git push origin vx.x.x`. Then you need to publish to RubyGems...
Publish Spree gem:
```
gem build spree_order_reporting.gemspec
gem push spree_order_reporting-x.x.x.gem
```
Publish Solidus gem:
```
gem build solidus_order_reporting.gemspec
gem push solidus_order_reporting-x.x.x.gem
```