diff --git a/backend/app/plugins/wiaas/includes/admin/simple-product/class-wiaas-admin-product-additional-info.php b/backend/app/plugins/wiaas/includes/admin/simple-product/class-wiaas-admin-product-additional-info.php
index 489417e..4a7d416 100644
--- a/backend/app/plugins/wiaas/includes/admin/simple-product/class-wiaas-admin-product-additional-info.php
+++ b/backend/app/plugins/wiaas/includes/admin/simple-product/class-wiaas-admin-product-additional-info.php
@@ -44,6 +44,14 @@ class Wiaas_Admin_Product_Additional_Info {
}
}
+ /**
+ * This method filters search results by template country
+ * In addition it adds template category to label of every product
+ *
+ * @param $search_results array provided by filter
+ * @return mixed array of filtered search results
+ */
+
public static function filter_product_by_country($search_results) {
$url = wp_get_referer();
@@ -59,9 +67,14 @@ class Wiaas_Admin_Product_Additional_Info {
if (!empty($search_results)) {
$search_result_objects = array_map('wc_get_product', array_keys($search_results));
- foreach ($search_result_objects as $result_id => $producta) {
- if (Wiaas_Countries::get_product_country_term_id($producta) !== $country_id) {
- unset($search_results[$producta->get_id()]);
+ foreach ($search_result_objects as $result_id => $product_form_search) {
+ if (Wiaas_Countries::get_product_country_term_id($product_form_search) !== $country_id) {
+ unset($search_results[$product_form_search->get_id()]);
+ } else {
+ $template_category = wp_get_object_terms($product_form_search->get_id(), 'template_category', array('fields' => 'names'));
+ if(!empty($template_category)){
+ $search_results[$product_form_search->get_id()] = $search_results[$product_form_search->get_id()].' ['.$template_category[0].']';
+ }
}
}
}
diff --git a/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-admin-template-selection.php b/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-admin-template-selection.php
index 2fca714..3135d2d 100644
--- a/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-admin-template-selection.php
+++ b/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-admin-template-selection.php
@@ -56,10 +56,14 @@ class Wiaas_Admin_Template_Selection {
ID );
+ $bundled_items = $product->get_bundled_items('view');
+ $categories_form_bundle = WC_Product_Template::extract_bundled_product_categories($bundled_items);
+
+ self::render_template_products($template_products_data['hardware'], $categories_form_bundle);
+ self::render_template_products($template_products_data['services'], $categories_form_bundle);
+ self::render_template_products($template_products_data['installation'], $categories_form_bundle);
+ self::render_template_products($template_products_data['software'], $categories_form_bundle);
?>
product_name : '';
+
$product_id = $item['template_category_id'];
$title = $item['template_category_title'];
$quantity = $item['quantity'];
-
+ $connected_product_name = $connected_product;
include('views/html-wiaas-template-selection.php');
}
diff --git a/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-template-admin-ajax.php b/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-template-admin-ajax.php
index 18e0ab5..bd302b8 100644
--- a/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-template-admin-ajax.php
+++ b/backend/app/plugins/wiaas/includes/admin/template/class-wiaas-template-admin-ajax.php
@@ -83,7 +83,8 @@ class Wiaas_Template_Admin_Ajax {
$terms = get_terms(array(
'taxonomy' => 'template_category',
- 'name__like' => $term
+ 'name__like' => $term,
+ 'hide_empty' => false
));
foreach ($terms as $t) {
diff --git a/backend/app/plugins/wiaas/includes/admin/template/views/html-wiaas-template-selection.php b/backend/app/plugins/wiaas/includes/admin/template/views/html-wiaas-template-selection.php
index 4c19b4e..7059d58 100644
--- a/backend/app/plugins/wiaas/includes/admin/template/views/html-wiaas-template-selection.php
+++ b/backend/app/plugins/wiaas/includes/admin/template/views/html-wiaas-template-selection.php
@@ -9,5 +9,6 @@ if (!defined('ABSPATH')) {
[]
+ []
template_category_id = $id;
$this->name = $title;
$this->quantity = $quant;
+ $this->product_id = $product_id;
+ $this->product_name = $product_name;
}
public function get_quantity(){
diff --git a/backend/app/plugins/wiaas/includes/templates/class-wiaas-wc-product-template.php b/backend/app/plugins/wiaas/includes/templates/class-wiaas-wc-product-template.php
index e9b4198..e9f6484 100644
--- a/backend/app/plugins/wiaas/includes/templates/class-wiaas-wc-product-template.php
+++ b/backend/app/plugins/wiaas/includes/templates/class-wiaas-wc-product-template.php
@@ -92,7 +92,9 @@ function construct_template_products_class() {
$template_category_object = new Wiaas_Template_Category_Object(
$category_template_id,
$cat,
- $item_data['quantity_max']);
+ $item_data['quantity_max'],
+ $item->get_id(),
+ $item->get_title());
$template_category_objects[$category_template_id] = $template_category_object;
}