You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the system can do only discounts. I would like us to get to a place where we can also add a line item to an order.
I envision it like this:
In every lane, before we run discounts, we run "automations", Promotion Actions that perform an action other than discounting (using a method that is different from discount, like perform, maybe?). perform should either add or remove a line item, depending on the promotion's availability for the promotion. For this to work, line items must be connected to promotion actions through a new promotion_action_id attribute on the line item.
An example spec could be something along the lines of:
context"A promotion that creates line items",:pendingdolet(:shirt){create(:product,name: "Shirt")}let(:pants){create(:product,name: "Pants")}let(:promotion){create(:friendly_promotion,name: "Free shirt with pants",apply_automatically: true)}let(:rule){SolidusFriendlyPromotions::Rules::Product.new(products: [shirt],preferred_line_item_applicable: false)}let(:action){SolidusFriendlyPromotions::Actions::FreeItem.new(preferred_variant_id: shirt.id)}let(:order){create(:order)}beforedopromotion.rules << rulepromotion.actions << actionorder.contents.add(pants.master,1)endit"creates one line item level adjustment"doexpect(order.adjustments).tobe_emptyexpect(order.total).toeq(19.99)expect(order.item_total).toeq(39.98)expect(order.item_total_before_tax).toeq(19.99)expect(order.line_items.flat_map(&:adjustments).length).toeq(1)expect(order.line_items.length).toeq(2)order.contents.remove(pants.master,1)# Because the pants are gone, the promo does not apply anymore, and our free shirt goes as well.expect(order.line_items).tobe_emptyendend
The text was updated successfully, but these errors were encountered:
mamhoff
changed the title
Implement automations / Free item
Implement automations / Free items
Oct 13, 2023
mamhoff
changed the title
Implement automations / Free items
Implement Free items
Oct 13, 2023
Done in #75
That PR solves 1 (admins select a variant), 2 (no they don't) and 3 (they get removed when the order becomes ineligible for the promotion, regardless of by time, promotion rule, or promotion deletion).
Currently, the system can do only discounts. I would like us to get to a place where we can also add a line item to an order.
I envision it like this:
In every lane, before we run discounts, we run "automations", Promotion Actions that perform an action other than discounting (using a method that is different from
discount
, likeperform
, maybe?).perform
should either add or remove a line item, depending on the promotion's availability for the promotion. For this to work, line items must be connected to promotion actions through a new promotion_action_id attribute on the line item.An example spec could be something along the lines of:
The text was updated successfully, but these errors were encountered: