• I’m using WooCommerce Fields Factory to add a simple text field (Name on Shirt), plus some variations for size and colour to my product. This works great when ordering a product. However, when I click “Order again” (on a previous order) the size and colour transfer, but the “Name on Shirt” does not appear under the cart item when viewing VIEW CART. Is there a way to add this? I attempted to play with the woocommerce_order_again_cart_item_data filter but wasn’t able to solve the issue.

    Here’s my attempt to add the code:

    add_filter( 'woocommerce_order_again_cart_item_data', 'tres_add_shirt_text_to_order_again', 10, 3 );
    
    function tres_add_shirt_text_to_order_again($cart_item_data, $item, $order) {
    	global $woocommerce;
    	// I saw this next line in some similar code on the web, but I'm not sure if it is necessary?
    	remove_filter( 'woocommerce_add_to_cart_validation', array( $woocommerce, 'validate_add_cart_item' ), 10, 3 );
    
    	$key = 'Shirt Text';
    	if ( ! array_key_exists( 'item_meta', $cart_item_data ) || ! is_array( $cart_item_data['item_meta'] ) ) {
            $cart_item_data['item_meta'] = array();
        }
    	$cart_item_data['shirt_text'] = $product['item_meta'][$key][0];
    	$cart_item_data['item_meta']['shirt_text'] = $product['item_meta'][$key][0];
    
    	return $cart_item_data;
    }

    Thank you.

    https://www.ads-software.com/plugins/woocommerce/

  • The topic ‘"Order Again" not transferring custom fields’ is closed to new replies.