PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.1
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.1
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
notificationx / includes / Types / Traits / Conversions.php

Conversions.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.3.1, at includes/Types/Traits/Conversions.php

90 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Reviews Types
4 *
5 * @package NotificationX\Types
6 */
7
8 namespace NotificationX\Types\Traits;
9 use NotificationX\Core\Rules;
10
11 trait Conversions {
12
13 public function excludes_product( $data, $settings ){
14 if( empty( $settings['product_exclude_by'] ) || $settings['product_exclude_by'] === 'none' ) {
15 return $data;
16 }
17 $product_category_list = $new_data = [];
18
19 if( ! empty( $data ) ) {
20 foreach( $data as $key => $product ) {
21 $product_id = $product['product_id'];
22 if( $settings['product_exclude_by'] == 'product_category' ) {
23 $product_categories = get_the_terms( $product_id, 'product_cat' );
24 if( ! is_wp_error( $product_categories ) ) {
25 foreach( $product_categories as $category ) {
26 $product_category_list[] = $category->slug;
27 }
28 }
29
30 $product_category_count = count( $product_category_list );
31 $array_diff = array_diff( $product_category_list, $settings['exclude_categories'] );
32 $array_diff_count = count( $array_diff );
33
34 if( ! ( $array_diff_count < $product_category_count ) ) {
35 $new_data[ $key ] = $product;
36 }
37 $product_category_list = [];
38 }
39 if( $settings['product_exclude_by'] == 'manual_selection' ) {
40 if( ! in_array( $product_id, $settings['exclude_products'] ) ) {
41 $new_data[ $key ] = $product;
42 }
43 }
44 }
45 }
46
47 return $new_data;
48
49 }
50
51 public function show_purchaseof( $data, $settings ){
52 if( empty( $settings['product_control'] ) || $settings['product_control'] === 'none' ) {
53 return $data;
54 }
55
56 $product_category_list = $new_data = [];
57
58 if( ! empty( $data ) ) {
59 foreach( $data as $key => $product ) {
60 $product_id = $product['product_id'];
61 if( $settings['product_control'] == 'product_category' ) {
62 $product_categories = get_the_terms( $product_id, 'product_cat' );
63 if( ! is_wp_error( $product_categories ) ) {
64 foreach( $product_categories as $category ) {
65 $product_category_list[] = $category->slug;
66 }
67 }
68
69 $product_category_count = count( $product_category_list );
70 $array_diff = array_diff( $settings['category_list'], $product_category_list );
71 $array_diff_count = count( $array_diff );
72
73 $cute_logic = ( count( $settings['category_list'] ) - ( $product_category_count + $array_diff_count) );
74
75 if( ! $cute_logic ) {
76 $new_data[ $key ] = $product;
77 }
78 $product_category_list = [];
79 }
80 if( $settings['product_control'] == 'manual_selection' ) {
81 if( in_array( $product_id, $settings['product_list'] ) ) {
82 $new_data[ $key ] = $product;
83 }
84 }
85 }
86 }
87 return $new_data;
88 }
89
90 }