Exemplo n.º 1
0
function wdcat_add_category()
{
    global $wpdb;
    $query = "SELECT name,ordering FROM " . $wpdb->prefix . "spidercatalog_product_categories WHERE parent=0 ORDER BY `ordering`";
    $ord_elem = $wpdb->get_results($query);
    ///////ordering elements list
    $cat_row = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "spidercatalog_product_categories where parent=0");
    $cat_row = wdcat_open_cat_in_tree($cat_row);
    wdcat_html_add_category($ord_elem, $cat_row);
}
Exemplo n.º 2
0
 function wdcat_open_cat_in_tree($catt, $tree_problem = '', $hihiih = 1)
 {
     global $wpdb;
     $search_tag = '';
     static $trr_cat = array();
     if ($hihiih) {
         $trr_cat = array();
     }
     foreach ($catt as $local_cat) {
         $local_cat->name = $tree_problem . $local_cat->name;
         array_push($trr_cat, $local_cat);
         $new_cat_query = "SELECT  a.* ,  COUNT(b.id) AS count, g.par_name AS par_name FROM " . $wpdb->prefix . "spidercatalog_product_categories  AS a LEFT JOIN " . $wpdb->prefix . "spidercatalog_product_categories AS b ON a.id = b.parent LEFT JOIN (SELECT  " . $wpdb->prefix . "spidercatalog_product_categories.ordering as ordering," . $wpdb->prefix . "spidercatalog_product_categories.id AS id, COUNT( " . $wpdb->prefix . "spidercatalog_products.category_id ) AS prod_count\nFROM " . $wpdb->prefix . "spidercatalog_products, " . $wpdb->prefix . "spidercatalog_product_categories\nWHERE " . $wpdb->prefix . "spidercatalog_products.category_id = " . $wpdb->prefix . "spidercatalog_product_categories.id\nGROUP BY " . $wpdb->prefix . "spidercatalog_products.category_id) AS c ON c.id = a.id LEFT JOIN\n(SELECT " . $wpdb->prefix . "spidercatalog_product_categories.name AS par_name," . $wpdb->prefix . "spidercatalog_product_categories.id FROM " . $wpdb->prefix . "spidercatalog_product_categories) AS g\n ON a.parent=g.id WHERE a.name LIKE '%" . esc_html($search_tag) . "%' AND a.parent=" . $local_cat->id . " group by a.id";
         $new_cat = $wpdb->get_results($new_cat_query);
         wdcat_open_cat_in_tree($new_cat, $tree_problem . "— ", 0);
     }
     return $trr_cat;
 }
Exemplo n.º 3
0
function wdcat_addProduct()
{
    global $wpdb;
    $params = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "spidercatalog_params");
    $new_param = array();
    foreach ($params as $param) {
        $new_param[$param->name] = $param->value;
    }
    $params = $new_param;
    $query = "SELECT id,name FROM " . $wpdb->prefix . "spidercatalog_product_categories where published=1";
    $rows1 = $wpdb->get_results($query);
    $category_id['0'] = array('value' => '0', 'text' => 'Uncategorised');
    $query = "SELECT ordering,name FROM " . $wpdb->prefix . "spidercatalog_products order by ordering";
    $rows1 = $wpdb->get_results($query);
    $cat_row = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "spidercatalog_product_categories where parent=0");
    $cat_row = wdcat_open_cat_in_tree($cat_row);
    $lists = $wpdb->get_results("SELECT ordering,name FROM " . $wpdb->prefix . "spidercatalog_products order by ordering");
    wdcat_html_addProduct($lists, $params, $rows1, $cat_row);
}