-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f17c557
commit fa71ad1
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
app/controllers/spree/api/v2/operator/recalculate_ticket_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Operator | ||
class RecalculateTicketController < ::Spree::Api::V2::ResourceController | ||
before_action :require_spree_current_user, only: :create | ||
before_action :load_taxon, only: :create | ||
|
||
def create | ||
@taxons.each do |taxon| | ||
taxon.products.each do |product| | ||
product.classification_ids.each do |classification_id| | ||
SpreeCmCommissioner::ConversionPreCalculator.call(product_taxon: Spree::Classification.find(classification_id)) | ||
end | ||
end | ||
end | ||
|
||
render json: { message: 'Conversions recalculated successfully' }, status: :ok | ||
end | ||
|
||
private | ||
|
||
def load_taxon | ||
parent_taxon = Spree::Taxon.find(params[:taxon_id]) | ||
@taxons = parent_taxon.children | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters