new-compare.php
491 lines
| 1 | <?php |
| 2 | global $product, $post; |
| 3 | if( isset($product) ) { |
| 4 | $product_backup = $product; |
| 5 | } |
| 6 | if( isset($post) ) { |
| 7 | $post_backup = $post; |
| 8 | } |
| 9 | if( empty( $is_full_screen ) ) { |
| 10 | $is_full_screen = FALSE; |
| 11 | } |
| 12 | $BeRocket_Compare_Products = BeRocket_Compare_Products::getInstance(); |
| 13 | $options_global = $BeRocket_Compare_Products->get_option(); |
| 14 | $options = $options_global['general_settings']; |
| 15 | $style = $options_global['style_settings']; |
| 16 | $text = $options_global['text_settings']; |
| 17 | if( isset($_GET['compare']) && $_GET['compare'] ) { |
| 18 | $products = explode(',', $_GET['compare']); |
| 19 | } else { |
| 20 | $products = $BeRocket_Compare_Products->get_all_compare_products(); |
| 21 | } |
| 22 | if ( isset( $products ) && is_array( $products ) && count( $products ) > 0 ) { |
| 23 | foreach ( $products as $i => $product ) { |
| 24 | $current_language= apply_filters( 'wpml_current_language', NULL ); |
| 25 | $product = apply_filters( 'wpml_object_id', $product, 'product', true, $current_language ); |
| 26 | $term = array(); |
| 27 | $post_get = wc_get_product($product); |
| 28 | if( $post_get === false ) { |
| 29 | unset($products[$i]); |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | $terms = array(); |
| 34 | $name = array(); |
| 35 | $name['attributes'] = array(); |
| 36 | $name['custom'] = array(); |
| 37 | $name['acf'] = array(); |
| 38 | $same = array(); |
| 39 | $same['attributes'] = array(); |
| 40 | $same['custom'] = array(); |
| 41 | $same['acf'] = array(); |
| 42 | $attr_count = array(); |
| 43 | $attr_count['attributes'] = array(); |
| 44 | $attr_count['custom'] = array(); |
| 45 | $attr_count['acf'] = array(); |
| 46 | if ( isset( $products ) && is_array( $products ) && count( $products ) > 0 ) { |
| 47 | $acf_field_list = array(); |
| 48 | if( isset($options['attributes']['acf_br_fields']) && function_exists('acf_get_field_groups') ) { |
| 49 | if( is_array($options['attributes']['acf_br_fields']) ) { |
| 50 | $acf_fields = $options['attributes']['acf_br_fields']; |
| 51 | $groups = acf_get_field_groups(); |
| 52 | if ( is_array( $groups ) ) { |
| 53 | foreach ( $groups as $group ) { |
| 54 | $fields = acf_get_fields($group); |
| 55 | if( is_array($fields) ) { |
| 56 | foreach($fields as $field) { |
| 57 | if( in_array($field['name'], $acf_fields) ) { |
| 58 | $acf_field_list[$field['name']] = $field; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | unset($options['attributes']['acf_br_fields']); |
| 66 | } |
| 67 | $description_length = 0; |
| 68 | foreach ( $products as $product ) { |
| 69 | $current_language= apply_filters( 'wpml_current_language', NULL ); |
| 70 | $product = apply_filters( 'wpml_object_id', $product, 'product', true, $current_language ); |
| 71 | $post = get_post($product); |
| 72 | $term = array(); |
| 73 | $post_get = wc_get_product($product); |
| 74 | if( $post_get === false ) { |
| 75 | continue; |
| 76 | } |
| 77 | $attributes = $post_get->get_attributes(); |
| 78 | $taxonomies = get_post_taxonomies( $product ); |
| 79 | $term['id'] = $product; |
| 80 | $term['title'] = $post_get->get_title(); |
| 81 | $term['image'] = $post_get->get_image(); |
| 82 | $term['price'] = $post_get->get_price_html(); |
| 83 | $term['link'] = $post_get->get_permalink(); |
| 84 | $term['short_description'] = get_the_excerpt($product); |
| 85 | $description_length = max(strlen($term['short_description']), $description_length); |
| 86 | //$term['availability'] = $post_get->stock_status; |
| 87 | $term['availability'] = $post_get->get_availability(); |
| 88 | $term['is_in_stock'] = $post_get->is_in_stock(); |
| 89 | $attributes_value = array(); |
| 90 | $attributes_name = array(); |
| 91 | foreach ( $attributes as $key => $attribute ) { |
| 92 | if ( ! is_array( $options['attributes'] ) || in_array( $key, $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { |
| 93 | $attributes_value[$key] = wc_get_product_terms( $product, $key ); |
| 94 | $same_check = wc_get_product_terms( $product, $key, array('fields' => 'slugs') ); |
| 95 | if ( is_object( br_get_value_from_array($attributes_value, array($key, 0)) ) ) { |
| 96 | $attr_value_temp = $attributes_value[$key]; |
| 97 | $attributes_value[$key] = array(); |
| 98 | $same_check = array(); |
| 99 | foreach( @ $attr_value_temp as $term_i => $term_data ) { |
| 100 | $attributes_value[$key][] = $term_data->name; |
| 101 | $same_check[] = $term_data->name; |
| 102 | } |
| 103 | } |
| 104 | if( isset($same['attributes'][$key]) ) { |
| 105 | $same['attributes'][$key] = array_intersect($same['attributes'][$key], $same_check); |
| 106 | } else { |
| 107 | $same['attributes'][$key] = $same_check; |
| 108 | } |
| 109 | if( empty($attr_count['attributes'][$key]) ) { |
| 110 | $attr_count['attributes'][$key] = count($attributes_value[$key]); |
| 111 | } else { |
| 112 | $attr_count['attributes'][$key] = max($attr_count['attributes'][$key], count($attributes_value[$key])); |
| 113 | } |
| 114 | $attributes_value[$key] = '<p>'.implode( '</p><p>', $attributes_value[$key] ).'</p>'; |
| 115 | if ( ! isset( $name['attributes'][$key] ) ) { |
| 116 | $attributes_name[$key] = get_taxonomy( $key ); |
| 117 | $taxonomy_label = $attributes_name[$key]->labels->singular_name; |
| 118 | $taxonomy_label = apply_filters('wpml_translate_single_string', $taxonomy_label, 'WordPress', sprintf( 'taxonomy singular name: %s', $taxonomy_label ) ); |
| 119 | $attributes_name[$key] = $taxonomy_label; |
| 120 | } |
| 121 | if(($key_delete = array_search($key, $taxonomies)) !== false) { |
| 122 | unset($taxonomies[$key_delete]); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | foreach($same['attributes'] as $key => $values) { |
| 127 | if( ! isset($attributes[$key]) ) { |
| 128 | $same['attributes'][$key] = array(); |
| 129 | } |
| 130 | } |
| 131 | $taxonomies = array_diff($taxonomies, array('product_type', 'product_shipping_class')); |
| 132 | $term['attributes'] = $attributes_value; |
| 133 | $name['attributes'] = $name['attributes'] + $attributes_name; |
| 134 | $attributes_value = array(); |
| 135 | $attributes_name = array(); |
| 136 | foreach ( $taxonomies as $key ) { |
| 137 | if ( ! is_array( $options['attributes'] ) || in_array( $key, $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { |
| 138 | $attributes_value[$key] = wp_get_post_terms( $product, $key ); |
| 139 | $custom_result = ''; |
| 140 | $same_check = array(); |
| 141 | foreach( $attributes_value[$key] as $cutom_term ) { |
| 142 | $custom_result .= '<p>'.$cutom_term->name.'</p>'; |
| 143 | $same_check[] = $cutom_term->slug; |
| 144 | } |
| 145 | if( isset($same['custom'][$key]) ) { |
| 146 | $same['custom'][$key] = array_intersect($same['custom'][$key], $same_check); |
| 147 | } else { |
| 148 | $same['custom'][$key] = $same_check; |
| 149 | } |
| 150 | if( ! empty($attributes_value[$key]) ) { |
| 151 | if( empty($attr_count['custom'][$key]) ) { |
| 152 | $attr_count['custom'][$key] = count($attributes_value[$key]); |
| 153 | } else { |
| 154 | $attr_count['custom'][$key] = max($attr_count['custom'][$key], count($attributes_value[$key])); |
| 155 | } |
| 156 | } |
| 157 | if ( $custom_result ) { |
| 158 | $attributes_value[$key] = $custom_result; |
| 159 | if ( ! isset( $name['custom'][$key] ) ) { |
| 160 | $attributes_name[$key] = get_taxonomy( $key ); |
| 161 | $taxonomy_label = $attributes_name[$key]->labels->name; |
| 162 | $taxonomy_label = apply_filters('wpml_translate_single_string', $taxonomy_label, 'WordPress', sprintf( 'taxonomy singular name: %s', $taxonomy_label ) ); |
| 163 | $attributes_name[$key] = $taxonomy_label; |
| 164 | } |
| 165 | } else { |
| 166 | unset( $attributes_value[$key] ); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | foreach($same['custom'] as $key => $values) { |
| 171 | if( ! in_array($key, $taxonomies) ) { |
| 172 | $same['custom'][$key] = array(); |
| 173 | } |
| 174 | } |
| 175 | $term['custom'] = $attributes_value; |
| 176 | $name['custom'] = $name['custom'] + $attributes_name; |
| 177 | //================================================================ |
| 178 | $attributes_value = array(); |
| 179 | $attributes_name = array(); |
| 180 | foreach ( $acf_field_list as $key => $field ) { |
| 181 | ob_start(); |
| 182 | the_field($field['name'], $product, true); |
| 183 | $attributes_value[$key] = array(ob_get_clean()); |
| 184 | if( empty($attributes_value[$key][0]) ) { |
| 185 | $attributes_value[$key] = array(''); |
| 186 | } |
| 187 | $custom_result = ''; |
| 188 | $same_check = array(); |
| 189 | foreach( $attributes_value[$key] as $cutom_term ) { |
| 190 | $custom_result .= '<p>'.$cutom_term.'</p>'; |
| 191 | $same_check[] = $cutom_term; |
| 192 | } |
| 193 | if( isset($same['acf'][$key]) ) { |
| 194 | $same['acf'][$key] = array_intersect($same['acf'][$key], $same_check); |
| 195 | } else { |
| 196 | $same['acf'][$key] = $same_check; |
| 197 | } |
| 198 | if( ! empty($attributes_value[$key]) ) { |
| 199 | if( empty($attr_count['acf'][$key]) ) { |
| 200 | $attr_count['acf'][$key] = count($attributes_value[$key]); |
| 201 | } else { |
| 202 | $attr_count['acf'][$key] = max($attr_count['acf'][$key], count($attributes_value[$key])); |
| 203 | } |
| 204 | } |
| 205 | if ( $custom_result ) { |
| 206 | $attributes_value[$key] = $custom_result; |
| 207 | if ( ! isset( $name['acf'][$key] ) ) { |
| 208 | $attributes_name[$key] = $field['label']; |
| 209 | } |
| 210 | } else { |
| 211 | unset( $attributes_value[$key] ); |
| 212 | } |
| 213 | } |
| 214 | foreach($same['acf'] as $key => $values) { |
| 215 | if( ! array_key_exists($key, $acf_field_list) ) { |
| 216 | $same['acf'][$key] = array(); |
| 217 | } |
| 218 | } |
| 219 | $term['acf'] = $attributes_value; |
| 220 | $name['acf'] = $name['acf'] + $attributes_name; |
| 221 | //================================================================ |
| 222 | $terms[] = $term; |
| 223 | } |
| 224 | $colwidth = $style['table']['colwidth']; |
| 225 | if( empty($colwidth) ) { |
| 226 | $colwidth = 200; |
| 227 | } |
| 228 | $colwidth = $colwidth - 10; |
| 229 | if( $colwidth < 0 ) { |
| 230 | $colwidth = 25; |
| 231 | } |
| 232 | $description_width = $description_length * 16; |
| 233 | $description_lines = $description_width / $colwidth; |
| 234 | $description_lines = (int)$description_lines; |
| 235 | $description_lines += 2; |
| 236 | $description_height = (20 + 20 * (empty($description_lines) ? 1 : $description_lines)); |
| 237 | $have_dif = false; |
| 238 | foreach ( $same['attributes'] as $attr ) { |
| 239 | if( count($attr) > 0 ) { |
| 240 | $have_dif = true; |
| 241 | break; |
| 242 | } |
| 243 | } |
| 244 | if( ! $have_dif ) { |
| 245 | foreach ( $same['custom'] as $attr ) { |
| 246 | if( count($attr) > 0 ) { |
| 247 | $have_dif = true; |
| 248 | break; |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | if( ! $have_dif ) { |
| 253 | foreach ( $same['acf'] as $attr ) { |
| 254 | if( count($attr) > 0 ) { |
| 255 | $have_dif = true; |
| 256 | break; |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | ?> |
| 261 | <div class="br_new_compare_block_wrap"> |
| 262 | <?php |
| 263 | if ( $options['use_full_screen'] || ! empty($is_full_screen) ) { |
| 264 | echo '<div class="br_new_compare_full_size br_full_size_open"><a href="#full-screen"><i class="fa fa-arrows-alt"></i></a></div>'; |
| 265 | echo '<div class="br_new_compare_full_size br_full_size_close" style="display:none;"><a href="#full-screen-close"><i class="fa fa-times"></i></a></div>'; |
| 266 | } |
| 267 | ?> |
| 268 | <div class="br_compare_popup_block"<?php if(! empty($berocket_element_i)) echo ' id="br_popup_'.$berocket_element_i.'"'; ?>> |
| 269 | <div class="br_new_compare_block" data-table_scroll="0" data-table_hidden_scroll="0" data-is_full_screen="<?php echo (empty($is_full_screen) ? "0" : "1"); ?>"> |
| 270 | <div style="clear:both;"></div> |
| 271 | <div class="br_top_table"> |
| 272 | <?php |
| 273 | if( $have_dif && ! empty($options['hide_same_button']) ) { |
| 274 | echo '<a class="br_show_compare_dif'.($options['hide_same_default'] ? ' br_hidden_same' : '').'" href="#difference">'.($options['hide_same_default'] |
| 275 | ? (empty($text['show_same_button_text']) ? __( 'Show attributes with same values', 'products-compare-for-woocommerce' ) : $text['show_same_button_text']) |
| 276 | : (empty($text['hide_same_button_text']) ? __( 'Hide attributes with same values', 'products-compare-for-woocommerce' ) : $text['hide_same_button_text']) |
| 277 | ).'</a>'; |
| 278 | } |
| 279 | if( ! empty($options['remove_all_compare']) ) { |
| 280 | echo '<a class="br_remove_all_compare" href="#remove_all">'.(empty($text['remove_all_compare_text']) ? __( 'Clear compare list', 'products-compare-for-woocommerce' ) : $text['remove_all_compare_text']).'</a>'; |
| 281 | } |
| 282 | $top_table_html = ' |
| 283 | <table>'; |
| 284 | $top_table_html2 = '<td></td>'; |
| 285 | $top_table_html .= ' |
| 286 | <tr><td></td>'; |
| 287 | foreach ( $terms as $term ) { |
| 288 | $top_table_html .= '<th><div> |
| 289 | <h3><a href="'.$term['link'].'">'.$term['title'].'</a></h3>'; |
| 290 | $top_table_term2 = ''; |
| 291 | if ( ! is_array( $options['attributes'] ) || in_array( 'cp_price', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { |
| 292 | $top_table_term2 .= '<p class="br_compare_price price">'.$term['price'].'</p>'; |
| 293 | } |
| 294 | if ( is_array( $options['attributes'] ) && in_array( 'cp_add_to_cart', $options['attributes'] ) ) { |
| 295 | $product = wc_get_product($term['id']); |
| 296 | $post = get_post($term['id']); |
| 297 | ob_start(); |
| 298 | echo '<div>'; |
| 299 | woocommerce_template_loop_add_to_cart(); |
| 300 | echo '</div>'; |
| 301 | $top_table_term2 .= ob_get_clean(); |
| 302 | } |
| 303 | if( ! empty($top_table_term2) ) { |
| 304 | $top_table_html2 .= '<th>'.$top_table_term2.'</th>'; |
| 305 | } |
| 306 | $default_language= apply_filters( 'wpml_default_language', NULL ); |
| 307 | $default_product = apply_filters( 'wpml_object_id', $term['id'], 'product', true, $default_language ); |
| 308 | $top_table_html .= '<a href="#remove" class="br_remove_compare_product_reload" data-id="'.$default_product.'"><i class="fa fa-times"></i></a>'; |
| 309 | $top_table_html .= '</div></th>'; |
| 310 | } |
| 311 | $top_table_html .= ' |
| 312 | </tr>'; |
| 313 | if( ! empty($top_table_html2) ) { |
| 314 | $top_table_html .= '<tr>'.$top_table_html2.'</tr>'; |
| 315 | } |
| 316 | $top_table_html .= ' |
| 317 | </table>'; |
| 318 | ?> |
| 319 | <div class="br_main_top"> |
| 320 | <?php echo $top_table_html; ?> |
| 321 | </div> |
| 322 | <div class="br_opacity_top"> |
| 323 | <?php echo $top_table_html; ?> |
| 324 | </div> |
| 325 | </div> |
| 326 | <div class="br_new_compare"> |
| 327 | <table class="br_left_table"> |
| 328 | <?php if ( ! is_array( $options['attributes'] ) || in_array( 'cp_image', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { ?> |
| 329 | <tr class="br_header_row"><td></td></tr> |
| 330 | <?php |
| 331 | } |
| 332 | if ( ! is_array( $options['attributes'] ) || in_array( 'cp_available', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { |
| 333 | echo '<tr class="br_absolute2_cp_availability"><th>'.(empty($text['availability']) ? __( 'Availability', 'products-compare-for-woocommerce' ) : $text['availability']).'</th></tr>'; |
| 334 | } |
| 335 | if ( ! is_array( $options['attributes'] ) || in_array( 'cp_short_description', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { ?> |
| 336 | <tr class="br_description_row"><th><?php echo (empty($text['description']) ? __( 'Description', 'products-compare-for-woocommerce' ) : $text['description']); ?></th></tr> |
| 337 | <?php |
| 338 | } |
| 339 | if ( is_array( $name['attributes'] ) && count( $name['attributes'] ) > 0 ) { |
| 340 | echo '<tr><th class="br_lined_attribute_left">'.(empty($text['attribute']) ? __( 'Attributes', 'products-compare-for-woocommerce' ) : $text['attribute']).'</th></tr>'; |
| 341 | foreach ( $name['attributes'] as $attr => $name_attr ) { |
| 342 | echo '<tr class="'.(is_array($same['attributes'][$attr]) && count($same['attributes'][$attr]) ? ' br_same_attr' : '').'" style="height:'.(15 + 20 * (empty($attr_count['attributes'][$attr]) ? '1' : $attr_count['attributes'][$attr])).'px!important;"><th>'.$name_attr.'</th></tr>'; |
| 343 | } |
| 344 | } |
| 345 | if ( is_array( $name['custom'] ) && count( $name['custom'] ) > 0 ) { |
| 346 | if ( is_array( $name['custom'] ) && count( $name['custom'] ) > 0 ) { |
| 347 | echo '<tr><th class="br_lined_attribute_left">'.(empty($text['custom']) ? __( 'Other attributes', 'products-compare-for-woocommerce' ) : $text['custom']).'</th></tr>'; |
| 348 | foreach ( $name['custom'] as $attr => $name_attr ) { |
| 349 | echo '<tr class="'.(is_array($same['custom'][$attr]) && count($same['custom'][$attr]) ? ' br_same_attr' : '').'" style="height:'.(15 + 20 * (empty($attr_count['custom'][$attr]) ? '1' : $attr_count['custom'][$attr])).'px!important;"><th>'.$name_attr.'</th></tr>'; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | if ( is_array( $name['acf'] ) && count( $name['acf'] ) > 0 ) { |
| 354 | foreach ( $name['acf'] as $attr => $name_attr ) { |
| 355 | echo '<tr class="'.(is_array($same['acf'][$attr]) && count($same['acf'][$attr]) ? ' br_same_attr' : '').'" style="'.apply_filters('berocket_compare_acf_product_field_height', 'height:'.(15 + 20 * (empty($attr_count['acf'][$attr]) ? '1' : $attr_count['acf'][$attr])).'px!important;', $acf_field_list[$attr]) . '"><th>'.$name_attr.'</th>'; |
| 356 | } |
| 357 | } |
| 358 | ?> |
| 359 | </table> |
| 360 | <div class="br_right_table"> |
| 361 | <table> |
| 362 | <?php if ( ! is_array( $options['attributes'] ) || in_array( 'cp_image', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { ?> |
| 363 | <thead> |
| 364 | <tr> |
| 365 | <td></td> |
| 366 | <?php |
| 367 | foreach ( $terms as $term ) { |
| 368 | echo '<th>'; |
| 369 | echo '<a href="'.$term['link'].'">'.$term['image'].'</a>'; |
| 370 | echo '</th>'; |
| 371 | } |
| 372 | ?> |
| 373 | </tr> |
| 374 | </thead> |
| 375 | <?php } ?> |
| 376 | <tbody> |
| 377 | <?php |
| 378 | if ( ! is_array( $options['attributes'] ) || in_array( 'cp_available', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { |
| 379 | echo '<tr>'; |
| 380 | echo '<th>'.(empty($text['availability']) ? __( 'Availability', 'products-compare-for-woocommerce' ) : $text['availability']).'</th>'; |
| 381 | foreach ( $terms as $term ) { |
| 382 | $class_stock = ''; |
| 383 | $text_stock = ''; |
| 384 | if ( $term['availability'] && ! empty( $term['availability']['availability'] ) ) { |
| 385 | $product = wc_get_product($term['id']); |
| 386 | $post = get_post($term['id']); |
| 387 | $availability_html = empty( $term['availability']['availability'] ) ? '' : '<p class="stock ' . esc_attr( $term['availability']['class'] ) . '">' . esc_html( $term['availability']['availability'] ) . '</p>'; |
| 388 | $text_stock = apply_filters( 'woocommerce_stock_html', $availability_html, $term['availability']['availability'], $product ); |
| 389 | $class_stock = esc_attr( $term['availability']['class'] ); |
| 390 | } else { |
| 391 | if ( $term['is_in_stock'] ) { |
| 392 | $text_stock = __( 'In stock', 'woocommerce' ); |
| 393 | $class_stock = 'in-stock'; |
| 394 | } else { |
| 395 | $text_stock = __( 'Out of stock', 'woocommerce' ); |
| 396 | $class_stock = 'out-of-stock'; |
| 397 | } |
| 398 | $text_stock = '<p class="stock '.$class_stock.'">'.$text_stock.'</p>'; |
| 399 | } |
| 400 | echo '<td>'; |
| 401 | echo $text_stock; |
| 402 | echo '</td>'; |
| 403 | } |
| 404 | echo '</tr>'; |
| 405 | } |
| 406 | if ( ! is_array( $options['attributes'] ) || in_array( 'cp_short_description', $options['attributes'] ) || count( $options['attributes'] ) == 0 ) { |
| 407 | echo '<tr class="br_description_row">'; |
| 408 | echo '<th>' . (empty($text['description']) ? __( 'Description', 'products-compare-for-woocommerce' ) : $text['description']) . '</th>'; |
| 409 | foreach ( $terms as $term ) { |
| 410 | echo '<td><div>'; |
| 411 | echo $term['short_description']; |
| 412 | echo '</div></td>'; |
| 413 | } |
| 414 | echo '</tr>'; |
| 415 | } |
| 416 | if ( is_array( $name['attributes'] ) && count( $name['attributes'] ) > 0 ) { |
| 417 | echo '<tr><th class="br_lined_attribute_left">'.(empty($text['attribute']) ? __( 'Attributes', 'products-compare-for-woocommerce' ) : $text['attribute']).'</th><td class="br_lined_attribute_right" colspan="'.(count($terms)).'"></td></tr>'; |
| 418 | foreach ( $name['attributes'] as $attr => $name_attr ) { |
| 419 | echo '<tr class="'.(is_array($same['attributes'][$attr]) && count($same['attributes'][$attr]) ? ' br_same_attr' : '').'" style="height:'.(15 + 20 * (empty($attr_count['attributes'][$attr]) ? '1' : $attr_count['attributes'][$attr])).'px!important;"><th>'.$name_attr.'</th>'; |
| 420 | foreach ( $terms as $term ) { |
| 421 | echo '<td>'.br_get_value_from_array($term, array('attributes', $attr)).'</td>'; |
| 422 | } |
| 423 | echo '</tr>'; |
| 424 | } |
| 425 | } |
| 426 | if ( is_array( $name['custom'] ) && count( $name['custom'] ) > 0 ) { |
| 427 | echo '<tr><th class="br_lined_attribute_left">'.(empty($text['custom']) ? __( 'Other attributes', 'products-compare-for-woocommerce' ) : $text['custom']).'</th><td class="br_lined_attribute_right" colspan="'.(count($terms)).'"></td></tr>'; |
| 428 | foreach ( $name['custom'] as $attr => $name_attr ) { |
| 429 | echo '<tr class="'.(is_array($same['custom'][$attr]) && count($same['custom'][$attr]) ? ' br_same_attr' : '').'" style="height:'.(15 + 20 * (empty($attr_count['custom'][$attr]) ? '1' : $attr_count['custom'][$attr])).'px!important;"><th>'.$name_attr.'</th>'; |
| 430 | foreach ( $terms as $term ) { |
| 431 | echo '<td>'.br_get_value_from_array($term, array('custom', $attr)).'</td>'; |
| 432 | } |
| 433 | echo '</tr>'; |
| 434 | } |
| 435 | } |
| 436 | if ( is_array( $name['acf'] ) && count( $name['acf'] ) > 0 ) { |
| 437 | foreach ( $name['acf'] as $attr => $name_attr ) { |
| 438 | echo '<tr class="'.(is_array($same['acf'][$attr]) && count($same['acf'][$attr]) ? ' br_same_attr' : '').'" style="'.apply_filters('berocket_compare_acf_product_field_height', 'height:'.(15 + 20 * (empty($attr_count['acf'][$attr]) ? '1' : $attr_count['acf'][$attr])).'px!important;', $acf_field_list[$attr]) . '"><th>'.$name_attr.'</th>'; |
| 439 | foreach ( $terms as $term ) { |
| 440 | echo '<td>'.apply_filters('berocket_compare_acf_product_field', br_get_value_from_array($term, array('acf', $attr)), $acf_field_list[$attr], $term).'</td>'; |
| 441 | } |
| 442 | echo '</tr>'; |
| 443 | } |
| 444 | } |
| 445 | ?> |
| 446 | </tbody> |
| 447 | </table> |
| 448 | </div> |
| 449 | <?php |
| 450 | $width_set = (empty($style['table']['colwidth']) ? 200 : $style['table']['colwidth']); |
| 451 | $width_set_full = $width_set * (count($terms) + 1); |
| 452 | $width_set = $width_set * count($terms); |
| 453 | ?> |
| 454 | <style> |
| 455 | .br_new_compare_block .br_top_table table, |
| 456 | .br_new_compare_block .br_right_table table { |
| 457 | min-width:<?php echo $width_set ?>px!important; |
| 458 | } |
| 459 | @media (max-width: 767px) { |
| 460 | .br_new_compare_block .br_top_table table, |
| 461 | .br_new_compare_block .br_right_table table { |
| 462 | min-width:<?php echo $width_set_full ?>px!important; |
| 463 | } |
| 464 | } |
| 465 | .br_new_compare .br_left_table .br_description_row, |
| 466 | .br_new_compare .br_right_table .br_description_row { |
| 467 | height:<?php echo $description_height; ?>px!important; |
| 468 | } |
| 469 | .br_new_compare .br_right_table .br_description_row td div { |
| 470 | height:<?php echo $description_height-1; ?>px!important; |
| 471 | } |
| 472 | </style> |
| 473 | <script> |
| 474 | if( typeof(berocket_popup_compare_scroll_fix) == 'function' ) { |
| 475 | berocket_popup_compare_scroll_fix(); |
| 476 | } |
| 477 | </script> |
| 478 | </div> |
| 479 | </div> |
| 480 | </div> |
| 481 | </div> |
| 482 | <?php |
| 483 | } |
| 484 | if( isset($product_backup) ) { |
| 485 | $product = $product_backup; |
| 486 | } |
| 487 | if( isset($post_backup) ) { |
| 488 | $post = $post_backup; |
| 489 | } |
| 490 | ?> |
| 491 |