简体   繁体   中英

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:

添加序列的可能性

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM