Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #4543990
Displaying Text Labels for Image Radio Options at cart and mini cart
Open

Comments

  •  1
    Rafael started the conversation

    Hi Dustin,

    I’ve recently purchased the WPC Product Options and I’m absolutely loving it.

    I have a specific UI challenge I need help with. For my "Image Radio" options, the Mini Cart and Cart page only show the selected image, but not the text label. This makes the cart look a bit confusing for customers (see attached screenshot).

    How can I display the Text Label instead of the image in the cart and checkout?

    I’m looking for a quick snippet to ensure the actual name of the option is what the customer sees once the item is added to the cart.

    Thanks,

    Attached files:  Screenshot 2026-02-17 at 13.09.13.png

  •  1,631
    Dustin replied

    Hi Rafael,

    Please add the custom code below. (How to add custom code? ↗):

    add_filter('wpcpo_cart_item_data', function($data, $option) {
    	if(( $option['type'] === 'image-radio' ) || ( $option['type'] === 'image-checkbox' )) {
    		$data['value'] .= isset( $option['label'] ) && $option['label'] !== '' ? $option['label'] : $option['value'];
    
    		if ( ! empty( $option['display_price'] ) ) {
    			$data['display'] = '<span class="' . esc_attr( 'wpcpo-item-data-display wpcpo-item-data-' . ( $option['type'] ?? 'default' ) ) . '">' . $data['value'] . ' <span class="wpcpo-item-data-price">(' . wc_price( $option['display_price'] ) . ')</span></span>';
    		}
    	}
    
    	return $data;
    }, 99, 2);

    The value will then be displayed next to the image.

    Best regards,
    Dustin

  •  1
    Rafael replied

    Thank You Dustin!