<?php

if ( ! function_exists( 'calla_elated_register_woocommerce_dropdown_cart_widget' ) ) {
	/**
	 * Function that register dropdown cart widget
	 */
	function calla_elated_register_woocommerce_dropdown_cart_widget( $widgets ) {
		$widgets[] = 'CallaElatedWoocommerceDropdownCart';
		
		return $widgets;
	}
	
	add_filter( 'calla_core_register_widgets', 'calla_elated_register_woocommerce_dropdown_cart_widget' );
}

if ( ! function_exists( 'calla_elated_get_dropdown_cart_icon_class' ) ) {
	/**
	 * Returns dropdow cart icon class
	 */
	function calla_elated_get_dropdown_cart_icon_class() {
		$dropdown_cart_icon_source = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_source' );
		
		$dropdown_cart_icon_class_array = array(
			'eltdf-header-cart'
		);
		
		$dropdown_cart_icon_class_array[] = $dropdown_cart_icon_source == 'icon_pack' ? 'eltdf-header-cart-icon-pack' : 'eltdf-header-cart-svg-path';
		
		return $dropdown_cart_icon_class_array;
	}
}

if ( ! function_exists( 'calla_elated_get_dropdown_cart_icon_html' ) ) {
	/**
	 * Returns dropdown cart icon HTML
	 */
	function calla_elated_get_dropdown_cart_icon_html() {
		$dropdown_cart_icon_source   = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_source' );
		$dropdown_cart_icon_pack     = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_pack' );
		$dropdown_cart_icon_svg_path = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_svg_path' );
		
		$dropdown_cart_icon_html = '';
		
		if ( ( $dropdown_cart_icon_source == 'icon_pack' ) && ( isset( $dropdown_cart_icon_pack ) ) ) {
			$dropdown_cart_icon_html .= calla_elated_icon_collections()->getDropdownCartIcon( $dropdown_cart_icon_pack );
		} else if ( isset( $dropdown_cart_icon_svg_path ) ) {
			$dropdown_cart_icon_html .= $dropdown_cart_icon_svg_path;
		}
		
		return $dropdown_cart_icon_html;
	}
}