/**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     extract($attributes);
     $products = $this->getCollection($attributes, array('post_type' => 'product'));
     $counter = 0;
     $categories = get_term_by('slug', $cat_name, 'product_category');
     if (!$categories) {
         return __('Product category slug not found: ', 'ct_theme') . $cat_name;
     }
     $categoryName = $categories->name;
     $category_description = $categories->description;
     $icons = $this->getDefaultIcons();
     if (isset($icons[$category_image])) {
         $category_image = $icons[$category_image];
     }
     $menuBoxHtml = '[menu_box style="' . $style . '" title="' . $categoryName . '" image="' . $category_image . '" description="' . $category_description . '"]';
     foreach ($products as $p) {
         $custom = get_post_custom($p->ID);
         $counter++;
         $imageSrc = $images == "yes" ? ct_get_feature_image_src($p->ID, 'full') : '';
         $thumb = $images == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb') : '';
         $price = str_replace('.', ',', $custom['price'][0]);
         $productPrice = explode(",", $price);
         $menuBoxHtml .= $this->embedShortcode('menu_box_item', array('thumb' => $thumb, 'image' => $imageSrc, 'separator' => $counter == count($products) ? 'no' : 'yes', 'title' => $p->post_title, 'price' => $productPrice[0], 'subprice' => isset($productPrice[1]) ? $productPrice[1] : ''), $p->post_content) . "\n";
     }
     $menuBoxHtml .= '[/menu_box]';
     return do_shortcode($menuBoxHtml);
 }
 /**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     $rounded = '';
     extract($attributes);
     //we grab only 1 product
     $products = $this->getCollection($attributes, array('post_type' => 'product', 'limit' => 1));
     if (!isset($products[0])) {
         return '';
     }
     $p = $products[0];
     $custom = get_post_custom($p->ID);
     $imageSrc = '';
     if ($images == 'yes') {
         if ($rounded == 'yes') {
             $imageSrc = $use_thumbnail == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb', 'product_box_2') : ct_get_feature_image_src($p->ID, 'product_box');
         } else {
             $imageSrc = $use_thumbnail == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb', 'product_box') : ct_get_feature_image_src($p->ID, 'product_box');
         }
     }
     $price = str_replace('.', ',', $this->getFromArray($custom, 'price'));
     $productPrice = explode(",", $price);
     $shortcode = $this->embedShortcode('product_box', array('button_label' => $button_label, 'button_link' => $button_link, 'postscript' => $this->getFromArray($custom, 'postscript'), 'align' => $align, 'style' => $style, 'rounded' => $rounded, 'title' => $p->post_title, 'image' => $imageSrc, 'price' => $showprice == 'yes' || $showprice == 'true' ? $productPrice[0] : '', 'subprice' => isset($productPrice[1]) ? $productPrice[1] : '', 'currency' => $this->getFromArray($custom, 'currency'), 'above_price_text' => $above_price_text), $p->post_content);
     return do_shortcode($shortcode);
 }