0

My app allows users to purchase products from a WooCommerce store. But I need to attach a serial number (cannot be generated on the fly) to each product, depending on type, size and design.

The serial numbers are selected from a pre-generated repository, and there are 20,000+

I'm thinking that I want to create a custom table just for these serial numbers and then connect the product with the serial using a custom field. There are two options that I see:

1) Create a Custom Post Type as serial_number

My main concern with creating a CPT is based on the massive number of posts that will need to be created to house all of the needed serial numbers. It may cause a huge bloat in the wp_posts and wp_postmeta tables...

2) Create a custom table, outside of the typical WP framework

My main concern with creating a custom table is that it is outside of the WP framework and it will make interacting with it a bit of a challenge.

I'm looking for guidance on this, because I need to ensure that I'm not going to need to make drastic changes to the database in the future as the data increases.

  • My initial feeling is to generate the serial keys dynamically at checkout and store them as meta values. Are these physical products you're selling or digital? – Benjamin Love Oct 17 '15 at 18:14
  • Problem is, these serial numbers can't be generated... a lot of them already exist, and it makes manufacturing the physical labels a lot easier. If they could, that would be my first choice as well. – dcolumbus Oct 17 '15 at 18:17
  • Oh so your table of serial numbers is basically your stock of inventory - on checkout you'd be marking that as sold... I sort of see where you're going. Instead, why not use the built-in inventory management features of Woocommerce, and when you receive an order - since you're manually grabbing the item and shipping it off - do the serial number management during that process. So wordpress/woocommerce knows how many you have in stock, but doesn't care about serial numbers. Then when you ship, you can add the serial number to the customer's order (as a note, or a meta field). – Benjamin Love Oct 17 '15 at 18:22
  • That's not a bad idea. The problem is, we want users to be able to manage their product (assign various virtual attributes) whilst they wait for their physical product to arrive. But fair enough, you didn't know about that aspect... – dcolumbus Oct 17 '15 at 18:25
  • Nonetheless - after you get the order and process it, now Wordpress/Woocommerce knows the serial number you've assigned to that specific order. As long as you disable those editing features until after the order is marked confirmed/processed by your team, you'll have access to the actual serial number when the customer goes in to adjust attributes. – Benjamin Love Oct 17 '15 at 18:36
0

then connect the product with the serial using a custom field

Why not store serial itself in custom field, instead of connection information?

You don't describe what serial number is in detail, but I think it's likely merely a text string. Since it's unique (as opposed to group-related) it sounds well suited to be just stored in custom field.

In my experience I had stored much more elaborate data in meta of WooCommerce orders (SVG customizations). I hit issues eventually with allowing multiple instances of same but differently customized product in same order, but I imagine with simpler use case the complexity would be accordingly lower.

  • I'm going to edit my question. Serial numbers cannot be generated. – dcolumbus Oct 17 '15 at 18:18
  • I don't see how is that an issue? As long as you can retrieve it and you want to store it with order, you can do that. – Rarst Oct 17 '15 at 18:19
  • But the serial number has to come from somewhere... they already exist and must be attached to a purchase product based on several, specific attributes. It's not as simple as just picking a number at random. – dcolumbus Oct 17 '15 at 18:20
  • Yes, but you are asking how to store it, not how to figure out the correct number. :) – Rarst Oct 17 '15 at 18:21
  • Well, I've done my best to describe that depending on how it's stored, relates to how I need to connect it. – dcolumbus Oct 17 '15 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.