vinsol / nectarcommerce

Quest for customizable E-commerce - the Elixir way
323 stars 53 forks source link

Add extensions support to nectar. #63

Closed nimish-mehta closed 8 years ago

BenMorganIO commented 7 years ago

Hey guys, I'm looking at your extension manager and thought I'd drop back to this old PR to ask about documentation. I'm trying to figure out how it works, how it was implemented, and how to use it, but I can't find any information.

nimish-mehta commented 7 years ago

@BenMorganIO

We are trying to move away from having extensions compiled into nectar to a more modular approach.

We refactored the code to move and separate the logic into workflows, please have a look at the pr here: https://github.com/vinsol/nectarcommerce/pull/78 which describes the direction we want to take nectar into.

If you just want to add new fields to extend the model. You can do so by writing a module named ExtensionsManager.Extend which has the following structure

defmodule ExtensionsManager.Extend do use ExtensionsManager.ModelExtension

add_to_schema(schema method calls)

include_method do

Methods to add

end end

You can see an example of this here: https://github.com/vinsol/nectarcommerce/blob/extensions-demo/apps/favorite_products/lib/favorite_products/nectar_extension.ex#L23.

For this to work you need to have nectarcommerce and extensions manager app in your umbrella. You can add the extension modules here: https://github.com/vinsol/nectarcommerce/blob/master/apps/extensions_manager/lib/extensions_manager/install_extensions.ex Example: https://github.com/vinsol/nectarcommerce/blob/extensions-demo/apps/extensions_manager/lib/extensions_manager/install_extensions.ex