0

I have created a custom promotion action in Spree. (Technically we are using Solidus )

In this promotion action, I have defined my own custom view ( in app/view/spree/admin/promotions/actions/_my_custom_action.html.erb )

I have a select menu and a few number fields that contain variables that need to be passed to a calculator and / or the promotion action class itself as part of the calculation.

How do I incorporate variables from this view into my discounts / promotions ?

I read this article: https://blog.planetargon.com/entries/creating-custom-actions-in-spree-commerce and it appears that there are some pre -made view components there that tie into calculators. However, when I try to implement that view , I get errors suggesting ( I think ) that my promotion action is not associated with any calculators, even though I've included Spree::CalculatedAdjustments in my promotion action.

I'm COMPLETELY fine with using pre-built form elements to capture my user defined variables in admin. I'm just stuck figuring out how all of this connects together and the documentation is scarce / non-existent..

Nmuta
  • 345
  • 4
  • 15

1 Answers1

0

So, I got this working .... the view variables come from the calculator itself, and the way they're defined makes sense but may not be readily apparent.

In the calculator you'll see something like:

enter image description here

here the variable "amount" is actually then translated into preferred_amount and the variable "thing" is translated into preferred_thing in the engine. That's the key to understanding how the calculator ties into the view.

Nmuta
  • 345
  • 4
  • 15