Author:
Fluent Commerce
Changed on:
19 Jan 2024
To allow article barcode scanning in Service Point, a barcode needs to be added to the corresponding Article entity. This article describes how this can be achieved.
If a barcode is entered in the “Scan or enter barcode” field in Service Point the articles which have the corresponding barcode set are retrieved and displayed as follows:
Service Point performs the following legacy REST API call to search for articles with the corresponding barcode:
1{{fluentApiHost}}/api/v4.1/article?retailerId={{retailer_id}}&query={{article_barcode}}&status=COURIER_COLLECTION&status=CUSTOMER_COLLECTION&fulfilmentStatus=FULFILLED&fulfilmentStatus=PARTIALLY_FULFILLED&type=CFS&type=CC_PFDC&type=CC_PFS&count=10&direction=INBOUND
Language: java
Name: Service Point
Description:
[Warning: empty required content area]To add a barcode to an article the "addBarcode" action needs to be triggered as shown in the following example:
1context.action().addBarcode(articleEntity, ``"ARTICLE_BARCODE"``, ``"123"``);
Language: java
Name: Add a barcode to an article
Description:
[Warning: empty required content area]NOTE:
1 {{fluentApiHost}}/api/v4.``1``/article/{{articleId}}/barcode
Language: java
Name: Barcode API
Description:
[Warning: empty required content area]1{
2 ``"barcode"``:``"123"``, ``//scannable barcode
3 ``"barcodeType"``:``"ARTICLE_BARCODE"` `//a type. e.g. REWARDS_CARD, ARTICLE_BARCODE, ...
4}
Language: java
Name: Payload
Description:
[Warning: empty required content area]Rule AddArticleBarcodeFromOrderAttributes:
1package` `com.fluentretail.rubix.foundation.rule;
2import` `com.fluentretail.api.model.BarcodeReferencableEntity;
3import` `com.fluentretail.api.model.article.Article;
4import` `com.fluentretail.api.model.attribute.Attribute;
5import` `com.fluentretail.rubix.context.Context;
6import` `com.fluentretail.rubix.rule.Rule;
7import` `com.fluentretail.rubix.rule.meta.ParamString;
8import` `com.fluentretail.rubix.rule.meta.RuleInfo;
9import` `com.fluentretail.rubix.util.RuleUtils;
10import` `lombok.extern.slf4j.Slf4j;
11import` `java.util.List;
12import` `static` `com.fluentretail.rubix.util.RuleUtils.validateSupportedType;
13/**
14 ``*
15 ``*/
16@RuleInfo``(
17 ``name = ``"AddArticleBarcodeFromOrderAttributes"``,
18 ``description = ``"Add Article Barcode from the Order Attributes <attributeNames> "``,
19 ``produces = {}
20)
21@ParamString``(
22 ``name = AddArticleBarcodeFromOrderAttributes.PROP_ATTRIBUTE_NAMES,
23 ``description = ``"Name of the attributes to create Barcode from"
24)
25@Slf4j
26public` `class` `AddArticleBarcodeFromOrderAttributes ``implements` `Rule {
27
28 ``public` `static` `final` `String PROP_ATTRIBUTE_NAMES = ``"attributeNames"``;
29
30 ``@Override
31 ``public` `void` `run(Context context) {
32 ``RuleUtils.validateRuleProps(context, PROP_ATTRIBUTE_NAMES);
33 ``BarcodeReferencableEntity entity = validateSupportedType(context.getEntity(), BarcodeReferencableEntity.``class``);
34 ``List<String> attributeNames = context.getPropList(PROP_ATTRIBUTE_NAMES, String.``class``);
35
36 ``Article articleResponse = context.api().getArticle(entity.getId());
37 ``String orderId = articleResponse.getOrderId();
38 ``Attribute.List entityAttributesResponse = context.api().getOrderAttributes(orderId);
39 ``entityAttributesResponse.getAttributes().forEach(attribute -> attributeNames.forEach(attributeName -> {
40 ``if` `(attributeName.equals(attribute.getName())) {
41 ``context.action().addBarcode(entity, attribute.getName(), (String) attribute.getValue());
42 ``}
43 ``}));
44 ``}
45}
Language: java
Name: Example
Description:
[Warning: empty required content area]1{
2 "name": "FLUENTRETAIL.base.AddArticleBarcodeFromOrderAttributes",
3 "props": {
4 "attributeNames": ["barcode"]
5 }
6}
Language: json
Name: Sample Workflow Snippet
Description:
[Warning: empty required content area]1mutation CreateOrder ($retailerId:ID!,
2$productCatalogueRef:String!,
3$productRef:String!,
4$customerId:ID!,
5$ccLocRef:String!) {
6 createOrder(input: {
7 ref: "CC_{{$randomInt}}"
8 retailer: { id:$retailerId }
9 type: "CC"
10 customer: { id:$customerId }
11 totalPrice:80.00
12 attributes:{
13 name:"barcode"
14 value: "B1234"
15 type: "STRING"
16 }
17 items: [{
18 ref: $productRef
19 productRef: $productRef
20 productCatalogueRef:$productCatalogueRef
21 price: 80.00
22 paidPrice:80.00
23 totalPrice:80.00
24 taxPrice:8.00
25 totalTaxPrice: 8.00
26 quantity:1
27 currency:"AUD"
28 }],
29 fulfilmentChoice: {
30 currency: "AUD"
31 deliveryType: "STANDARD"
32 fulfilmentPrice:5.00
33 fulfilmentTaxPrice:0.99
34 fulfilmentType: "CC_PFS"
35 pickupLocationRef: $ccLocRef
36 }
37 }) {
38 id
39 }
40}
Language: graphqlschema
Name: Sample Order Mutation
Description:
[Warning: empty required content area]NOTE: Since the rule expects a String as the order attribute and attribute values starting with a number are interpreted to ensure that the order attribute barcode value starts with a character.
Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.