<?php
if(class_exists('CmsShortCode') and class_exists('WooCommerce')){
    //get product categories
    $product_categories = get_categories( array(
        'hide_empty'   => 0,
        'hierarchical' => 1,
        'taxonomy'     => 'product_cat'
    ));
    $categories['- Select -'] = "";
    foreach ($product_categories as $cat) {
        $categories[$cat->cat_name] = (string)$cat->cat_ID;
    }
    vc_map(
        array(
            "name" => esc_html__("CMS Woo Category", 'haswell'),
            "base" => "wc_category",
            "class" => "vc-cms-woo-category",
            "category" => esc_html__("CmsSuperheroes Shortcodes", 'haswell'),
            "params" => array(
                array(
                    "type" => "dropdown",
                    "heading" => esc_html__("Category",'haswell'),
                    "param_name" => "category",
                    "value" => $categories,
                    "description" => esc_html__("Select Category",'haswell'),
                    "group" => esc_html__("General Settings", 'haswell')
                ),
                array(
                    "type" => "cms_template",
                    "param_name" => "cms_template",
                    "admin_label" => true,
                    "heading" => esc_html__("Shortcode Template",'haswell'),
                    "shortcode" => "wc_category",
                    "group" => esc_html__("General Settings", 'haswell')
                ),
                array(
                    'type' => 'checkbox',
                    'heading' => esc_html__( 'Custom Category Info ?', 'haswell' ),
                    'param_name' => 'wc_custom',
                    'description' => esc_html__( 'Custom Category Info', 'haswell' ),
                    "group" => esc_html__("General Settings", 'haswell')
                ),
                array(
                    'type' => 'textfield',
                    'heading' => esc_html__( 'Custom Text', 'haswell' ),
                    'param_name' => 'wc_custom_text',
                    'description' => esc_html__( 'Custom Text', 'haswell' ),
                    'dependency' => array(
                        'element' => 'wc_custom',
                        'value' => 'true',
                    ),
                    "group" => esc_html__("General Settings", 'haswell')
                ),
            )
        )
    );
    class WPBakeryShortCode_wc_category extends CmsShortCode {
        protected function content($atts, $content = null) {
            //default value
            $atts_extra = shortcode_atts(array(
                'category' => '',
                'cms_template' => 'wc_category.php',
            ), $atts);
            $atts = array_merge($atts_extra,$atts);
            $html_id = cmsHtmlID('cms-wc-category');
            $atts['template'] = 'template-'.str_replace('.php','',$atts['cms_template']);
            $atts['html_id'] = $html_id;
            return parent::content($atts, $content);
        }
    }
}
?>