Hey Stephan,
The technical question is clear.
However, I am curious what the exact use case is, just to make sure that we solve the right problem. There is existing functionality to add additional products under certain conditions automatically. For example, if the user choses product A, he will always get product B for free. Then only product A has to be passed via the endpoint, and the logic for adding extra products stays in the backend. “M5328 - Novulo Kortingscodes” covers a lot of use cases for special deals, limited offers, vouchers, extra products, etc.
Let me know if you are interested.
However, if you are sure that you want to add multiple items at once, follow the steps below:
This would probably require a new process. For example, in M10452 or in a new custom component. The difficulty lies in the input parameter for passing the new shopping cart items.
One item consists of three properties:
- Sales price list item
- Quantity
- Force new line
You can use a parameter “items” of type string to pass a JSON of all the items to your process. The JSON to pass the items would need to look like this.
{
"items": [
{
"item": {
"spli": "123",
"qty": 2,
"force_new_line": true
},
{
"item": {
"spli": "456",
"qty": 1,
"force_new_line": false
},
...
}
]
}
Then, in your new process, you can convert the JSON into a “list<tuple <String,Mixed>>” with a DeserializeObjectV2 action. You will need the serialization plugin for that.
Then, the tuple list can be processed and the data of the individual items can be extracted with “TupleExtLookup” actions. You will need the tuple extension plugin for that. When all data is extracted, you can use it for the logic of the process that will be similar to “N_WebShoppingcart - No user - Add to WebShoppingcart” in M10452.
Disadvantages: You will hardcode the keys for the values in an “item” object. So “spli”, “qty” etc can only be changed through an application update.
If you have questions on how to use the plugin action, I will probably create a separate and more generic wiki post per plugin.