Spree intergration for Mirakl API. Currently only processes orders and brings them into the system and allows you to ship. Each Mirakl Store Requires a user to be assigned to it. All orders from that store will be placed under that user.
- Add this extension to your Gemfile with this line:
gem 'spree_mirakl_api', github: 'https://github.com/ShopFelixGray/spree_mirakl_api', branch: 'master'
The branch
option is important: it must match the version of Spree you're using.
For example, use 3-1-stable
if you're using Spree 3-1-stable
or any 3.1.x
version.
- Install the gem using Bundler:
bundle install
- Copy & run migrations
bundle exec rails g spree_mirakl_api:install
- Restart your server
If your server was running, restart it so that it can find the assets properly.
- Setup up Mirakl Payment Method
The gem uses a payment method that must be called Mirakl to process payments. After installing the gem please make a payment method of type Mirakl called Mirakl
Shipping Mapper Currently cause we assume shipping is free refunds dont give shipping back We also need to update the return reasons UI to make it more spree like adjustment calculator
To pull in the orders a cron job is required. There is 3 different services that should be run separately of each other.
- Mirakl::OrderProcessing.new(stores: Spree::MiraklStore.active)
This service gets all orders waiting acceptance and checks if they can be fully accepted. If one line item cant be meet the whole order is rejected. It also takes any orders ready to be shipped and builds the order in the spree store. An example worker for this would be
service = Mirakl::OrderProcessing.new(stores: Spree::MiraklStore.active)
unless service.call
logger.debug service.errors
Rollbar.error(Exception.new(service.errors.to_s))
end
end
Service.errors will return an array of errors and call will return false if there is any errors
- Mirakl::UpdateInventory.new({store: store})
This service syncs a single stores inventory. It takes a single store because it is reused on index. It will use the spree call total_on_hand for a given sku to update Mirakls offerings. An example for a worker would be
Spree::MiraklStore.active.each do |store|
service = Mirakl::UpdateInventory.new({store: store})
unless service.call
raise Exception.new("Issue with updating inventory for store: #{store.shop_id}")
end
end
end
First bundle your dependencies, then run rake
. rake
will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app
.
bundle
bundle exec rake
When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:
require 'spree_mirakl_api/factories'
If you'd like to contribute, please take a look at the instructions for installing dependencies and crafting a good pull request.
Copyright (c) 2020 Mike Walters, released under the New BSD License