Custom data partly missing
-
Hi
Love the cart and checkout blocks! But I have some custom code that a developer added who I cannot get hold of now. It adds a note and preview image into the cart product data. But switching to the new block it shows everything except the preview image, any idea why please?
// Add custom note as custom cart item data add_filter('woocommerce_add_cart_item_data', 'custom_woocommerce_add_cart_item_data', 10, 4) function get_custom_product_note( $cart_item_data, $product_id ){ if ( isset($_GET['note']) && ! empty($_GET['note']) ) { $cart_item_data['custom_note'] = sanitize_text_field( $_GET['note'] ); $cart_item_data['unique_key'] = md5( microtime().rand() ); } if ( isset($_GET['design']) && ! empty($_GET['design']) ) { $cart_item_data['design'] = sanitize_text_field( $_GET['design'] ); } return $cart_item_data; } // Display note in cart and checkout pages as cart item data - Optional add_filter( 'woocommerce_get_item_data', 'display_custom_item_data', 10, 2 ); function display_custom_item_data( $cart_item_data, $cart_item ) { if ( isset( $cart_item['custom_note'] ) ){ $cart_item_data[] = array( 'name' => "Note", 'value' => $cart_item['custom_note'], ); } if ( isset( $cart_item['design'] ) ){ $cart_item_data[] = array( 'name' => "Preview", 'value' => "<a href=\"$cart_item[design]\" target=\"_blank\" class=\"cartPreviewLink\"><img src=\"$cart_item[design]\" width=100 style=\"width:100px;max-width:100px!important;\" alt=\"\" /></a>", ); } return $cart_item_data; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Custom data partly missing’ is closed to new replies.