private function getCategoryTree($radio_buttons = false)
 {
     include_once _GIVEIT_CLASSES_DIR_ . '/HelperTreeCategories.php';
     $selected_cat = !$radio_buttons ? GiveItCategory::getCategories() : array(Category::getRootCategory()->id);
     $tree = new GiveItHelperTreeCategoriesCore('associated-categories-tree', 'Associated categories');
     $tree->setRootCategory(Category::getRootCategory()->id)->setUseCheckBox(!$radio_buttons)->setUseSearch(true)->setSelectedCategories($selected_cat);
     $tree->render();
 }
Пример #2
0
    private function isProductCategoryEnabledToDisplayButton($id_product)
    {
        /* checks if button is enabled for product category */
        if (!($categories = GiveItCategory::getCategories())) {
            return $this->l('one or more categores to which belongs product are disabled and button uses global settings');
        }
        $category_shop = version_compare(_PS_VERSION_, '1.5', '<') ? '' : ' JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cs.`id_shop`=' . (int) $this->context->shop->id . ' AND cs.`id_category`=cp.`id_category`) ';
        $total_category_count_products = Db::getInstance()->getValue('
                        SELECT COUNT(*)
                        FROM `' . _DB_PREFIX_ . 'category_product` cp
                        ' . $category_shop . '
                        WHERE cp.`id_product`=' . (int) $id_product);
        $active_product_categories = Db::getInstance()->getValue('
			SELECT COUNT(*)
			FROM `' . _DB_PREFIX_ . 'category_product` cp
			' . $category_shop . '
			WHERE cp.`id_product`=' . (int) $id_product . ' AND cp.`id_category` IN (' . implode(',', $categories) . ')
		');
        /* if amount of categories for this product differs from amount of categories enabled hide button */
        if ($total_category_count_products == $active_product_categories) {
            return true;
        } else {
            return $this->l('one or more categores to which belongs product are disabled and button uses global settings');
        }
    }