Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce - add serial to products in orders

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!

like image 777
user2806026 Avatar asked May 31 '15 15:05

user2806026


1 Answers

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.

like image 144
mitchelangelo Avatar answered Nov 16 '22 14:11

mitchelangelo