Connected template category to product in bundle product search

This commit is contained in:
Nedim Uka
2018-10-23 15:48:56 +02:00
parent 18f40d9403
commit 66452eee86
5 changed files with 42 additions and 11 deletions

View File

@@ -56,10 +56,14 @@ class Wiaas_Admin_Template_Selection {
<div id="wiaas_selected_template_items_container"><?php
$template_products_data = self::show_template_products($value);
self::render_template_products($template_products_data['hardware']);
self::render_template_products($template_products_data['services']);
self::render_template_products($template_products_data['installation']);
self::render_template_products($template_products_data['software']);
$product = wc_get_product( $post->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);
?></div><?php
}
@@ -132,17 +136,22 @@ class Wiaas_Admin_Template_Selection {
* Render html of template categories
*
* @param $template_products array containing template category information
* @param $categories_form_bundle
*/
public static function render_template_products($template_products) {
public static function render_template_products($template_products, $categories_form_bundle = array()) {
if (!empty($template_products)) {
foreach ($template_products as $item) {
$connected_product = $categories_form_bundle[$item['template_category_id']] ?
$categories_form_bundle[$item['template_category_id']]->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');
}