/** * Get all compare cats */ public static function get_all_compare_cats($parent = 0, $append_str = '') { $compare_cats = array(); $all_product_cats = get_terms('product_cat', array('hide_empty' => false, 'parent' => $parent)); if (!empty($all_product_cats) && !is_wp_error($all_product_cats)) { foreach ($all_product_cats as $cat) { $cat->name = $append_str . $cat->name; $compare_cats[$cat->term_id] = $cat; $compare_cats = array_merge($compare_cats, WC_Compare_Functions::get_all_compare_cats($cat->term_id, $append_str . '– ')); } } return $compare_cats; }
/** * Edit Compare Feature field. * * @access public * @param mixed $term Term (category) being edited * @param mixed $taxonomy Taxonomy of the term being edited */ public function edit_feature_fields($term_id) { ob_start(); ?> <div class="a3rev_panel_container"> <div class="a3_wc_compare_plugin_meta_upgrade_area_box"> <?php global $wc_compare_admin_init; $wc_compare_admin_init->upgrade_top_message(true); ?> <h3><?php _e('Attribute Comparison Data', 'woo_cp'); ?> </h3> <input type="hidden" name="have_compare_feature_field" value="yes" /> <table class="form-table"> <tbody> <tr class="form-field"> <th scope="row" valign="top"> <div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="<?php _e("Attribute can be assigned to any Product Category that is activated for Product Comparisons. Attributes show on the comparison table as the Comparable Product Attributes.", 'woo_cp'); ?> "></div> <label for="field_type"><?php _e('Select Categories', 'woo_cp'); ?> </label> </th> <td> <?php $compare_cats = WC_Compare_Functions::get_all_compare_cats(); ?> <select multiple="multiple" name="field_cats[]" data-placeholder="<?php _e('Select Compare Categories', 'woo_cp'); ?> " style="width:95%;" class="chzn-select"> <?php if (is_array($compare_cats) && count($compare_cats) > 0) { foreach ($compare_cats as $cat) { ?> <option value="<?php echo $cat->term_id; ?> "><?php echo esc_html($cat->name); ?> </option> <?php } } ?> </select> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="<?php _e("Use these fields to determine how this Attribute with display its compare data. Text input fields are for adding custom compare data and ignore the Attribute Terms or set to show the Attributes Terms as single or multi select Compare data options that are quick and easy to set for each product.", 'woo_cp'); ?> "></div> <label for="field_type"><?php _e('Attribute and Terms Compare data Input type', 'woo_cp'); ?> </label> </th> <td> <select name="field_type" id="field_type" class="chzn-select" style="width:95%"> <?php foreach ($this->default_types as $type => $type_name) { ?> <option value="<?php echo $type; ?> "><?php echo $type_name['name'] . ' - ' . $type_name['description']; ?> </option> <?php } ?> </select> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="<?php _e("e.g kgs, mm, lbs, cm, inches - the unit of measurement shows after the Attribute name in (brackets). If you leave this blank you will just see the Attribute name.", 'woo_cp'); ?> "></div> <label for="field_unit"><?php _e('Attribute Unit of Measurement', 'woo_cp'); ?> </label> </th> <td> <input type="text" name="field_unit" id="field_unit" value="" /> </td> </tr> </tbody> </table> </div> </div> <?php $ouput = ob_get_clean(); $ouput = addslashes(str_replace(array("\r\n", "\r", "\n"), "", $ouput)); return $ouput; }