<?php
// Ensure cart contents updates when products are added to the cart via AJAX
function tropicana_wc_header_add_to_cart_fragment( $fragments ) {
	if ( get_theme_mod( 'tropicana-font-awesome-version', customizer_library_get_default( 'tropicana-font-awesome-version' ) ) == '4.7.0' ) {
		$font_awesome_code = 'otb-fa';
		$font_awesome_icon_prefix = 'otb-';
	} else {
		$font_awesome_code = 'fa';
		$font_awesome_icon_prefix = '';
	}
		
	ob_start();
	get_template_part( 'library/template-parts/header-cart-contents' );
	$fragments['a.header-cart-contents'] = ob_get_clean();
    return $fragments;
}

if ( get_theme_mod( 'tropicana-woocommerce-header-cart-auto-update', true ) ) {
	add_filter('woocommerce_add_to_cart_fragments', 'tropicana_wc_header_add_to_cart_fragment');
}
