sourcing

package
v3.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 7 Imported by: 0

README

Sourcing Package

What do we mean by sourcing?

Sourcing is about finding the "best" possible location from which a product or an ordered item should be fulfilled. Sourcing logic is therefore also used to allocate ordered items to the best source locations.

Different factors can play a role when determining the correct source location(s):

  • available stock (or replenished stock)
  • cost of delivery (e.g. picking warehouses close to the delivery location)
  • synergies regarding the complete order
    (e.g. sourcing the order from a warehouse where most of the items are available)
  • delivery time (if time is more important than cost, pick the source location that can deliver the fastest)
  • ...

Typical use cases in e-commerce

For your shop, it is helpful to have access to the sourcing logic for advanced use cases such as:

  • On PDP:

    • you might restrict the allowed qty based on the available source qty (e.g. a QtyRestrictor that accesses the sourcing logic)
    • you might want to indicate delivery times based on source locations
  • During checkout or place order you can access the item allocation to:

    • make sure that a cart can always be sourced (e.g. as part of your CartValidator)
    • show potential packages and delivery times
    • make sure that only carts which can be sourced completely are allowed to be placed
    • attach the source locations for every item to your backend system (e.g. by accessing the sourcing logic in your PlaceOrder adapter)

About this package

Provides a port for sourcing logic that can be implemented according to your project's needs.

The main port is the SourcingService interface, for which you can provide a custom adapter, giving you full freedom to design your sourcing logic.

Configurations
  commerce:
    sourcing:
      # use the DefaultSourcingService (default: true)
      useDefaultSourcingService: true
DefaultSourcingService

The package also offers a DefaultSourcingService that performs sourcing based on two inputs:

  1. The theoretically available or possible source locations for a given delivery
  2. The available stock for specific source locations

For these two inputs, the DefaultSourcingService also offers ports where you can provide individual adapters. Based on this, the DefaultSourcingService fetches the possible source locations and sources items based on the available stock at those locations (starting from the first source location retrieved).

Fake SourcingService

Enabled by adding:

commerce:
  sourcing:
    fake:
      enable: true

When enabled, it overrides other fake services, and the user has to provide a fake data JSON file via:

commerce:
  sourcing:
    fake:
      jsonPath: <your_json_path_here>

JSON structure example:

{
  "deliveryCodes": {
    "inflight": 5
  },
  "products": {
    "0f0asdf-0asd0a9sd-askdlj123rw": 10,
    "0f0asdf-0asd0a9sd-askdlj123rx": 15
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module registers the sourcing module

func (*Module) Configure

func (m *Module) Configure(injector *dingo.Injector)

Configure module

func (*Module) CueConfig

func (m *Module) CueConfig() string

CueConfig defines the sourcing module configuration

func (*Module) Depends

func (m *Module) Depends() []dingo.Module

Depends declares the modules this module depends on.

func (*Module) Inject

func (m *Module) Inject(
	config *struct {
		UseDefaultSourcingService bool `inject:"config:commerce.sourcing.useDefaultSourcingService,optional"`
		EnableQtyRestrictor       bool `inject:"config:commerce.sourcing.enableQtyRestrictor,optional"`
		UseFakeService            bool `inject:"config:commerce.sourcing.fake.enable, optional"`
	},
)

Inject dependencies

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL