config/initializers/spree.rb
file, you can set the following:
Spree::Cart::AddItem
call
method to add your custom logicrun :add_to_line_item
to add the item to the cartrun Spree::Dependencies.cart_recalculate_service.constantize
to recalculate the cartrun :update_in_external_system
to execute your custom logic, eg. updating Order in an external system such as ERP'MyNewAwesomeAddItemToCart'
MyNewAwesomeCartSerializer
and also it will swap the default add_item_service
to MyNewAwesomeAddItemToCart
.
Different API endpoints can have different dependency injection points. You can review their source code to see what you can replace.
config/initializers/spree.rb
) please add:
AnotherAddItemToCart
and the rest of the application will use MyNewAwesomeAddItemToCart