flamingo.me/flamingo-commerce/v3@v3.11.0/sourcing/Readme.md (about)

     1  # Sourcing Package
     2  
     3  ## What do we mean by sourcing
     4  
     5  Sourcing is about finding the "best" possible location,
     6  where a product or an ordered item should be fulfilled from.
     7  A sourcing logic is therefore also used to allocate your ordered items to the best source locations.
     8  
     9  Different things can play a role while figuring out the correct source location(s):
    10  
    11  - available stock (or replenished stock)
    12  - cost of delivery (e.g. pick warehouses close to delivery location)
    13  - synergies regarding the complete order  
    14    (e.g. source the order from a warehouse where most of the items are available)
    15  - delivery time (if time is more important than cost -
    16    then picking the source location that can deliver the fastest)
    17  ...
    18  
    19  ## Typical Use cases in e-commerce
    20  
    21  For your shop it is helpful to have access to the Sourcing logic for advanced use cases like:
    22  
    23  - On PDP:
    24    - you might restrict the allowed qty based on available source qty (e.g. QtyRestrictor that access Sourcing logic)
    25    - you might want to indicate delivery times based on source locations
    26  
    27  - During Checkout or Place Order you can access the item allocation for:
    28    - make sure that a cart can always be sourced (e.g. as part of your CartValidator)
    29    - you might want to show potential packages and delivery time
    30    - you want to make sure that only carts can be placed that can be Sourced completly
    31    - you might want to attach the source locations for every item to your backend system (e.g. access the Sourcng logic in your PlaceOrder Adapter)
    32  
    33  ## About this package
    34  
    35  Provides Port for Sourcing logic, that can be implemented according to your project needs.
    36  
    37  The main Port is the "SourcingService" interface that you can provide a custom adapter and have all possible freedom to design your sourcing logic.
    38  
    39  ### Configurations
    40  
    41  ```yaml
    42    commerce:
    43      sourcing:
    44        # use the DefaultSourcingService (default: true)
    45        useDefaultSourcingService: true
    46  ```
    47  
    48  ### DefaultSourcingService
    49  
    50  The package also offers a "DefaultSourcingService" that does sourcing based on two inputs:
    51  
    52  1. The theoretical available or possible sourcelocations for a given delivery
    53  2. The available stock for a specific sourcelocations
    54  
    55  For this two inputs the DefaultSourcingService offers also Ports where you can provide individual adapters.
    56  Based on this the DefaultSourcingService fetches the possible sourcelocations and will source items based on the available stock on that locations (starting from the first sourcelocation retrieved).
    57  
    58  ### Fake SourcingService
    59  
    60  Enabled by adding:
    61  ```yaml
    62  commerce:
    63    sourcing:
    64      fake:
    65        enable: true
    66  ```
    67  
    68  When enabled overrides other fake services and user should provide fake data json by
    69  ```yaml
    70  commerce:
    71    sourcing:
    72      fake:
    73        jsonPath: <your_json_path_here>
    74  ```
    75  
    76  JSON structure example:
    77  ```json
    78  {
    79    "deliveryCodes": {
    80      "inflight": 5
    81    },
    82    "products": {
    83      "0f0asdf-0asd0a9sd-askdlj123rw": 10,
    84      "0f0asdf-0asd0a9sd-askdlj123rx": 15
    85    }
    86  }
    87  ```