I am creating a custom element where I need to load woo-commerce product categories as dropdown (in visual composer element edit option)
but I am getting this error. can someone tell me where is the problem?
here is the code:
<?php
add_shortcode('woo_my_cat_sub_cat_show_element_code','woo_my_cat_sub_cat_show_element_functions');
function woo_my_cat_sub_cat_show_element_functions($atts,$content){
extract(shortcode_atts(array(
'woo_my_cat_list' => '',
),$atts));
ob_start();?>
<!-- I will do the frontend here -->
<?php
return ob_get_clean();
}
if(function_exists('vc_map')){
/***
* dynamic fields for the element
*/
$args = array(
'taxonomy' => 'product_cat',
// 'number' => $number,
// 'orderby' => $orderby,
// 'order' => $order,
// 'hide_empty' => $hide_empty,
//'include' => 59,
'parent' => 0,
);
$product_categories = get_terms($args);
$dropdown_cats_array = array();
foreach( $product_categories as $single ){
$dropdown_cats_array[$single->name] = $single->term_id;
}
vc_map(array(
'name' => 'Subcategory',
'base' => 'woo_my_cat_sub_cat_show_element_code',
'category' => 'Custom Element',
'params' => array(
array(
'param_name' => 'woo_my_cat_list',
'heading' => 'Select Category',
'type' => 'dropdown',
'value' => $dropdown_cats_array,
"description" => "Please Select the category, which subcategories you want to show on the page.",
),
)
));
}
?>
And here is the error I am getting: