Product Categories
#Get
static function ProductCategory::Get($args);
Phiên bản plugin nhỏ hơn 3.0.0 get_product_category
Phiên bản plugin nhỏ hơn 2.0.6 wcmc_get_category
#Parameters
Tham số $args có thể là :
ID (int) danh mục sản phẩm
Mảng (array) các tham số
Parameter | Value | Description |
---|---|---|
where | string | array | Xem Model::get_data để biết thông tin về các đối số được chấp nhận. |
params | array | Xem Model::get_data để biết thông tin về các đối số được chấp nhận. |
#Gets
static function ProductCategory::Gets($args);
Phiên bản plugin nhỏ hơn 3.0.0 gets_product_category
Phiên bản plugin nhỏ hơn 2.0.6 wcmc_gets_category
#Parameters
Tham số $args có thể là :
Mảng (array) các tham số
Parameter | Value | Description |
---|---|---|
product_id | number | Lấy toàn bộ danh mục của sản phẩm có id là "product_id" |
mutilevel | string | number |
Number : cây thư mục dạng object có parent_id là mutilevel" option : cây thư mục dạng option của input select |
where | string | array | Xem Model::gets_data để biết thông tin về các đối số được chấp nhận. |
params | array | Xem Model::gets_data để biết thông tin về các đối số được chấp nhận. |
#Example
Lấy toàn bộ doanh mục
ProductCategory::Gets();
Array
(
[0] => stdClass Object
(
[id] => 4
[name] => Dụng cụ ăn
[slug] => dung-cu-a
[level] => 1
)
[1] => stdClass Object
(
[id] => 3
[name] => Dao, kéo
[slug] => dao-keo
[level] => 1
)
[2] => stdClass Object
(
[id] => 2
[name] => Đồ gang
[slug] => do-gang
[level] => 1
)
[3] => stdClass Object
(
[id] => 1
[name] => Nồi chảo
[slug] => noi-chao
[level] => 1
)
)
Lấy toàn bộ danh mục sắp xếp theo thứ tự cấp độ
ProductCategory::Gets(['tree' => array(), 'params' => array('select' => 'id, name, level')])
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Nồi chảo
[level] => 1
)
[1] => stdClass Object
(
[id] => 5
[name] => Nồi hàng quốc
[level] => 2
)
[2] => stdClass Object
(
[id] => 6
[name] => Nồi nhật bản
[level] => 2
)
[3] => stdClass Object
(
[id] => 2
[name] => Đồ gang
[level] => 1
)
[4] => stdClass Object
(
[id] => 3
[name] => Dao, kéo
[level] => 1
)
[5] => stdClass Object
(
[id] => 4
[name] => Dụng cụ ăn
[level] => 1
)
)
Lấy toàn bộ doanh mục theo cây thư mục dạng object
ProductCategory::Gets(['mutilevel' => 0, 'params' => array('select' => 'id, name, level')])
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Nồi chảo
[level] => 1
[child] => Array
(
[0] => stdClass Object
(
[id] => 6
[name] => Nồi nhật bản
[level] => 2
[child] => Array
(
)
)
[1] => stdClass Object
(
[id] => 5
[name] => Nồi hàng quốc
[level] => 2
[child] => Array
(
)
)
)
)
[1] => stdClass Object
(
[id] => 2
[name] => Đồ gang
[level] => 1
[child] => Array
(
)
)
[2] => stdClass Object
(
[id] => 3
[name] => Dao, kéo
[level] => 1
[child] => Array
(
)
)
[3] => stdClass Object
(
[id] => 4
[name] => Dụng cụ ăn
[level] => 1
[child] => Array
(
)
)
Lấy toàn bộ doanh mục theo cây thư mục dạng option
ProductCategory::Gets(['mutilevel' => 'option', 'params' => array('select' => 'id, name, level')])
Array
(
[0] => Chọn danh mục
[1] => Nồi chảo
[5] => |-----Nồi hàng quốc
[6] => |-----Nồi nhật bản
[2] => Đồ gang
[3] => Dao, kéo
[4] => Dụng cụ ăn
)
Lấy toàn bộ doanh mục của một sản phẩm
ProductCategory::Gets(['product_id' => 1, 'params' => array('select' => 'products_categories.id, name, level')])
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Nồi chảo
[level] => 1
)
[1] => stdClass Object
(
[id] => 2
[name] => Đồ gang
[level] => 1
)
)
#Delete
static function ProductCategory::delete($cateID);
Phiên bản plugin nhỏ hơn 3.0.0 delete_product_category
Phiên bản plugin nhỏ hơn 2.0.6 wcmc_delete_category
Tham số $cateID là : Id category muốn xóa