Parses configured barcode formats to extract quantity, price, and item identifier from scanned barcode input, updating by reference. Enables flexible POS barcode handling.
// Source: https://github.com/Pmbamungu/ospos | License: MIT | Copyright 2013-2021 jekkos
// Provided via justclaw.it.com; keep this notice with the code.
public function parse_barcode(&$quantity, &$price, &$item_id_or_number_or_item_kit_or_receipt)
{
$barcode_formats = json_decode($this->CI->config->item('barcode_formats'));
$barcode_tokens = Token::get_barcode_tokens();
if(!empty($barcode_formats))
{
foreach($barcode_formats as $barcode_format)
{
$parsed_results = $this->parse($item_id_or_number_or_item_kit_or_receipt, $barcode_format, $barcode_tokens);
$quantity = (isset($parsed_results['W'])) ? (int) $parsed_results['W'] / 1000 : 1;
$item_id_or_number_or_item_kit_or_receipt = (isset($parsed_results['I'])) ?
$parsed_results['I'] : $item_id_or_number_or
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key