{"id":32010,"date":"2025-07-22T15:07:15","date_gmt":"2025-07-22T15:07:15","guid":{"rendered":"https:\/\/kb.sambapos.com\/?p=32010"},"modified":"2025-07-22T15:10:03","modified_gmt":"2025-07-22T15:10:03","slug":"4-100-how-to-add-new-product-by-scanning-unknown-barcode","status":"publish","type":"post","link":"https:\/\/kb.sambapos.com\/en\/4-100-how-to-add-new-product-by-scanning-unknown-barcode\/","title":{"rendered":"4.100. How to Add New Product By Scanning Unknown Barcode"},"content":{"rendered":"<p>In this document it will be explained how to add new product by scanning an unknown barcode.<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>1. Addin<\/strong><strong>g Script<\/strong><\/h3>\n<p><strong>Main Menu &gt; Manage &gt; Automation &gt; Scripts &gt; <\/strong>Here, click on <strong>Add Script.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-32019 size-large\" src=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-05-1024x550.jpg\" alt=\"\" width=\"640\" height=\"344\" srcset=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-05-1024x550.jpg 1024w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-05-300x161.jpg 300w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-05-768x413.jpg 768w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-05-1536x826.jpg 1536w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-05.jpg 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Name:<\/strong> Add Product By Barcode<\/p>\n<p><strong>Handler:<\/strong> addproductbybarcode<\/p>\n<p>In here copy\/paste the below script into the Script field;<\/p>\n<p><code>function addProduct(name, portion, category, price, barcode)<br \/>\n{<br \/>\nvar response = gql.Exec('mutation m {addProduct(name: \"'+name+'\", groupCode: \"'+category+'\",barcode:\"'+barcode+'\", portions: [{name: \"'+portion+'\", price: \"'+price+'\"}]) { id name groupCode }}');<br \/>\nvar result = JSON.parse(response);<br \/>\nif (!result || !result.data || !result.data.addProduct) return \":x: Fout: Product kon niet worden toegevoegd via GraphQL.\";<br \/>\nvar ProductID = result.data.addProduct.id;<br \/>\ngql.Exec('mutation m{postResetProductCacheMessage {id}}');<br \/>\nvar portionID = JSON.parse(gql.Exec('{getProduct(id:'+ProductID+'){portions{id}, tags{name,value} }}')).data.getProduct.portions[0].id;<br \/>\nsql.ExecSql(\"UPDATE MenuItemPrices SET Price = '\"+price+\"' WHERE MenuItemPortionId = \"+portionID+\"\")<\/code><\/p>\n<p><code>gql.Exec('mutation m{postResetProductCacheMessage {id}}');<\/code><\/p>\n<p><code>return \":white_check_mark: Product '\"+name+\"' met portie '\"+portion+\"' en prijs \"+price+\" toegevoegd via GraphQL!\";<br \/>\n}<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>After completing necessary editings, click on <strong>Save<\/strong> button.<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>2. Addin<\/strong><strong>g Actions<\/strong><\/h3>\n<h4><strong style=\"font-size: 16px;\">2.1. Adding APB-Add Order Action<\/strong><\/h4>\n<p><strong>Main Menu &gt; Manage &gt; Automation &gt; Actions &gt;<\/strong> Here, click on <strong>Add Action.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-32011 size-large\" src=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-01-1024x550.jpg\" alt=\"\" width=\"640\" height=\"344\" srcset=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-01-1024x550.jpg 1024w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-01-300x161.jpg 300w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-01-768x413.jpg 768w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-01-1536x826.jpg 1536w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-01.jpg 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Action Name:<\/strong> APB-Add Order<\/p>\n<p><strong>Action Type:<\/strong> Add Order<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p><strong>Menu Item Name:<\/strong> [:Menu Item Name]<\/p>\n<p><strong>Portion Name:<\/strong> [:Portion Name]<\/p>\n<p><strong>Quantity:<\/strong> [:Quantity]<\/p>\n<p>After completing necessary editings, click on <strong>Save<\/strong> button.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>2.2. Adding APB-Add Product Execute Script Action<\/strong><\/h4>\n<p><strong>Main Menu &gt; Manage &gt; Automation &gt; Actions &gt;<\/strong> Here, click on <strong>Add Action.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-32013 size-large\" src=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-02-1024x550.jpg\" alt=\"\" width=\"640\" height=\"344\" srcset=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-02-1024x550.jpg 1024w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-02-300x161.jpg 300w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-02-768x413.jpg 768w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-02-1536x826.jpg 1536w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-02.jpg 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Action Name:<\/strong> APB-Add Product Execute Script<\/p>\n<p><strong>Action Type:<\/strong> Execute Script<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p><strong>Function:<\/strong> [:Function]<\/p>\n<p><strong>Parameters:<\/strong> [:Parameters]<\/p>\n<p><strong>Run In Background:<\/strong> True<\/p>\n<p>After completing necessary editings, click on <strong>Save<\/strong> button.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>2.3. Adding APB-Show Popup Action<\/strong><\/h4>\n<p><strong>Main Menu &gt; Manage &gt; Automation &gt; Actions &gt;<\/strong> Here, click on <strong>Add Action.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-32015 size-large\" src=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-03-1024x550.jpg\" alt=\"\" width=\"640\" height=\"344\" srcset=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-03-1024x550.jpg 1024w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-03-300x161.jpg 300w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-03-768x413.jpg 768w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-03-1536x826.jpg 1536w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-03.jpg 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Action Name:<\/strong> APB-Show Popup<\/p>\n<p><strong>Action Type:<\/strong> Update Program Setting<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p><strong>Setting Name:<\/strong> [:SettingName]<\/p>\n<p><strong>Setting Value:<\/strong> [:SettingValue]<\/p>\n<p><strong>Is Local:<\/strong> True<\/p>\n<p>After completing necessary editings, click on <strong>Save<\/strong> button.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>3. Addin<\/strong><strong>g Rule<\/strong><\/h3>\n<p><strong>Main Menu &gt; Manage &gt; Automation &gt; Rules &gt;<\/strong> Here, click on <strong>Add Rule.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-32017 size-large\" src=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-04-1024x550.jpg\" alt=\"\" width=\"640\" height=\"344\" srcset=\"https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-04-1024x550.jpg 1024w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-04-300x161.jpg 300w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-04-768x413.jpg 768w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-04-1536x826.jpg 1536w, https:\/\/kb.sambapos.com\/wp-content\/uploads\/2025\/07\/Add-Product-By-Barcode-04.jpg 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Rule Name:<\/strong> APB-Unknown Barcode Scanned<\/p>\n<p><strong>Event Name:<\/strong> Numberpad Value Entered<\/p>\n<p><strong>Execute Rule If:<\/strong> Matches<\/p>\n<p><strong>Add Custom Constraint:<\/strong><\/p>\n<p>{ENTITY NAME:Products}|Is Null|<\/p>\n<p><strong>Select Actions:<\/strong><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-1: APB-Show Popup<\/strong><\/span><\/p>\n<p><strong>SettingName:<\/strong> PRD_productName<\/p>\n<p><strong>SettingValue:<\/strong> [?Name;;;OCN]<\/p>\n<p>In here click on Select Actions button and move <strong>APB-Show Popup<\/strong> to the right side.<\/p>\n<p><span style=\"color: #000000;\"><strong>Add the same action 4 more times on the Action Adding Screen by right clicking on mouse and select<\/strong> <\/span><span style=\"color: #ff0000;\"><strong>Display All Values.<\/strong><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-2: APB-Show Popup<\/strong><\/span><\/p>\n<p><strong>SettingName:<\/strong> PRD_productPortion<\/p>\n<p><strong>SettingValue:<\/strong> Normal<\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-3: APB-Show Popup<\/strong><\/span><\/p>\n<p><strong>SettingName:<\/strong> PRD_productPrice<\/p>\n<p><strong>SettingValue:<\/strong> [?Price;[0-9.]{0,};;OCN;49,50,51|52,53,54|55,56,57|190,48,8]<\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-4: APB-Show Popup<\/strong><\/span><\/p>\n<p><strong>SettingName:<\/strong> PRD_productBarcode<\/p>\n<p><strong>SettingValue:<\/strong> [:NumberpadValue]<\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-5: APB-Show Popup<\/strong><\/span><\/p>\n<p><strong>SettingName:<\/strong> PRD_productCategory<\/p>\n<p><strong>SettingValue:<\/strong> [?Category;;{REPORT MENU ITEM DETAILS:M.GroupCode,T.GroupCode.asc}]<\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-6: APB-Add Product Execute Script<\/strong><\/span><\/p>\n<p><strong>Function:\u00a0<code>{CALL:addproductbybarcode.addProduct('{:PRD_productName}', '{:PRD_productPortion}', '{:PRD_productCategory}', '{:PRD_productPrice}', '{:PRD_productBarcode}', '{:PRD_productMenu}')}<\/code><\/strong><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Action-7: APB-Add Order<\/strong><\/span><\/p>\n<p><strong>Menu Item Name:<\/strong><code>[='{SETTING:PRD_productName}']<\/code><\/p>\n<p><strong>Portion Name:\u00a0<code>[='{SETTING:PRD_productPortion}']<\/code><\/strong><\/p>\n<p><strong>Quantity:<\/strong> 1<\/p>\n<p>After completing necessary editings, click on <strong>Save<\/strong> button.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this document it will be explained how to add new product by scanning an unknown barcode. &nbsp; 1. Adding Script Main Menu &gt; Manage &gt; Automation &gt; Scripts &gt; Here, click on Add Script. Name: Add Product By Barcode Handler: addproductbybarcode In here copy\/paste the below script into the Script field; function addProduct(name, portion, [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-32010","post","type-post","status-publish","format-standard","hentry","category-customization"],"_links":{"self":[{"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/posts\/32010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/comments?post=32010"}],"version-history":[{"count":3,"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/posts\/32010\/revisions"}],"predecessor-version":[{"id":32023,"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/posts\/32010\/revisions\/32023"}],"wp:attachment":[{"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/media?parent=32010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/categories?post=32010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.sambapos.com\/en\/wp-json\/wp\/v2\/tags?post=32010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}