-
Notifications
You must be signed in to change notification settings - Fork 53
Add New Shipping Method
Pikender Sharma edited this page Mar 21, 2016
·
2 revisions
When selecting shipping_methods while checkout, there would be a process spinned for each listed shipping_method to calculate applicable shipping_cost.
All the shipping_methods which are applicable & respond with in allowed wait time (timeout) will be consolidated, and would be presented in checkout shipping step.
-
Create a module, preferably with new name of Shipping Method, say
new_shipping_method
and adduse Nectar.ShippingCalculator.Base
for overridable behavior# web/calculators/shipping_calculator/new_shipping_method.ex defmodule Nectar.ShippingCalculator.NewShippingMethod do use Nectar.ShippingCalculator.Base # calculate_shipping/1, applicable?/1 # can also be re-defined def shipping_rate(_order) do # Add your shipping_method cost logic cost = some_complex_logic Decimal.new(cost) end end
-
Register the new_shipping_method in available shipping_calculators
config :nectar, :shipping_calculators, ... new_shipping_method: Nectar.ShippingCalculator.NewShippingMethod, ...
-
Add the new_shipping_method in DB
%{name: "new_shipping_method", enabled: true}
Note: the configuration key should be same as name of added shipping_method in DB or vice-versa.