PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets / 4.9.4
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets v4.9.4
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / modules / comparison / group-meta.php
shopengine / modules / comparison Last commit date
assets 2 weeks ago comparison-cookie.php 2 years ago comparison-field-value.php 11 months ago comparison-helper.php 3 years ago comparison-share.php 3 years ago comparison.php 3 years ago group-meta.php 3 years ago route.php 3 years ago
group-meta.php
62 lines
1 <?php
2
3 namespace ShopEngine\Modules\Comparison;
4
5 use ShopEngine\Modules\Swatches\Helper;
6 use ShopEngine\Modules\Swatches\Swatches;
7
8 class Group_Meta {
9
10 public function index(\WC_Product $product){
11
12 if( $product->get_status() !== 'publish' ){
13 return false;
14 }
15
16 $product_id = $product->get_id();
17
18 $formatted_attributes[ $product_id ] = [];
19
20 try {
21 if ( $product->has_attributes() ) {
22 $attributes = $product->get_attributes();
23
24 foreach ( $attributes as $attribute ) {
25 $attribute_id = $attribute->get_name();
26
27 $assigned_terms = $attribute->get_options();
28
29 $formatted_attributes[$product_id][$attribute_id]['name'] = wc_attribute_label( $attribute->get_name() );
30 $formatted_attributes[$product_id][$attribute_id]['plain_name'] = $attribute->get_name();
31 $formatted_attributes[$product_id][$attribute_id]['taxonomy'] = '';
32
33 if ( $attribute->is_taxonomy() ) {
34 $txo_meta = Helper::get_tax_attribute( $attribute->get_name() );
35
36 $formatted_attributes[$product_id][$attribute_id]['taxonomy'] = $txo_meta->attribute_type;
37
38 foreach ( $assigned_terms as $assigned_term ) {
39 $term = get_term_by( 'id', $assigned_term, $attribute->get_name() );
40
41 if ( $txo_meta->attribute_type === Swatches::PA_COLOR ) {
42 $t_val = get_term_meta( $assigned_term, 'shopengine_color', true );
43
44 $formatted_attributes[$product_id][$attribute_id]['taxonomy_value'][$assigned_term] = $t_val;
45 }
46
47 $formatted_attributes[$product_id][$attribute_id]['value'][] = $term->name;
48 }
49 } else {
50 foreach ( $assigned_terms as $term ) {
51 $formatted_attributes[$product_id][$attribute_id]['value'][] = $term;
52 }
53 }
54 }
55 }
56 return $formatted_attributes;
57 } catch ( \Throwable $th ) {
58 return false;
59 }
60 }
61 }
62