Title: Barcodes
Last modified: August 30, 2016

---

# Barcodes

 *  ResolvedPlugin Author [Peter Hardy-vanDoorn](https://wordpress.org/support/users/petervandoorn/)
 * (@petervandoorn)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/)
 * Me again 🙂 again!
 * My client is requiring barcodes, rather than QR codes.
 * I have found how you are generating the URL in the QR code, but I can’t seem 
   to get it to work for me (mostly because the code in add_qr_code() in checkin.
   class.php is using a variable called $order_item_id and I can’t find where it’s
   being defined or what it should contain).
 * I also see mention in the code that this whole checkin URL generation is pluggable.
 * Again, any documentation would be greatly appreciated.
 * Cheers
 * [https://wordpress.org/plugins/opentickets-community-edition/](https://wordpress.org/plugins/opentickets-community-edition/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [quadshot](https://wordpress.org/support/users/quadshot/)
 * (@quadshot)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/#post-6303853)
 * [@petervandoorn](https://wordpress.org/support/users/petervandoorn/) We’ll have
   to get one of the core developers to instruct on this. I do know that we aren’t
   setup to do straight barcodes but QR codes, but there may be a method to give
   you to change that.
 *  Plugin Author [loushou](https://wordpress.org/support/users/loushou/)
 * (@loushou)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/#post-6303859)
 * Hey [@petervandoorn](https://wordpress.org/support/users/petervandoorn/) ,
 * The primary reason we use a QR Code instead of a barcode is because you can include
   significantly more data in a QR than a regular barcode, an you use much less 
   space. Typically one of our barcodes holds somewhere in the range of 150 to 200
   characters of information (sometimes less, sometimes more, but this is an accurate
   average range). For a ‘regular barcode’ that data would be somewhere around 7-
   9 inches long in barcode form. With a QR, we can fit that into a square that 
   is less than 2×2, which actually fits on the ticket.
 * Despite this, if your client ‘requires’ it, and understands the severe limitations
   it incurs and extra work it could require, we can make it so. I assume, based
   on your comment, that you already have a lib you want to use to generate the 
   barcode. Assuming that you do, you can use the ‘qsot-compile-ticket-info’ filter
   to inject your code (after priority 3000) in the form of `<img>` tags, as you
   probably found out. If the ticket has a quantity of 1, you must make sure that
   the `->qr_code` property is set, with an `<img>` tag of the barcode. If the quantity
   is more than 1, you need to make one barcode for each of the tickets in the quantity,
   and store them in a numeric array `->qr_codes` (has an ‘s’).
 * Once you have that, the barcode should replace the QR code on the ticket. Now,
   assuming you did not change the information that goes into the barcode (when 
   compared to the info in the QR), you should just be able to start scanning, because
   the data has not changed, and really that is all the software cares about; however,
   if you did change the data, then you have a little more work ahead of you.
 * First, if you need to change the data of the barcode (so that it is not so overbearingly
   large), you can do so by hooking into ‘qsot-create-checkin-packet’, which you
   can find on `opentickets-community-edition/inc/ticket/checkin.class.php @ 285`.
   This filter will need to accept an array of data we gathered for the individual
   ticket, and pass back a string representation of it. As long as your filter returns
   something other than null, your data will be used instead of our core data. Looking
   at this code should explain how it works, but if you need guidance here, let 
   me know and I will do what I can to assist.
 * Next, when scanning the barcode, we need to make sure that if you changed the
   data, that we interpret the data the same way you created it. You can do this
   by hooking into ‘qsot-parse-checkin-packet’, found in `opentickets-community-
   edition/inc/ticket/checkin.class.php @ 326`. This filter will accept a string
   representation of the data you packed above, and we will need it to return an
   array of the needed data, detailed on like 329. As long as you return something
   other than null, you logic will be used, and ours will be skipped.
 * Finally, if it is vitally important to figure out where ‘order_item_id’ is generated,
   you can track that back to one of two locations.
 * *`opentickets-community-edition/inc/ticket/checkin.class.php @ 64`*
    This is 
   the location that is used during the actual checkin process. This is probably
   not the location you are mostly concerned with, but I will back track it for 
   your just for piece of mind. The ‘order_item_id’ key comes into this function
   from the function params. Those params are generated on line 37, above, which
   in turn calls `_parse_checkin_packet()` on line 306. Basically, in this particular
   location, the ‘order_item_id’ is parsed out of the checkin url data (the data
   that is stored in the QR code).
 * *`opentickets-community-edition/inc/ticket/ticket.class.php @ 280`*
    This is 
   the location that is used to generate the ticket output. This is probably the
   one you are concerned with. In this case, ‘order_item_id’ is parsed out of the‘
   ticket code’ (on line 269). That ‘ticket code’ is pulled from the actual ticket
   url (the url used to view the ticket). _That_ ‘ticket code’ is generated via 
   the `generate_ticket_code()` method (line 223) and stored in the databased in
   the the wp_qsot_ticket_codes table via the `add_ticket_code_for_order_item()`
   method (line 188) during the order creation process (or ‘add order item’ process).
   The ‘ticket code’ is parsed from the ticket url on line 269, which calls the `
   decode_ticket_code()` mehtod (line 241). That takes the ticket url and turns 
   it into an array containing the order_id, order_item_id, and event_id.
 * In short, I do not recommend changing the QR to a tranditional barcode. Even 
   at the absolute minimum length you can produce for information for it to hold(
   order_item_id, qty index, security code, and separators, which is 40-50 characters
   long), you are still looking at line 3-4 inches of barcode. Furthermore, the 
   order_item_id, while a relevant number, is really handled in the background, 
   and should not be the focal point of your investigation. If you really want to
   change to the barcode, investigate the ‘qsot-create-checkin-packet’ and ‘qsot-
   parse-checkin-packet’ filters, and assume that order_item_id will be part of 
   the information for those.
 * I really hope this helps, and if you come up with a solid solution that does 
   not have an outrageous barcode length, by all means, please share your solution,
   and we will do what we can to add it to the code.
 * Loushou
 *  Plugin Author [Peter Hardy-vanDoorn](https://wordpress.org/support/users/petervandoorn/)
 * (@petervandoorn)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/#post-6303863)
 * Hi. Thanks hugely for the detailed responses. It’s truly refreshing to come across
   a developer that actually tries to help you out (are you reading this, WooThemes?!
   😉
 * Thanks to your wonderfully commented code, I have actually been able to sort 
   most of this out for myself (at least, in theory – I’ve been away, so haven’t
   had a chance to put things into practice yet!)
 * Yes, I understand fully why QR codes are used as most barcodes formats either
   can’t handle a URL or would generate one that’s just too wide. Unfortunately,
   I am stuck with the fact that this site I’m putting together is for a client 
   who already has barcode scanning equipment, and so are requiring barcodes.
 * I think that the solution to this is to generate a much simplified barcode, consisting
   of just the minimum data – order number and ticket number probably, although 
   I may include a security hash too. I don’t need to encode anything else, such
   as venue or event area, etc, as there is only one of each and won’t change.
 * I will then create a simple page that takes that data from the scan and constructs
   the check in URL there and then. This will mean that the barcode is more secure
   as it doesn’t actually encode the check in URL.
 * _(as an aside, actually, I’ve noticed something about the check in process that
   I think you should address – I’ll create a new post for that though so that it
   doesn’t get lost!!)_
 * I was only enquiring about the origin of order_item_id because, in my testing,
   I wasn’t actually able to work out what this should hold. I had copied your code
   to create the checkin URL, but without the correct definition of order_item_id
   I always got an invalid checkin response.
 * Although you traced this back for me (thanks again) I’m still none the wiser 
   as to what, exacly, order_item_id should hold. Is it the WC order ID? The product
   ID? The event area ID?
 * Huge thanks once again!
 * Peter
 *  Plugin Author [loushou](https://wordpress.org/support/users/loushou/)
 * (@loushou)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/#post-6303883)
 * Hey [@petervandoorn](https://wordpress.org/support/users/petervandoorn/),
 * Sorry for the late response (a hectic week for me). To clarify, order_item_id
   should hold the WooCommerce `order_item_id`, the id that identifies a unique 
   order item. If you are going to encode one piece of data, this is by far the 
   most important. This id links it all together.
 * From the order_item_id, you can derive almost all information you need, which
   I think is what you want. You can use the order_item_id to look up the order_id,
   via the wp_woocommercer_order_items table. You can use it to find all of the 
   meta data for the item itself, like quantity, paid price, and event_id, via the
   wp_woocommerce_order_itemmeta table. Finally, you can actually use this to find
   the actual reservation information about that specific ticket, found in the wp_qsot_event_zone_to_order
   table.
 * Keep in mind, one of the big powers of having the ticket system on top of a flexible
   cart like WooCommerce, is that a given ticket can exist on the same order as 
   another (even several other) tickets, as well as non-tickets, like merch. Because
   there could be 10 different tickets for 8 different shows on a single order (
   or really any combination), having only the order_id is insufficient.
 * Consider that a user has purchased 2 tickets for today’s show, and 4 tickets 
   for tomorrow’s show, and paid for them on the same order. Knowing the order number
   would then be basically useless, because you have no idea which tickets to check
   in, since ticket exist for today’s show and tomorrow’s show. The only way I can
   see knowing only the order_id could work is if you were only checking in all 
   tickets for the same event on a given order at once, and knew the event_id before
   hand.
 * Then consider this. What if that same customer above went to today’s show with
   her son, who will be 15 minutes late to the show. She gave him his ticket so 
   he could get in, after she checked in. If you check in the entire order of tickets
   when she arrives then there could be a problem when he finally makes it. The 
   reason is because you already check in his ticket, but here he is 15 minutes 
   late trying to get in. Who is to say that this is not some random guy who photo
   copied his buddy’s ticket and is tryint to get free admission.
 * The information that goes into a ticket is mainly used as a security check. Sure
   someone could guess one short sequential number relatively easily. But it would
   be much harder to guess several sequential numbers, and a few strings, in their
   exact configuration, in order to build a valid fake ticket. That is why when 
   the checkin process happens we validate most of the data coincides with what 
   we have on record.
 * If you want to shorten that as much as possible then really the only thing you
   can use to guarantee you will have enough information to check them in, is the
   order_item_id. With it, you can derive all other data. Taking out all the other
   data however does open you up to anyone with some minor technical skill being
   able to “fake” or “commandeer” a ticket. If there is one thing I learn at Defcon
   every year, it is that if you leave it unsecured, it will be hacked. Just make
   sure client is aware of that aspect of their request too. 🙁
 * Anyways, hope this helps understand order_item_id and why it is important. If
   you have any other questions about it, let me know.
 * Loushou
 *  Plugin Author [Peter Hardy-vanDoorn](https://wordpress.org/support/users/petervandoorn/)
 * (@petervandoorn)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/#post-6303884)
 * Hi. And, again – wow – thanks!
 * So, in the add_qr_code() function in checkin.class.php ‘order_item_id’ => $order_item_id,
   is referring to the individual line item in the order. That which, indeed, WC
   themselves refer to as ‘order_item_id’ (d’oh! – well, best not to assume really!!)
 * Fantastic!
 *  Plugin Author [loushou](https://wordpress.org/support/users/loushou/)
 * (@loushou)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/barcodes/#post-6303887)
 * Hey [@petervandoorn](https://wordpress.org/support/users/petervandoorn/),
 * Yeah it is best not to assume for sure. That being said, I try to give most variables
   and functions names that fit. It is rare to see something like ‘$ambiguous_var_1’
   or ‘$value2’, unless it has contextual sense inside the scope it is used. Still,
   translating between WC and our plugin is not always one to one, so it is best
   to not assume, and ask. You were right on, as usual.
 * Loushou
 *  Plugin Author [Peter Hardy-vanDoorn](https://wordpress.org/support/users/petervandoorn/)
 * (@petervandoorn)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/barcodes/#post-6303892)
 * Hi. Sorry to bother you again!
 * I’m having trouble getting the order_item_id in the ticket display page (basic-
   ticket.php). Would it be possible to have it added to the $ticket array?
 * I’m sorry to keep bothering you about this, as I do appreciate you’re not here
   to give individual support for a free plugin.
 * If you’re wondering why, it’s because my client now wants both a barcode and 
   the QR code (!) and so I’ve decided not to over-ride your standard check-in procedure(
   which I’m assuming will stop the QR from working). What I’m thinking of doing
   is creating the barcode on the ticket page encoding the important info, and then
   create a new check-in barcode scanning page that takes that code and then re-
   creates the URL that the QR code encodes.
 * I know that sounds a bit of a long-way-round approach, but I think it will work.
 * Cheers!
 *  Plugin Author [loushou](https://wordpress.org/support/users/loushou/)
 * (@loushou)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/barcodes/#post-6303903)
 * Hey [@petervandoorn](https://wordpress.org/support/users/petervandoorn/),
 * Firstly, to this point, everything you have asked / pointed out, have been pretty
   general, and really have a place in a public forum, since you seem to have a 
   knack for identifying questions and comments before others do. Do not feel like
   you are taking advantage, because trust me, if we get to a point where your requests
   start fading into specialize support, I will let you know immediately. Further
   though, almost everything you have brought up has added to the product, not detracted,
   so keep it up without fear.
 * In regards to the actual request: you are quite right that the order_item_id 
   belongs in the $ticket information when rendering a ticket. I am pretty sure 
   I had it there at one point, but removed it. Looking though my notes though, 
   there is no indication of why I removed it, and I cannot see or think of any 
   reason why it would be imperative to do so; thus, I have readded the order_item_id
   to the $ticket object. You will now be able to access it (in the next version,
   1.11.2) by doing this inside the ticket template:
 *     ```
       echo "Order Item ID: ", $ticket->order_item_id;
       ```
   
 * Hope this helps, and I will ping again once the release is out,
    Loushou
 *  Plugin Author [Peter Hardy-vanDoorn](https://wordpress.org/support/users/petervandoorn/)
 * (@petervandoorn)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/barcodes/#post-6303904)
 * `<emoticon class="smiley-face" />`
 *  Plugin Author [loushou](https://wordpress.org/support/users/loushou/)
 * (@loushou)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/barcodes/#post-6303905)
 * Hey [@petervandoorn](https://wordpress.org/support/users/petervandoorn/),
 * This is in the new release, 1.11.2. Let me know if there is anything else, and
   thanks for the great idea.
 * Loushou

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Barcodes’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/opentickets-community-edition_bcbcb3.
   svg)
 * [OpenTickets Community Edition](https://wordpress.org/plugins/opentickets-community-edition/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/opentickets-community-edition/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/opentickets-community-edition/)
 * [Active Topics](https://wordpress.org/support/plugin/opentickets-community-edition/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/opentickets-community-edition/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/opentickets-community-edition/reviews/)

 * 10 replies
 * 3 participants
 * Last reply from: [loushou](https://wordpress.org/support/users/loushou/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/barcodes/#post-6303905)
 * Status: resolved