I know this topic is more for the Product Image, but how I can upload the Customer Specific Logo for a Product variant as he not had it ready for upload. The Upload and Preview I made with the Function and Logic of the Product Page. But now I'm missing the part to update the order that not are complete.
I did try with this code:
add_filter('woocommerce_order_item_meta_end', '_hook_order_detail_item', 30, 3);
function _hook_order_detail_item($item_id, $item, $order)
{
foreach ($order->get_items() as $inner_item)
{
if ($inner_item['_img_file_degree']&&$item_id===$inner_item->get_id())
{
$_img_file = $inner_item['_img_file'];
$_img_file_title = $_img_file[0]['title'];
//print_r($_img_file_title);
//$order_id = $order->get_order_number();$cart_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
//echo '<pre>Hallo<br />'; print_r($cart_items);echo '<br /></pre>';
echo '<ul class="wc-item-meta" style="list-style: none; padding-left: 0; font-size: inherit;"><li><strong class="wc-item-meta-label">' . esc_html__('Bild hochgeladen:', 'woocommerce') . '</strong><span>' . $_img_file_title . '</span></li><li><strong class="wc-item-meta-label">' . esc_html__("Logo-Bilddrehung:", "woocommerce") . '</strong><span>' . $inner_item['_img_file_degree'] . '</span></li></ul>';
}
elseif (is_wc_endpoint_url( 'view-order' ))
{
$order_id = $order->get_order_number();$cart_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
$items = $order->get_items();
foreach ( $items as $item ) {
$product_name = $item->get_name();
$product_id = $item->get_product_id();
$product_variation_id = $item->get_variation_id();
};
?><form class="variations_form" method="post"><?php display_additional_product_fields();
// echo '<pre>Hallo<br />'; print_r($product_variation_id);echo '<br /></pre>';
?><button type="submit" class="button" name="update_product" id="image_variant_upload" value="<?php esc_attr_e( 'Update product', 'woocommerce' ); ?>"><?php esc_html_e( 'Update product', 'woocommerce' ); ?>
</button>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>">
<input type="hidden" name="variation_id" class="variation_id" value="<?php echo $product_variation_id; ?>">
</form><?php
if(array_key_exists('update_product', $_POST)) {add_custom_fields_data_as_custom_cart_item_data($cart_item, $product_id);};
);
};
}
}
This Code is in the same file like the add_action to add the Logo on Cart as Product Variation Image upload.