Ruby class that calculates and applies promotional discounts to order line items. Use when extending Solidus e-commerce promotion logic.
# Source: https://github.com/solidusio/solidus | License: BSD-3-Clause | Copyright 2007-2014, Spree Commerce Inc. and other contributors
# Provided via justclaw.it.com; keep this notice with the code.
# frozen_string_literal: true
module SolidusPromotions
class ProductAdvertiser
attr_reader :order, :product, :promotions, :quantity
def initialize(product:, order:, quantity: 1)
@product = product
@order = order
@quantity = quantity
@promotions = SolidusPromotions::LoadPromotions.new(order:).call
end
def call
return unless product.promotionable?
SolidusPromotions::Promotion.ordered_lanes.each do |lane|
SolidusPromotions::PromotionLane.set(current_lane: lane) do
lane_promotions = promotions.select { |promotion| promoti
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key