<?php
function exwoofood_shortcode_cart( $atts ) {
	if(phpversion()>=7){
		$atts = (array)$atts;
	}
	if(is_admin()&& !defined( 'DOING_AJAX' ) || (defined('REST_REQUEST') && REST_REQUEST)){ return;}

	if(!function_exists('woocommerce_mini_cart')){ return;}
	ob_start();
	global $sc_cart;
	$sc_cart = 1;
	echo '<div class="ex-fdlist exwf-cart">';
	echo '<div class="ex-hidden">'.do_shortcode('[ex_wf_ordbutton enable_mtod="yes" product_id="-1" cart_enable="no" enable_mbnav="no"]').'</div>';
	exwoofood_template_plugin('cart-mini',1);
	echo '</div>';
	$output_string = ob_get_contents();
	ob_end_clean();
	return $output_string;
}
add_shortcode( 'ex_wf_cart', 'exwoofood_shortcode_cart' );
add_action( 'after_setup_theme', 'ex_reg_wfood_cart_vc' );
function ex_reg_wfood_cart_vc(){
    if(function_exists('vc_map')){
	vc_map( array(
	   "name" => esc_html__("Food Cart", "woocommerce-food"),
	   "base" => "ex_wf_cart",
	   "class" => "",
	   "icon" => "icon-grid",
	   "controls" => "full",
	   "category" => esc_html__('Woocommerce Food','woocommerce-food'),
	   "params" => array(
		  array(
		  	"admin_label" => true,
			"type" => "textfield",
			"heading" => esc_html__("Class name", "woocommerce-food"),
			"param_name" => "class",
			"value" => "",
			"description" => esc_html__("add a class name and refer to it in custom CSS", "woocommerce-food"),
		  ),
	   )
	));
	}
}