const { registerCheckoutFilters } = window.wc.blocksCheckout;

const modifyItemName = ( defaultValue, extensions, {context, cartItem, cart} ) => {
    //const isCartContext = context === 'cart';

    console.log('ssss', cart)

    if ( cartItem.type !== 'wcs_ticket' ) {
        return defaultValue;
    }

    const lines = (cartItem?.item_data || [])?.map( i => {
        return `<strong>${i.key}: </strong>${i.value}`
    })

    return `${defaultValue}<br><small class='wcs-woo-description'>${lines.join(' ')}</div>`;
};

const modifyCartItemClass = ( defaultValue, extensions, {context, cartItem, cart} ) => {

    if ( cartItem.type !== 'wcs_ticket' ) {
        return defaultValue;
    }

    return 'product-type-wcs_ticket';
};

registerCheckoutFilters( 'example-extension', {
    itemName: modifyItemName,
    cartItemClass: modifyCartItemClass,
} );

	