PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / trunk
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution vtrunk
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 / route.php
shopengine / modules / comparison Last commit date
assets 7 months ago comparison-cookie.php 2 years ago comparison-field-value.php 9 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
route.php
114 lines
1 <?php
2
3 namespace ShopEngine\Modules\Comparison;
4
5 use ShopEngine\Base\Api;
6 use ShopEngine\Utils\Helper;
7
8 class Route extends Api {
9
10 public function config() {
11
12 $this->prefix = 'comparison';
13 $this->param = "";
14 }
15
16
17 public function get_comparison_table() {
18 $data = $this->request->get_params();
19 $product_id = !empty($data['pid']) ? $data['pid'] : "";
20
21 if( $product_id ) Comparison_Cookie::add_product_id($product_id);
22 $product_ids = Comparison_Cookie::get_product_ids($product_id);
23
24 Comparison_Helper::get_html($product_ids);
25 exit();
26 }
27
28 public function post_remove() {
29
30 $data = $this->request->get_params();
31 $pid = $data['pid'];
32
33 Comparison_Cookie::remove_product_id($pid);
34
35 $product_ids = Comparison_Cookie::get_product_ids();
36 if (($key = array_search($pid, $product_ids)) !== false) {
37 unset($product_ids[$key]);
38 }
39 $share_url = home_url( '?comparison=yes&product_ids=' . implode( ',', $product_ids ) );
40
41 wp_send_json([
42 "status" => "Success",
43 "share_url" => $product_ids ? $share_url : home_url( '?comparison=yes' ),
44 ]);
45 }
46
47
48
49 public function get_comparison_bar_data() {
50
51 $product_ids = Comparison_Cookie::get_product_ids();
52
53 $content = '';
54 if ( empty( $product_ids ) ) {
55 $content .= '<h1 class="shopengine-no-comparison-product-for-bar">' . esc_html__( 'No product is added for comparison, please add some product to compare',
56 'shopengine' ) . '</h1>';
57 return $content;
58 }
59
60 $title = esc_html__("Remove Product For Comparison", "shopengine");
61
62 $args = [
63 'post_type' => 'product',
64 'post__in' => $product_ids
65 ];
66
67 $productQuery = new \WP_Query($args);
68
69 if ($productQuery->have_posts()) {
70 while ($productQuery->have_posts()) {
71 $productQuery->the_post();
72 $product = wc_get_product(get_the_ID());
73 $content .= '<div class="comparison-for-bottom-bar-item">
74 <a title="' . $title . '" class="shopengine-comparison-bar-action badge-comparison" data-pid="'.esc_attr( get_the_ID() ).'"><i class="eicon-close"></i></a>
75 '.$product->get_image('woocommerce_thumbnail').'</div>';
76 }
77 }
78
79 return $content;
80 }
81
82
83
84 public function get_attributes() {
85 global $wpdb;
86
87 $attributes = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}woocommerce_attribute_taxonomies");
88
89 $formatted_attributes = [];
90 foreach ($attributes as $attribute){
91 $formatted_attributes[$attribute->attribute_name] = $attribute->attribute_label;
92 }
93
94 wp_send_json([
95 "status" => "success",
96 "result" => $formatted_attributes,
97 "message" => "Available attributes"
98 ] );
99 }
100
101
102 public function get_custom_meta() {
103
104 wp_send_json([
105 "status" => "success",
106 "result" => Comparison_Helper::get_products_meta_keys(),
107 "message" => "Products Meta keys"
108 ] );
109 }
110
111
112
113 }
114