I'm building a custom plugin for my client, to add uploaded files to each product in cart. But I need also able to attached "upload id" let say:"456498816" to each product in cart.
So I will be able to use this data and associated it with the uploaded files, but only the products that i sending using this script.
update.php
After files uploaded it transfer the product id and quantity to cart using this code:
$product_id = $imgsizefilterdaddcart;
//$found = true;
$quantity = $spec3;
// echo '<pre>';
//var_dump( WC() );
//check if product already in cart
if (sizeof(WC()->cart->get_cart()) < 0) {
foreach(WC()->cart->get_cart() as $cart_item_key = > $values) {
// var_dump( $cart_item );
// var_dump( WC()->cart->get_item_data( $cart_item ) );
$_product = $values['data'];
if ($_product->id == $product_id)
$found = true;
}
// if product not found, add it
if (!$found)
WC()->cart->add_to_cart($product_id);
}
else {
// if no products in cart, add it
WC()->cart->add_to_cart($product_id, $quantity);
}
But I can't figure out how to add number of uploading id for example "4564564564" to each product in cart so that way I'm able to retrieve data after order complete, and know what files belong to what order all I need is to able add only id that I created to my uploaded files. I was thinking to do something like this:
WC()->cart->add_to_cart( $product_id,$quantity,$uploadid);