Added documentation to methods

This commit is contained in:
Nedim Uka
2018-09-28 14:24:47 +02:00
parent 6f6fb1115a
commit f1c99c28ae
4 changed files with 107 additions and 51 deletions

View File

@@ -27,10 +27,16 @@ function construct_template_products_class() {
return 'wiaastemplate';
}
/**
* Get template categories from template product meta
*
* @param $template_id integer
* @param $template_category_slug string the name of the main wiaas category
* @return mixed
*/
public function get_template_categories_from_meta($template_id, $template_category_slug) {
return get_post_meta($template_id, $template_category_slug, true);
}
public static function extract_template_product_categories($category_meta) {
@@ -60,6 +66,12 @@ function construct_template_products_class() {
return empty($category_objects) ? null : $category_objects;
}
/**
* Get template categories from bundled products items
*
* @param $bundled_items array
* @return array
*/
public static function extract_bundled_product_categories($bundled_items) {
$template_category_objects = array();
@@ -89,6 +101,13 @@ function construct_template_products_class() {
return $template_category_objects;
}
/**
* Save selected template to bundled product meta
*
* @param $selected_template integer
* @param $post_id integer
*/
public static function bind_selected_template_to_product($selected_template, $post_id) {
if (!empty($selected_template))
update_post_meta($post_id, '_select_template', esc_attr($selected_template));
@@ -97,6 +116,14 @@ function construct_template_products_class() {
}
}
/**
* Save template categories to template product meta
*
* @param $post_id integer
* @param $option string a main wiaas category
* @param $processed_template_data array actual template category data
*/
public static function save_template_product_meta($post_id, $option, $processed_template_data) {
update_post_meta($post_id, '_template_items_' . $option, $processed_template_data);