16

I am looking for a way to add a serial number to each sold product, in the order display in WooCommerce. What I need is a manual solution, where the S/N of the sent product is added to the order before the package is sent. I have tried to show it on the following picture:

Possibility of adding a serial

Originally, I thought about implementing it as a product meta (without really knowing how) but I realized that product metas can only be altered when the order is set on hold and not while processing.

Any ideas aboout how to proceed? Thanks already!

John Conde
  • 217,595
  • 99
  • 455
  • 496
user2806026
  • 787
  • 3
  • 10
  • 24
  • Perhaps [WooCommerce Serial Keys](http://www.storeapps.org/support/documentation/woocommerce-serial-key/)? You can easily add some custom meta to the order item, the trick would be making sure that it was always unique. To that end you might need a custom table to store the IDs. – helgatheviking Feb 10 '16 at 02:04
  • 1
    I want to assume that the product being sent has its own unique S/N per item.. so you want to add it every time you ship an item... is that correct? – Reigel Gallarde Feb 10 '16 at 06:45
  • @Reigel, Exactly I want that only when I will ship the product – Cool Perfectionist Feb 10 '16 at 06:56
  • @CoolPerfectionist I was thinking of creating this, but I don't find it of use in general public, thus, I find it too big to do for just one person... if you can explain why or how this would help the general public, I might try and implement this.. (at least, that's how I answer questions here in SO). – Reigel Gallarde Feb 13 '16 at 03:13

1 Answers1

1

Not really sure what your trying to achieve but if you need a serial number for each product (just to display it in your cart page) you can add that data as an attribute to each listing then recall it in the checkout area and have it display using hooks. How do you want to process the serial number? is it purely for display on checkout? assuming it is...

add_filter( 'woocommerce_cart_item_name', recall_serial_number, 10, 2 );

function recall_serial_number() {
    $serial = $item_data->get_attributes( 'serial-number' );    
    echo $serial;
}

Give this code a whirl if all you want to do is display the serial on the cart page without processing it any further. Make sure the name of the attribute is "Serial Number" not tested but should work.

mitchelangelo
  • 851
  • 4
  • 16
  • 42
  • Can you pease explain the filter for adding serial number in product archive page @Scott ? – Lipsa Dec 29 '16 at 09:47