Spree-spl is a plugin that provides a promotion switcher for Spree, enabling enhanced loyalty program functionality.
Add spree-spl to your Gemfile and run bundle install:
gem 'spree-spl'After installation, add the following line to Spree::Adjustable::AdjustmentsUpdaterDecorator#persist_totals:
apply_spl_adjustments(attributes, totals)Add the following lines to Spree::OrderUpdaterDecorator#update_adjustment_total:
skip_recalculation = check_spl_adjustments
return if skip_recalculationAdditionally, Add the following lines to view spree/checkout/_line_item.html.erb
<% if spl_adjustment(line_item) %>
<div class="flex justify-between">
<span class="text-red-500">
<%= spl_adjustment(line_item)&.label %>
</span>
<span class="text-red-500">
<%= "#{spl_adjustment(line_item)&.amount} zł" %>
</span>
</div>
<% end %>To run tests type in terminal:
bundle update
bundle exec rake test_app
bundle exec rspec