WooCommerce Wishlist Plugin - Version 1.24.0

Version Description

Release Date - 18 March 2021

  • Added plugin settings to allow disabling built-in integrations with 3rd party plugins and themes
  • Added preload for the plugin custom webfont
  • Added integration with WooCommerce Square plugin
  • Updated integration with WooCommerce TM Extra Product Options plugin
Download this release

Release Info

Developer templateinvaders
Plugin Icon 128x128 WooCommerce Wishlist Plugin
Version 1.24.0
Comparing to
See all releases

Code changes from version 1.23.10 to 1.24.0

Files changed (75) hide show
  1. admin/settings/integrations.class.php +126 -0
  2. assets/css/admin-form-rtl.min.css +1 -1
  3. assets/css/admin-form.min.css +1 -1
  4. assets/css/admin-rtl.min.css +1 -1
  5. assets/css/admin-setup-rtl.min.css +1 -1
  6. assets/css/admin-setup.min.css +1 -1
  7. assets/css/admin.min.css +1 -1
  8. assets/css/public-rtl.min.css +1 -1
  9. assets/css/public.min.css +1 -1
  10. assets/css/theme-rtl.min.css +1 -1
  11. assets/css/theme.min.css +1 -1
  12. assets/css/webfont-rtl.css +2 -2
  13. assets/css/webfont-rtl.css.map +1 -1
  14. assets/css/webfont-rtl.min.css +2 -2
  15. assets/css/webfont.css +2 -2
  16. assets/css/webfont.css.map +1 -1
  17. assets/css/webfont.min.css +2 -2
  18. assets/fonts/tinvwl-webfont.woff2 +0 -0
  19. assets/js/admin.min.js +1 -1
  20. assets/js/public.min.js +1 -1
  21. integrations/advanced-product-fields-for-woocommerce-pro.php +68 -44
  22. integrations/advanced-product-fields-for-woocommerce.php +76 -52
  23. integrations/automatewoo.php +48 -22
  24. integrations/check-pincodezipcode-for-shipping-woocommerce.php +24 -2
  25. integrations/clever-swatches.php +98 -74
  26. integrations/comet-cache.php +34 -11
  27. integrations/duracelltomi-google-tag-manager.php +31 -8
  28. integrations/elex-woocommerce-catalog-mode.php +40 -16
  29. integrations/gift-cards-for-woocommerce.php +170 -144
  30. integrations/hide-price-add-to-cart-button.php +454 -429
  31. integrations/improved-variable-product-attributes.php +59 -35
  32. integrations/litespeed-cache.php +55 -30
  33. integrations/mycred.php +345 -313
  34. integrations/product-extras-for-woocommerce.php +130 -106
  35. integrations/pw-woocommerce-gift-cards.php +23 -1
  36. integrations/show-single-variations.php +29 -6
  37. integrations/sitepress-multilingual-cms.php +46 -22
  38. integrations/theme-divi.php +36 -13
  39. integrations/theme-flatsome.php +24 -1
  40. integrations/theme-kallyas.php +32 -9
  41. integrations/theme-oceanwp.php +32 -9
  42. integrations/uni-woo-custom-product-options.php +107 -83
  43. integrations/woo-advanced-qty.php +46 -22
  44. integrations/woo-custom-product-addons.php +142 -117
  45. integrations/woo-payment-gateway.php +36 -13
  46. integrations/woo-product-bundle.php +67 -42
  47. integrations/woo-variation-swatches-pro.php +38 -13
  48. integrations/woo-variations-table-grid.php +47 -21
  49. integrations/woocommerce-booking.php +47 -23
  50. integrations/woocommerce-bookings.php +75 -49
  51. integrations/woocommerce-composite-products.php +110 -84
  52. integrations/woocommerce-custom-fields.php +69 -45
  53. integrations/woocommerce-gravityforms-product-addons.php +59 -32
  54. integrations/woocommerce-mix-and-match-products.php +88 -62
  55. integrations/woocommerce-multilingual.php +95 -68
  56. integrations/woocommerce-product-addon.php +47 -25
  57. integrations/woocommerce-product-addons.php +146 -119
  58. integrations/woocommerce-product-bundles.php +97 -72
  59. integrations/woocommerce-product-table.php +29 -9
  60. integrations/woocommerce-rental-and-booking.php +107 -82
  61. integrations/woocommerce-square.php +66 -0
  62. integrations/woocommerce-tm-extra-product-options.php +214 -70
  63. integrations/woocommerce-variation-swatches-and-photos.php +0 -18
  64. integrations/wp-fastest-cache.php +66 -43
  65. integrations/wp-grid-builder.php +52 -25
  66. integrations/wp-multilang.php +38 -16
  67. integrations/wp-rocket.php +76 -47
  68. integrations/wpc-variations-radio-buttons.php +31 -8
  69. integrations/yith-woocommerce-product-add-ons.php +58 -34
  70. integrations/yith-woocommerce-product-bundles.php +78 -53
  71. integrations/yith-woocommerce-quick-view.php +32 -9
  72. languages/ti-woocommerce-wishlist.pot +47 -31
  73. public/tinvwl.class.php +12 -0
  74. readme.txt +9 -1
  75. ti-woocommerce-wishlist.php +98 -84
admin/settings/integrations.class.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin settings class
4
+ *
5
+ * @since 1.0.0
6
+ * @package TInvWishlist\Admin
7
+ * @subpackage Settings
8
+ */
9
+
10
+ // If this file is called directly, abort.
11
+ if (!defined('ABSPATH')) {
12
+ die;
13
+ }
14
+
15
+ /**
16
+ * Admin settings class
17
+ */
18
+ class TInvWL_Admin_Settings_Integrations extends TInvWL_Admin_BaseSection
19
+ {
20
+
21
+ /**
22
+ * Priority for admin menu
23
+ *
24
+ * @var integer
25
+ */
26
+ public $priority = 110;
27
+
28
+ /**
29
+ * This class
30
+ *
31
+ * @var \TInvWL_Admin_Settings_Integrations
32
+ */
33
+ protected static $_instance = null;
34
+
35
+ /**
36
+ * Get this class object
37
+ *
38
+ * @param string $plugin_name Plugin name.
39
+ *
40
+ * @return \TInvWL_Admin_Settings_Integrations
41
+ */
42
+ public static function instance($plugin_name = TINVWL_PREFIX, $plugin_version = TINVWL_FVERSION)
43
+ {
44
+ if (is_null(self::$_instance)) {
45
+ self::$_instance = new self($plugin_name, $plugin_version);
46
+ }
47
+
48
+ return self::$_instance;
49
+ }
50
+
51
+ /**
52
+ * Menu array
53
+ *
54
+ * @return array
55
+ */
56
+ function menu()
57
+ {
58
+ return array(
59
+ 'title' => __('Integrations', 'ti-woocommerce-wishlist'),
60
+ 'page_title' => __('Wishlist Integrations with 3rd party plugins and themes', 'ti-woocommerce-wishlist'),
61
+ 'method' => array($this, '_print_'),
62
+ 'slug' => 'integrations-settings',
63
+ 'capability' => 'tinvwl_integrations_settings',
64
+ );
65
+ }
66
+
67
+ /**
68
+ * Create sections for this settings
69
+ *
70
+ * @return array
71
+ */
72
+ function constructor_data()
73
+ {
74
+
75
+ global $integrations;
76
+ $fields = array();
77
+ foreach ($integrations as $slug => $settings) {
78
+
79
+ $disabled = ($settings['available']) ? array() : array('disabled' => 'disabled');
80
+
81
+ $fields[] = array(
82
+ 'type' => 'checkboxonoff',
83
+ 'name' => $slug,
84
+ 'text' => $settings['name'],
85
+ 'std' => true,
86
+ 'extra' => $disabled,
87
+ );
88
+ }
89
+
90
+
91
+ $settings = array(
92
+
93
+ array(
94
+ 'id' => 'integrations',
95
+ 'title' => __('Available Integrations', 'ti-woocommerce-wishlist'),
96
+ 'show_names' => true,
97
+ 'fields' => $fields,
98
+ 'desc' => __('You can disable built-in integrations with 3rd party plugins and themes.', 'ti-woocommerce-wishlist'),
99
+ ),
100
+
101
+ );
102
+
103
+
104
+ // Buttons.
105
+ $settings[] = array(
106
+ 'id' => 'save_buttons',
107
+ 'class' => 'only-button',
108
+ 'noform' => true,
109
+ 'fields' => array(
110
+ array(
111
+ 'type' => 'button_submit',
112
+ 'name' => 'setting_save',
113
+ 'std' => '<span><i class="ftinvwl ftinvwl-check"></i></span>' . __('Save Settings', 'ti-woocommerce-wishlist'),
114
+ 'extra' => array('class' => 'tinvwl-btn split status-btn-ok'),
115
+ ),
116
+ array(
117
+ 'type' => 'button_submit_quick',
118
+ 'name' => 'setting_save_quick',
119
+ 'std' => '<span><i class="ftinvwl ftinvwl-floppy-o"></i></span>' . __('Save', 'ti-woocommerce-wishlist'),
120
+ ),
121
+ ),
122
+ );
123
+
124
+ return $settings;
125
+ }
126
+ }
assets/css/admin-form-rtl.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
assets/css/admin-form.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
assets/css/admin-rtl.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
assets/css/admin-setup-rtl.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
assets/css/admin-setup.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
assets/css/admin.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
assets/css/public-rtl.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
assets/css/public.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
assets/css/theme-rtl.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
assets/css/theme.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
assets/css/webfont-rtl.css CHANGED
@@ -3,8 +3,8 @@ WooCommerce Wishlist Plugin custom webfont
3
  -------------------------------------------------------------------*/
4
  @font-face {
5
  font-family: 'tinvwl-webfont';
6
- src: url("../fonts/tinvwl-webfont.eot?xu2uyi");
7
- src: url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"), url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"), url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"), url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");
8
  font-weight: normal;
9
  font-style: normal; }
10
 
3
  -------------------------------------------------------------------*/
4
  @font-face {
5
  font-family: 'tinvwl-webfont';
6
+ src: url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");
7
+ src: url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"), url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"), url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"), url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"), url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");
8
  font-weight: normal;
9
  font-style: normal; }
10
 
assets/css/webfont-rtl.css.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["webfont-rtl.css"],"file":"webfont-rtl.css","sourcesContent":["/*------------------------------------------------------------------\nWooCommerce Wishlist Plugin custom webfont\n-------------------------------------------------------------------*/\n@font-face {\n font-family: 'tinvwl-webfont';\n src: url(\"../fonts/tinvwl-webfont.eot?xu2uyi\");\n src: url(\"../fonts/tinvwl-webfont.eot?xu2uyi#iefix\") format(\"embedded-opentype\"), url(\"../fonts/tinvwl-webfont.ttf?xu2uyi\") format(\"truetype\"), url(\"../fonts/tinvwl-webfont.woff?xu2uyi\") format(\"woff\"), url(\"../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont\") format(\"svg\");\n font-weight: normal;\n font-style: normal; }\n\n.ftinvwl {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'tinvwl-webfont' !important;\n speak: none;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n line-height: 1;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.ftinvwl-twitter:before {\n content: \"\\f099\" !important; }\n\n.ftinvwl-facebook:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-facebook-f:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-google:before {\n content: \"\\f0d5\" !important; }\n\n.ftinvwl-email:before {\n content: \"\\f0e0\" !important; }\n\n.ftinvwl-pinterest:before {\n content: \"\\f231\" !important; }\n\n.ftinvwl-whatsapp:before {\n content: \"\\f232\" !important; }\n\n.ftinvwl-clipboard:before {\n content: \"\\e911\" !important; }\n\n.ftinvwl-star:before {\n content: \"\\e912\" !important; }\n\n.ftinvwl-shopping-cart:before {\n content: \"\\e913\" !important; }\n\n.ftinvwl-magic:before {\n content: \"\\e914\" !important; }\n\n.ftinvwl-info:before {\n content: \"\\e915\" !important; }\n\n.ftinvwl-graduation-cap:before {\n content: \"\\e918\" !important; }\n\n.ftinvwl-floppy-o:before {\n content: \"\\e919\" !important; }\n\n.ftinvwl-eyedropper:before {\n content: \"\\e91a\" !important; }\n\n.ftinvwl-exclamation-triangle:before {\n content: \"\\e91b\" !important; }\n\n.ftinvwl-check:before {\n content: \"\\e91e\" !important; }\n\n.ftinvwl-arrow-left:before {\n content: \"\\e91f\" !important; }\n\n.ftinvwl-wrench:before {\n content: \"\\e920\" !important; }\n\n.ftinvwl-chevron-down:before {\n content: \"\\e900\" !important; }\n\n.ftinvwl-chevron-right:before {\n content: \"\\e901\" !important; }\n\n.ftinvwl-chevron-left:before {\n content: \"\\e902\" !important; }\n\n.ftinvwl-chevron-up:before {\n content: \"\\e903\" !important; }\n\n.ftinvwl-cancel:before {\n content: \"\\e904\" !important; }\n\n.ftinvwl-times:before {\n content: \"\\e905\" !important; }\n\n.ftinvwl-heart-plus:before {\n content: \"\\e906\" !important; }\n\n.ftinvwl-heart-mark-right:before {\n content: \"\\e907\" !important; }\n\n.ftinvwl-heart2:before {\n content: \"\\e908\" !important; }\n\n.ftinvwl-heart-o:before {\n content: \"\\e909\" !important; }\n\n.ftinvwl-heart-mark-left:before {\n content: \"\\e90a\" !important; }\n\n.ftinvwl-heart-mail:before {\n content: \"\\e90b\" !important; }\n\n.ftinvwl-heart-tinv:before {\n content: \"\\e90c\" !important; }\n\n.ftinvwl-key:before {\n content: \"\\e90d\" !important; }\n\n.ftinvwl-lock:before {\n content: \"\\e90e\" !important; }\n\n.ftinvwl-hearts:before {\n content: \"\\e90f\" !important; }\n\n.ftinvwl-user:before {\n content: \"\\e910\" !important; }\n\n/* PULSE */\n@-webkit-keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n@keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n.ftinvwl-pulse.ftinvwl-animated::before {\n -webkit-animation: ftinvwl-pulse 2s linear infinite;\n animation: ftinvwl-pulse 2s linear infinite; }\n"]}
1
+ {"version":3,"names":[],"mappings":"","sources":["webfont-rtl.css"],"file":"webfont-rtl.css","sourcesContent":["/*------------------------------------------------------------------\nWooCommerce Wishlist Plugin custom webfont\n-------------------------------------------------------------------*/\n@font-face {\n font-family: 'tinvwl-webfont';\n src: url(\"../fonts/tinvwl-webfont.eot?ver=xu2uyi\");\n src: url(\"../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix\") format(\"embedded-opentype\"), url(\"../fonts/tinvwl-webfont.woff2?ver=xu2uyi\") format(\"woff2\"), url(\"../fonts/tinvwl-webfont.woff?ver=xu2uyi\") format(\"woff\"), url(\"../fonts/tinvwl-webfont.ttf?ver=xu2uyi\") format(\"truetype\"), url(\"../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont\") format(\"svg\");\n font-weight: normal;\n font-style: normal; }\n\n.ftinvwl {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'tinvwl-webfont' !important;\n speak: none;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n line-height: 1;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.ftinvwl-twitter:before {\n content: \"\\f099\" !important; }\n\n.ftinvwl-facebook:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-facebook-f:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-google:before {\n content: \"\\f0d5\" !important; }\n\n.ftinvwl-email:before {\n content: \"\\f0e0\" !important; }\n\n.ftinvwl-pinterest:before {\n content: \"\\f231\" !important; }\n\n.ftinvwl-whatsapp:before {\n content: \"\\f232\" !important; }\n\n.ftinvwl-clipboard:before {\n content: \"\\e911\" !important; }\n\n.ftinvwl-star:before {\n content: \"\\e912\" !important; }\n\n.ftinvwl-shopping-cart:before {\n content: \"\\e913\" !important; }\n\n.ftinvwl-magic:before {\n content: \"\\e914\" !important; }\n\n.ftinvwl-info:before {\n content: \"\\e915\" !important; }\n\n.ftinvwl-graduation-cap:before {\n content: \"\\e918\" !important; }\n\n.ftinvwl-floppy-o:before {\n content: \"\\e919\" !important; }\n\n.ftinvwl-eyedropper:before {\n content: \"\\e91a\" !important; }\n\n.ftinvwl-exclamation-triangle:before {\n content: \"\\e91b\" !important; }\n\n.ftinvwl-check:before {\n content: \"\\e91e\" !important; }\n\n.ftinvwl-arrow-left:before {\n content: \"\\e91f\" !important; }\n\n.ftinvwl-wrench:before {\n content: \"\\e920\" !important; }\n\n.ftinvwl-chevron-down:before {\n content: \"\\e900\" !important; }\n\n.ftinvwl-chevron-right:before {\n content: \"\\e901\" !important; }\n\n.ftinvwl-chevron-left:before {\n content: \"\\e902\" !important; }\n\n.ftinvwl-chevron-up:before {\n content: \"\\e903\" !important; }\n\n.ftinvwl-cancel:before {\n content: \"\\e904\" !important; }\n\n.ftinvwl-times:before {\n content: \"\\e905\" !important; }\n\n.ftinvwl-heart-plus:before {\n content: \"\\e906\" !important; }\n\n.ftinvwl-heart-mark-right:before {\n content: \"\\e907\" !important; }\n\n.ftinvwl-heart2:before {\n content: \"\\e908\" !important; }\n\n.ftinvwl-heart-o:before {\n content: \"\\e909\" !important; }\n\n.ftinvwl-heart-mark-left:before {\n content: \"\\e90a\" !important; }\n\n.ftinvwl-heart-mail:before {\n content: \"\\e90b\" !important; }\n\n.ftinvwl-heart-tinv:before {\n content: \"\\e90c\" !important; }\n\n.ftinvwl-key:before {\n content: \"\\e90d\" !important; }\n\n.ftinvwl-lock:before {\n content: \"\\e90e\" !important; }\n\n.ftinvwl-hearts:before {\n content: \"\\e90f\" !important; }\n\n.ftinvwl-user:before {\n content: \"\\e910\" !important; }\n\n/* PULSE */\n@-webkit-keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n@keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n.ftinvwl-pulse.ftinvwl-animated::before {\n -webkit-animation: ftinvwl-pulse 2s linear infinite;\n animation: ftinvwl-pulse 2s linear infinite; }\n"]}
assets/css/webfont-rtl.min.css CHANGED
@@ -1,9 +1,9 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
- @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
7
  .ftinvwl{font-family:'tinvwl-webfont' !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
8
  .ftinvwl-twitter:before{content:"\f099" !important}
9
  .ftinvwl-facebook:before{content:"\f09a" !important}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
+ @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
7
  .ftinvwl{font-family:'tinvwl-webfont' !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
8
  .ftinvwl-twitter:before{content:"\f099" !important}
9
  .ftinvwl-facebook:before{content:"\f09a" !important}
assets/css/webfont.css CHANGED
@@ -3,8 +3,8 @@ WooCommerce Wishlist Plugin custom webfont
3
  -------------------------------------------------------------------*/
4
  @font-face {
5
  font-family: 'tinvwl-webfont';
6
- src: url("../fonts/tinvwl-webfont.eot?xu2uyi");
7
- src: url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"), url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"), url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"), url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");
8
  font-weight: normal;
9
  font-style: normal; }
10
 
3
  -------------------------------------------------------------------*/
4
  @font-face {
5
  font-family: 'tinvwl-webfont';
6
+ src: url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");
7
+ src: url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"), url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"), url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"), url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"), url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");
8
  font-weight: normal;
9
  font-style: normal; }
10
 
assets/css/webfont.css.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["webfont.css"],"file":"webfont.css","sourcesContent":["/*------------------------------------------------------------------\nWooCommerce Wishlist Plugin custom webfont\n-------------------------------------------------------------------*/\n@font-face {\n font-family: 'tinvwl-webfont';\n src: url(\"../fonts/tinvwl-webfont.eot?xu2uyi\");\n src: url(\"../fonts/tinvwl-webfont.eot?xu2uyi#iefix\") format(\"embedded-opentype\"), url(\"../fonts/tinvwl-webfont.ttf?xu2uyi\") format(\"truetype\"), url(\"../fonts/tinvwl-webfont.woff?xu2uyi\") format(\"woff\"), url(\"../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont\") format(\"svg\");\n font-weight: normal;\n font-style: normal; }\n\n.ftinvwl {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'tinvwl-webfont' !important;\n speak: none;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n line-height: 1;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.ftinvwl-twitter:before {\n content: \"\\f099\" !important; }\n\n.ftinvwl-facebook:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-facebook-f:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-google:before {\n content: \"\\f0d5\" !important; }\n\n.ftinvwl-email:before {\n content: \"\\f0e0\" !important; }\n\n.ftinvwl-pinterest:before {\n content: \"\\f231\" !important; }\n\n.ftinvwl-whatsapp:before {\n content: \"\\f232\" !important; }\n\n.ftinvwl-clipboard:before {\n content: \"\\e911\" !important; }\n\n.ftinvwl-star:before {\n content: \"\\e912\" !important; }\n\n.ftinvwl-shopping-cart:before {\n content: \"\\e913\" !important; }\n\n.ftinvwl-magic:before {\n content: \"\\e914\" !important; }\n\n.ftinvwl-info:before {\n content: \"\\e915\" !important; }\n\n.ftinvwl-graduation-cap:before {\n content: \"\\e918\" !important; }\n\n.ftinvwl-floppy-o:before {\n content: \"\\e919\" !important; }\n\n.ftinvwl-eyedropper:before {\n content: \"\\e91a\" !important; }\n\n.ftinvwl-exclamation-triangle:before {\n content: \"\\e91b\" !important; }\n\n.ftinvwl-check:before {\n content: \"\\e91e\" !important; }\n\n.ftinvwl-arrow-left:before {\n content: \"\\e91f\" !important; }\n\n.ftinvwl-wrench:before {\n content: \"\\e920\" !important; }\n\n.ftinvwl-chevron-down:before {\n content: \"\\e900\" !important; }\n\n.ftinvwl-chevron-right:before {\n content: \"\\e901\" !important; }\n\n.ftinvwl-chevron-left:before {\n content: \"\\e902\" !important; }\n\n.ftinvwl-chevron-up:before {\n content: \"\\e903\" !important; }\n\n.ftinvwl-cancel:before {\n content: \"\\e904\" !important; }\n\n.ftinvwl-times:before {\n content: \"\\e905\" !important; }\n\n.ftinvwl-heart-plus:before {\n content: \"\\e906\" !important; }\n\n.ftinvwl-heart-mark-right:before {\n content: \"\\e907\" !important; }\n\n.ftinvwl-heart2:before {\n content: \"\\e908\" !important; }\n\n.ftinvwl-heart-o:before {\n content: \"\\e909\" !important; }\n\n.ftinvwl-heart-mark-left:before {\n content: \"\\e90a\" !important; }\n\n.ftinvwl-heart-mail:before {\n content: \"\\e90b\" !important; }\n\n.ftinvwl-heart-tinv:before {\n content: \"\\e90c\" !important; }\n\n.ftinvwl-key:before {\n content: \"\\e90d\" !important; }\n\n.ftinvwl-lock:before {\n content: \"\\e90e\" !important; }\n\n.ftinvwl-hearts:before {\n content: \"\\e90f\" !important; }\n\n.ftinvwl-user:before {\n content: \"\\e910\" !important; }\n\n/* PULSE */\n@-webkit-keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n@keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n.ftinvwl-pulse.ftinvwl-animated::before {\n -webkit-animation: ftinvwl-pulse 2s linear infinite;\n animation: ftinvwl-pulse 2s linear infinite; }\n"]}
1
+ {"version":3,"names":[],"mappings":"","sources":["webfont.css"],"file":"webfont.css","sourcesContent":["/*------------------------------------------------------------------\nWooCommerce Wishlist Plugin custom webfont\n-------------------------------------------------------------------*/\n@font-face {\n font-family: 'tinvwl-webfont';\n src: url(\"../fonts/tinvwl-webfont.eot?ver=xu2uyi\");\n src: url(\"../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix\") format(\"embedded-opentype\"), url(\"../fonts/tinvwl-webfont.woff2?ver=xu2uyi\") format(\"woff2\"), url(\"../fonts/tinvwl-webfont.woff?ver=xu2uyi\") format(\"woff\"), url(\"../fonts/tinvwl-webfont.ttf?ver=xu2uyi\") format(\"truetype\"), url(\"../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont\") format(\"svg\");\n font-weight: normal;\n font-style: normal; }\n\n.ftinvwl {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'tinvwl-webfont' !important;\n speak: none;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n line-height: 1;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.ftinvwl-twitter:before {\n content: \"\\f099\" !important; }\n\n.ftinvwl-facebook:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-facebook-f:before {\n content: \"\\f09a\" !important; }\n\n.ftinvwl-google:before {\n content: \"\\f0d5\" !important; }\n\n.ftinvwl-email:before {\n content: \"\\f0e0\" !important; }\n\n.ftinvwl-pinterest:before {\n content: \"\\f231\" !important; }\n\n.ftinvwl-whatsapp:before {\n content: \"\\f232\" !important; }\n\n.ftinvwl-clipboard:before {\n content: \"\\e911\" !important; }\n\n.ftinvwl-star:before {\n content: \"\\e912\" !important; }\n\n.ftinvwl-shopping-cart:before {\n content: \"\\e913\" !important; }\n\n.ftinvwl-magic:before {\n content: \"\\e914\" !important; }\n\n.ftinvwl-info:before {\n content: \"\\e915\" !important; }\n\n.ftinvwl-graduation-cap:before {\n content: \"\\e918\" !important; }\n\n.ftinvwl-floppy-o:before {\n content: \"\\e919\" !important; }\n\n.ftinvwl-eyedropper:before {\n content: \"\\e91a\" !important; }\n\n.ftinvwl-exclamation-triangle:before {\n content: \"\\e91b\" !important; }\n\n.ftinvwl-check:before {\n content: \"\\e91e\" !important; }\n\n.ftinvwl-arrow-left:before {\n content: \"\\e91f\" !important; }\n\n.ftinvwl-wrench:before {\n content: \"\\e920\" !important; }\n\n.ftinvwl-chevron-down:before {\n content: \"\\e900\" !important; }\n\n.ftinvwl-chevron-right:before {\n content: \"\\e901\" !important; }\n\n.ftinvwl-chevron-left:before {\n content: \"\\e902\" !important; }\n\n.ftinvwl-chevron-up:before {\n content: \"\\e903\" !important; }\n\n.ftinvwl-cancel:before {\n content: \"\\e904\" !important; }\n\n.ftinvwl-times:before {\n content: \"\\e905\" !important; }\n\n.ftinvwl-heart-plus:before {\n content: \"\\e906\" !important; }\n\n.ftinvwl-heart-mark-right:before {\n content: \"\\e907\" !important; }\n\n.ftinvwl-heart2:before {\n content: \"\\e908\" !important; }\n\n.ftinvwl-heart-o:before {\n content: \"\\e909\" !important; }\n\n.ftinvwl-heart-mark-left:before {\n content: \"\\e90a\" !important; }\n\n.ftinvwl-heart-mail:before {\n content: \"\\e90b\" !important; }\n\n.ftinvwl-heart-tinv:before {\n content: \"\\e90c\" !important; }\n\n.ftinvwl-key:before {\n content: \"\\e90d\" !important; }\n\n.ftinvwl-lock:before {\n content: \"\\e90e\" !important; }\n\n.ftinvwl-hearts:before {\n content: \"\\e90f\" !important; }\n\n.ftinvwl-user:before {\n content: \"\\e910\" !important; }\n\n/* PULSE */\n@-webkit-keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n@keyframes ftinvwl-pulse {\n 0% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); }\n 50% {\n -webkit-transform: scale(0.8);\n transform: scale(0.8); }\n 100% {\n -webkit-transform: scale(1.1);\n transform: scale(1.1); } }\n\n.ftinvwl-pulse.ftinvwl-animated::before {\n -webkit-animation: ftinvwl-pulse 2s linear infinite;\n animation: ftinvwl-pulse 2s linear infinite; }\n"]}
assets/css/webfont.min.css CHANGED
@@ -1,9 +1,9 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
- @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
7
  .ftinvwl{font-family:'tinvwl-webfont' !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
8
  .ftinvwl-twitter:before{content:"\f099" !important}
9
  .ftinvwl-facebook:before{content:"\f09a" !important}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
+ @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
7
  .ftinvwl{font-family:'tinvwl-webfont' !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
8
  .ftinvwl-twitter:before{content:"\f099" !important}
9
  .ftinvwl-facebook:before{content:"\f09a" !important}
assets/fonts/tinvwl-webfont.woff2 ADDED
Binary file
assets/js/admin.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
assets/js/public.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.10
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=c("<ul>");c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(t))}}};i.onActionProduct=function(t,i){var r={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,o=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),o.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){o.push(c(this))}),o.length||o.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),c.each(o,function(t,i){c(i).find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=n,n=l}t=a[1],o--}if("file"===i){var s=c(this)[0].files;s&&d.append(t,s[0])}"checkbox"===i||"radio"===i?c(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),r.form[t]=e(r.form[t],n)):r.form[t]=e(r.form[t],n)}})}),r=e.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:e.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(e.class.select).eq(0);c(this).find(e.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),c(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(e.class.select),n=c(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}c(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},c(document).ready(function(){c("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n=JSON.parse(i.attr("data-tinv-wl-list")),o=!1,e="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var a in n)n[a].hasOwnProperty("in")&&Array.isArray(n[a].in)&&-1<(n[a].in||[]).indexOf(0)&&(o=!0);i.toggleClass("tinvwl-product-in-list",o).toggleClass("tinvwl-product-make-remove",o&&e).attr("data-tinv-wl-action",o&&e?"remove":"addto")}i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),c(document).on("show_variation",".variations_form",function(t,i,n){var o=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(o.attr("data-tinv-wl-productvariation",i.variation_id),o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(a=!0);o.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){if(s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&localStorage.getItem(s)){var i=JSON.parse(localStorage.getItem(s));"object"===_typeof(i)&&null!==i&&(i.hasOwnProperty("products")||i.hasOwnProperty("counter"))&&d(localStorage.getItem(s))}});var n=[],i=!1;c("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))}),c(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.plugin_url+"includes/api/ajax.php",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)}).fail(function(){!function(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)})}}()})}}function e(){if(l&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(s,""),localStorage.getItem(s))){var t=JSON.parse(localStorage.getItem(s));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void r(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||o()}e();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&c(i).each(function(){var t=c(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))})})}),n.length&&e()}),a=document.body;t.observe(a,{childList:!0,subtree:!0})});var l=!0,s=tinvwl_add_to_wishlist.hash_key;try{l="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){l=!1}function r(t){var l="1"==window.tinvwl_add_to_wishlist.simple_flow;l&&c("a.tinvwl_add_to_wishlist_button").each(function(){c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]")}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,e){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var t=parseInt(c(this).attr("data-tinv-wl-productvariation")),i=c(this).data("tinv-wl-productvariations")||[],n=!1;for(var o in e)e[o].hasOwnProperty("in")&&Array.isArray(e[o].in)&&(-1<(e[o].in||[]).indexOf(a)||-1<(e[o].in||[]).indexOf(t)||i.some(function(t){return 0<=(e[o].in||[]).indexOf(t)}))&&(n=!0);c("body").trigger("tinvwl_wishlist_product_marked",[this,n]),c(this).attr("data-tinv-wl-list",JSON.stringify(e)).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&l).attr("data-tinv-wl-action",n&&l?"remove":"addto")})}),function(t){"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===t&&(t="false");jQuery("i.wishlist-icon").addClass("added"),"false"!==t?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t),jQuery("i.wishlist-icon").attr("data-icon-label",t)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label"));var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}(t.counter)}function d(t){l&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),r(JSON.parse(t)))}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o(this).html().trim().length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open"),o("body").trigger("tinvwl_modal_closed",[this])}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").off("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.24.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=c("<ul>");c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(t))}}};i.onActionProduct=function(t,i){var r={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,o=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),o.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){o.push(c(this))}),o.length||o.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),c.each(o,function(t,i){c(i).find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=n,n=l}t=a[1],o--}if("file"===i){var s=c(this)[0].files;s&&d.append(t,s[0])}"checkbox"===i||"radio"===i?c(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),r.form[t]=e(r.form[t],n)):r.form[t]=e(r.form[t],n)}})}),r=e.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:e.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(e.class.select).eq(0);c(this).find(e.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),c(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(e.class.select),n=c(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}c(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},c(document).ready(function(){c("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n=JSON.parse(i.attr("data-tinv-wl-list")),o=!1,e="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var a in n)n[a].hasOwnProperty("in")&&Array.isArray(n[a].in)&&-1<(n[a].in||[]).indexOf(0)&&(o=!0);i.toggleClass("tinvwl-product-in-list",o).toggleClass("tinvwl-product-make-remove",o&&e).attr("data-tinv-wl-action",o&&e?"remove":"addto")}i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),c(document).on("show_variation",".variations_form",function(t,i,n){var o=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(o.attr("data-tinv-wl-productvariation",i.variation_id),o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(a=!0);o.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){if(s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&localStorage.getItem(s)){var i=JSON.parse(localStorage.getItem(s));"object"===_typeof(i)&&null!==i&&(i.hasOwnProperty("products")||i.hasOwnProperty("counter"))&&d(localStorage.getItem(s))}});var n=[],i=!1;c("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))}),c(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.plugin_url+"includes/api/ajax.php",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)}).fail(function(){!function(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)})}}()})}}function e(){if(l&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(s,""),localStorage.getItem(s))){var t=JSON.parse(localStorage.getItem(s));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void r(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||o()}e();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&c(i).each(function(){var t=c(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))})})}),n.length&&e()}),a=document.body;t.observe(a,{childList:!0,subtree:!0})});var l=!0,s=tinvwl_add_to_wishlist.hash_key;try{l="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){l=!1}function r(t){var l="1"==window.tinvwl_add_to_wishlist.simple_flow;l&&c("a.tinvwl_add_to_wishlist_button").each(function(){c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]")}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,e){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var t=parseInt(c(this).attr("data-tinv-wl-productvariation")),i=c(this).data("tinv-wl-productvariations")||[],n=!1;for(var o in e)e[o].hasOwnProperty("in")&&Array.isArray(e[o].in)&&(-1<(e[o].in||[]).indexOf(a)||-1<(e[o].in||[]).indexOf(t)||i.some(function(t){return 0<=(e[o].in||[]).indexOf(t)}))&&(n=!0);c("body").trigger("tinvwl_wishlist_product_marked",[this,n]),c(this).attr("data-tinv-wl-list",JSON.stringify(e)).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&l).attr("data-tinv-wl-action",n&&l?"remove":"addto")})}),function(t){"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===t&&(t="false");jQuery("i.wishlist-icon").addClass("added"),"false"!==t?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t),jQuery("i.wishlist-icon").attr("data-icon-label",t)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label"));var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}(t.counter)}function d(t){l&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),r(JSON.parse(t)))}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o(this).html().trim().length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open"),o("body").trigger("tinvwl_modal_closed",[this])}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").off("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
integrations/advanced-product-fields-for-woocommerce-pro.php CHANGED
@@ -13,9 +13,30 @@
13
  */
14
 
15
  // If this file is called directly, abort.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- if ( ! defined( 'ABSPATH' ) ) {
18
- die;
19
  }
20
 
21
  use SW_WAPF_PRO\Includes\Classes\Enumerable;
@@ -24,50 +45,51 @@ use SW_WAPF_PRO\Includes\Classes\Fields;
24
  use SW_WAPF_PRO\Includes\Classes\Helper;
25
  use SW_WAPF_PRO\Includes\Classes\Cart;
26
 
27
- if ( class_exists( 'SW_WAPF_PRO\WAPF' ) ) {
28
 
29
  $wapf_ti_cartfield_cache = array();
30
 
31
- if ( ! function_exists( 'tinv_wishlist_item_meta_wapf' ) ) {
32
 
33
- function tinv_wishlist_item_meta_wapf( $item_data, $product_id, $variation_id ) {
 
34
  global $wapf_ti_cartfield_cache;
35
 
36
- if ( class_exists( 'SW_WAPF_PRO\WAPF' ) ) {
37
 
38
- if ( empty( $item_data['wapf'] ) || ! is_array( $item_data['wapf'] ) || ! isset( $item_data['wapf_field_groups'] ) ) {
39
  return $item_data;
40
  }
41
 
42
- $field_groups = SW_WAPF_PRO\Includes\Classes\Field_Groups::get_by_ids( explode( ',', sanitize_text_field( $item_data['wapf_field_groups']['display'] ) ) );
43
 
44
- $fields = SW_WAPF_PRO\Includes\Classes\Enumerable::from( $field_groups )->merge( function ( $x ) {
45
  return $x->fields;
46
- } )->toArray();
47
 
48
- foreach ( $item_data['wapf']['display'] as $key => $field ) {
49
 
50
- if ( empty( $field ) ) {
51
  continue;
52
  }
53
- $field_id = str_replace( 'field_', '', $key );
54
 
55
- $field_obj = SW_WAPF_PRO\Includes\Classes\Enumerable::from( $fields )->firstOrDefault( function ( $x ) use ( $field_id ) {
56
  return $x->id === $field_id;
57
- } );
58
 
59
- $cartitem = Cart::to_cart_item_field( $field_obj, 0, $field );
60
  $wapf_ti_cartfield_cache[] = $cartitem;
61
 
62
- $item_data[ $key ] = array(
63
- 'key' => $field_obj->label,
64
- 'display' => Helper::values_to_string( $cartitem, '' )
65
  );
66
  }
67
 
68
- foreach ( array_keys( $item_data ) as $key ) {
69
- if ( strpos( $key, 'wapf' ) === 0 ) {
70
- unset( $item_data[ $key ] );
71
  }
72
  }
73
 
@@ -76,63 +98,65 @@ if ( class_exists( 'SW_WAPF_PRO\WAPF' ) ) {
76
  return $item_data;
77
  }
78
 
79
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_wapf', 10, 3 );
80
  }
81
 
82
- if ( ! function_exists( 'tinvwl_calc_wapf_option_price' ) ) {
83
- function tinvwl_calc_wapf_option_price( $price, $wl_product, $product ) {
 
84
  global $wapf_ti_cartfield_cache;
85
 
86
  $options_total = 0;
87
 
88
- $quantity = empty( $wl_product['quantity'] ) ? 1 : wc_stock_amount( $wl_product['quantity'] );
89
- if(wc_prices_include_tax())
90
  $price = wc_get_price_including_tax($product);
91
  else $price = wc_get_price_excluding_tax($product);
92
 
93
  $base = apply_filters('wapf/pricing/base', $price, $product, $quantity);
94
 
95
- if ( ! empty( $wapf_ti_cartfield_cache ) ) {
96
- foreach ( $wapf_ti_cartfield_cache as $cart_field ) {
97
- foreach ( $cart_field['values'] as $value ) {
98
- if ( $value['price'] === 0 || $value['price_type'] === 'none' ) {
99
  continue;
100
  }
101
 
102
- $v = isset( $value['slug'] ) ? $value['label'] : $cart_field['raw'];
103
  $field_ids = array();
104
- if ( isset( $wl_product['meta']['wapf_field_groups'] ) ) {
105
- $field_ids = explode( ',', $wl_product['meta']['wapf_field_groups'] );
106
  }
107
 
108
- $n_price = Fields::do_pricing( $cart_field['qty_based'], $value['price_type'], $value['price'], $base, $quantity, $v, $product->get_id(), $wapf_ti_cartfield_cache, $field_ids, 0 );
109
  $options_total = $options_total + $n_price;
110
  }
111
  }
112
  }
113
 
114
  $wapf_ti_cartfield_cache = [];
115
- if ( $options_total > 0 ) {
116
- return wc_price( $base + $options_total );
117
  }
118
 
119
  return $price;
120
  }
121
 
122
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_calc_wapf_option_price', 10, 3 );
123
  }
124
 
125
- if ( ! function_exists( 'tinv_wishlist_metaprepare_wapf' ) ) {
126
- function tinv_wishlist_metaprepare_wapf( $meta ) {
127
- foreach ( $meta as $key => $value ) {
128
- if ( 'wapf' === $key && ! is_array( $value ) ) {
129
- $meta[ $key ] = json_decode( $value );
 
130
  }
131
  }
132
 
133
  return $meta;
134
  }
135
 
136
- add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_wapf' );
137
  }
138
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "advanced-product-fields-for-woocommerce-pro";
24
+
25
+ $name = "Advanced Product Fields for WooCommerce Pro";
26
+
27
+ $available = class_exists('SW_WAPF_PRO');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
 
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  use SW_WAPF_PRO\Includes\Classes\Enumerable;
45
  use SW_WAPF_PRO\Includes\Classes\Helper;
46
  use SW_WAPF_PRO\Includes\Classes\Cart;
47
 
48
+ if (class_exists('SW_WAPF_PRO\WAPF')) {
49
 
50
  $wapf_ti_cartfield_cache = array();
51
 
52
+ if (!function_exists('tinv_wishlist_item_meta_wapf')) {
53
 
54
+ function tinv_wishlist_item_meta_wapf($item_data, $product_id, $variation_id)
55
+ {
56
  global $wapf_ti_cartfield_cache;
57
 
58
+ if (class_exists('SW_WAPF_PRO\WAPF')) {
59
 
60
+ if (empty($item_data['wapf']) || !is_array($item_data['wapf']) || !isset($item_data['wapf_field_groups'])) {
61
  return $item_data;
62
  }
63
 
64
+ $field_groups = SW_WAPF_PRO\Includes\Classes\Field_Groups::get_by_ids(explode(',', sanitize_text_field($item_data['wapf_field_groups']['display'])));
65
 
66
+ $fields = SW_WAPF_PRO\Includes\Classes\Enumerable::from($field_groups)->merge(function ($x) {
67
  return $x->fields;
68
+ })->toArray();
69
 
70
+ foreach ($item_data['wapf']['display'] as $key => $field) {
71
 
72
+ if (empty($field)) {
73
  continue;
74
  }
75
+ $field_id = str_replace('field_', '', $key);
76
 
77
+ $field_obj = SW_WAPF_PRO\Includes\Classes\Enumerable::from($fields)->firstOrDefault(function ($x) use ($field_id) {
78
  return $x->id === $field_id;
79
+ });
80
 
81
+ $cartitem = Cart::to_cart_item_field($field_obj, 0, $field);
82
  $wapf_ti_cartfield_cache[] = $cartitem;
83
 
84
+ $item_data[$key] = array(
85
+ 'key' => $field_obj->label,
86
+ 'display' => Helper::values_to_string($cartitem, '')
87
  );
88
  }
89
 
90
+ foreach (array_keys($item_data) as $key) {
91
+ if (strpos($key, 'wapf') === 0) {
92
+ unset($item_data[$key]);
93
  }
94
  }
95
 
98
  return $item_data;
99
  }
100
 
101
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_wapf', 10, 3);
102
  }
103
 
104
+ if (!function_exists('tinvwl_calc_wapf_option_price')) {
105
+ function tinvwl_calc_wapf_option_price($price, $wl_product, $product)
106
+ {
107
  global $wapf_ti_cartfield_cache;
108
 
109
  $options_total = 0;
110
 
111
+ $quantity = empty($wl_product['quantity']) ? 1 : wc_stock_amount($wl_product['quantity']);
112
+ if (wc_prices_include_tax())
113
  $price = wc_get_price_including_tax($product);
114
  else $price = wc_get_price_excluding_tax($product);
115
 
116
  $base = apply_filters('wapf/pricing/base', $price, $product, $quantity);
117
 
118
+ if (!empty($wapf_ti_cartfield_cache)) {
119
+ foreach ($wapf_ti_cartfield_cache as $cart_field) {
120
+ foreach ($cart_field['values'] as $value) {
121
+ if ($value['price'] === 0 || $value['price_type'] === 'none') {
122
  continue;
123
  }
124
 
125
+ $v = isset($value['slug']) ? $value['label'] : $cart_field['raw'];
126
  $field_ids = array();
127
+ if (isset($wl_product['meta']['wapf_field_groups'])) {
128
+ $field_ids = explode(',', $wl_product['meta']['wapf_field_groups']);
129
  }
130
 
131
+ $n_price = Fields::do_pricing($cart_field['qty_based'], $value['price_type'], $value['price'], $base, $quantity, $v, $product->get_id(), $wapf_ti_cartfield_cache, $field_ids, 0);
132
  $options_total = $options_total + $n_price;
133
  }
134
  }
135
  }
136
 
137
  $wapf_ti_cartfield_cache = [];
138
+ if ($options_total > 0) {
139
+ return wc_price($base + $options_total);
140
  }
141
 
142
  return $price;
143
  }
144
 
145
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_calc_wapf_option_price', 10, 3);
146
  }
147
 
148
+ if (!function_exists('tinv_wishlist_metaprepare_wapf')) {
149
+ function tinv_wishlist_metaprepare_wapf($meta)
150
+ {
151
+ foreach ($meta as $key => $value) {
152
+ if ('wapf' === $key && !is_array($value)) {
153
+ $meta[$key] = json_decode($value);
154
  }
155
  }
156
 
157
  return $meta;
158
  }
159
 
160
+ add_filter('tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_wapf');
161
  }
162
  }
integrations/advanced-product-fields-for-woocommerce.php CHANGED
@@ -13,9 +13,30 @@
13
  */
14
 
15
  // If this file is called directly, abort.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- if ( ! defined( 'ABSPATH' ) ) {
18
- die;
19
  }
20
 
21
  use SW_WAPF\Includes\Classes\Enumerable;
@@ -23,7 +44,7 @@ use SW_WAPF\Includes\Classes\Field_Groups;
23
  use SW_WAPF\Includes\Classes\Fields;
24
  use SW_WAPF\Includes\Classes\Helper;
25
 
26
- if ( ! function_exists( 'tinv_wishlist_item_meta_wapf' ) ) {
27
 
28
  /**
29
  * Set description for meta Advanced Product Fields (Product Options) for WooCommerce
@@ -35,44 +56,45 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_wapf' ) ) {
35
  * @return array
36
  */
37
 
38
- function tinv_wishlist_item_meta_wapf( $item_data, $product_id, $variation_id ) {
39
- if ( class_exists( 'SW_WAPF\WAPF' ) ) {
 
40
 
41
- if ( empty( $item_data['wapf'] ) || ! is_array( $item_data['wapf'] ) || ! isset( $item_data['wapf_field_groups'] ) ) {
42
  return $item_data;
43
  }
44
 
45
- $field_groups = SW_WAPF\Includes\Classes\Field_Groups::get_by_ids( explode( ',', sanitize_text_field( $item_data['wapf_field_groups']['display'] ) ) );
46
 
47
- $fields = SW_WAPF\Includes\Classes\Enumerable::from( $field_groups )->merge( function ( $x ) {
48
  return $x->fields;
49
- } )->toArray();
50
 
51
- foreach ( $item_data['wapf']['display'] as $key => $field ) {
52
- if ( empty( $field ) ) {
53
  continue;
54
  }
55
- $field_id = str_replace( 'field_', '', $key );
56
 
57
- $field_obj = SW_WAPF\Includes\Classes\Enumerable::from( $fields )->firstOrDefault( function ( $x ) use ( $field_id ) {
58
  return $x->id === $field_id;
59
- } );
60
- $product = wc_get_product( $product_id );
61
  $price_addition = array();
62
 
63
- if ( $field_obj->pricing_enabled() ) {
64
- $price_addition = SW_WAPF\Includes\Classes\Fields::pricing_value( $field_obj, $field );
65
  }
66
 
67
- $item_data[ $key ] = array(
68
- 'key' => $field_obj->label,
69
- 'display' => SW_WAPF\Includes\Classes\Fields::value_to_string( $field_obj, $field, $price_addition > 0, $product, 'cart' ),
70
  );
71
  }
72
 
73
- foreach ( array_keys( $item_data ) as $key ) {
74
- if ( strpos( $key, 'wapf' ) === 0 ) {
75
- unset( $item_data[ $key ] );
76
  }
77
  }
78
 
@@ -81,10 +103,10 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_wapf' ) ) {
81
  return $item_data;
82
  }
83
 
84
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_wapf', 10, 3 );
85
  }
86
 
87
- if ( ! function_exists( 'tinvwl_item_price_wapf' ) ) {
88
 
89
  /**
90
  * Modify price for Advanced Product Fields (Product Options) for WooCommerce
@@ -95,54 +117,55 @@ if ( ! function_exists( 'tinvwl_item_price_wapf' ) ) {
95
  *
96
  * @return string
97
  */
98
- function tinvwl_item_price_wapf( $price, $wl_product, $product ) {
 
99
 
100
- if ( class_exists( 'SW_WAPF\WAPF' ) ) {
101
 
102
- if ( empty( $wl_product['meta'] ) || empty( $wl_product['meta']['wapf'] ) || ! is_array( $wl_product['meta']['wapf'] ) || ! isset( $wl_product['meta']['wapf_field_groups'] ) ) {
103
  return $price;
104
  }
105
 
106
- $field_groups = SW_WAPF\Includes\Classes\Field_Groups::get_by_ids( explode( ',', sanitize_text_field( $wl_product['meta']['wapf_field_groups'] ) ) );
107
 
108
- $fields = SW_WAPF\Includes\Classes\Enumerable::from( $field_groups )->merge( function ( $x ) {
109
  return $x->fields;
110
- } )->toArray();
111
 
112
- $quantity = empty( $wl_product['quantity'] ) ? 1 : wc_stock_amount( $wl_product['quantity'] );
113
 
114
- $base = SW_WAPF\Includes\Classes\Helper::get_product_base_price( $product );
115
  $options_total = 0;
116
 
117
- foreach ( $wl_product['meta']['wapf'] as $key => $field ) {
118
 
119
- $field_id = str_replace( 'field_', '', $key );
120
 
121
- $field_obj = SW_WAPF\Includes\Classes\Enumerable::from( $fields )->firstOrDefault( function ( $x ) use ( $field_id ) {
122
  return $x->id === $field_id;
123
- } );
124
 
125
  $price_addition = array();
126
 
127
- if ( $field_obj->pricing_enabled() ) {
128
- $price_addition = SW_WAPF\Includes\Classes\Fields::pricing_value( $field_obj, $field );
129
  }
130
 
131
- if ( ! empty( $price_addition ) ) {
132
- foreach ( $price_addition as $price ) {
133
 
134
- if ( $price['value'] === 0 ) {
135
  continue;
136
  }
137
 
138
- $options_total = $options_total + SW_WAPF\Includes\Classes\Fields::do_pricing( $price['value'], $quantity );
139
 
140
  }
141
  }
142
  }
143
 
144
- if ( $options_total > 0 ) {
145
- return wc_price( $base + $options_total );
146
  }
147
 
148
  }
@@ -150,10 +173,10 @@ if ( ! function_exists( 'tinvwl_item_price_wapf' ) ) {
150
  return $price;
151
  }
152
 
153
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_wapf', 10, 3 );
154
  } // End if().
155
 
156
- if ( ! function_exists( 'tinv_wishlist_metaprepare_wapf' ) ) {
157
 
158
  /**
159
  * Prepare save meta for Advanced Product Fields (Product Options) for WooCommerce
@@ -162,17 +185,18 @@ if ( ! function_exists( 'tinv_wishlist_metaprepare_wapf' ) ) {
162
  *
163
  * @return array
164
  */
165
- function tinv_wishlist_metaprepare_wapf( $meta ) {
 
166
 
167
- foreach ( $meta as $key => $value ) {
168
- if ( 'wapf' === $key && ! is_array( $value ) ) {
169
 
170
- $meta[ $key ] = json_decode( $value );
171
  }
172
  }
173
 
174
  return $meta;
175
  }
176
 
177
- add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_wapf' );
178
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "advanced-product-fields-for-woocommerce";
24
+
25
+ $name = "Advanced Product Fields (Product Addons) for WooCommerce";
26
+
27
+ $available = class_exists('SW_WAPF');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
 
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  use SW_WAPF\Includes\Classes\Enumerable;
44
  use SW_WAPF\Includes\Classes\Fields;
45
  use SW_WAPF\Includes\Classes\Helper;
46
 
47
+ if (!function_exists('tinv_wishlist_item_meta_wapf')) {
48
 
49
  /**
50
  * Set description for meta Advanced Product Fields (Product Options) for WooCommerce
56
  * @return array
57
  */
58
 
59
+ function tinv_wishlist_item_meta_wapf($item_data, $product_id, $variation_id)
60
+ {
61
+ if (class_exists('SW_WAPF\WAPF')) {
62
 
63
+ if (empty($item_data['wapf']) || !is_array($item_data['wapf']) || !isset($item_data['wapf_field_groups'])) {
64
  return $item_data;
65
  }
66
 
67
+ $field_groups = SW_WAPF\Includes\Classes\Field_Groups::get_by_ids(explode(',', sanitize_text_field($item_data['wapf_field_groups']['display'])));
68
 
69
+ $fields = SW_WAPF\Includes\Classes\Enumerable::from($field_groups)->merge(function ($x) {
70
  return $x->fields;
71
+ })->toArray();
72
 
73
+ foreach ($item_data['wapf']['display'] as $key => $field) {
74
+ if (empty($field)) {
75
  continue;
76
  }
77
+ $field_id = str_replace('field_', '', $key);
78
 
79
+ $field_obj = SW_WAPF\Includes\Classes\Enumerable::from($fields)->firstOrDefault(function ($x) use ($field_id) {
80
  return $x->id === $field_id;
81
+ });
82
+ $product = wc_get_product($product_id);
83
  $price_addition = array();
84
 
85
+ if ($field_obj->pricing_enabled()) {
86
+ $price_addition = SW_WAPF\Includes\Classes\Fields::pricing_value($field_obj, $field);
87
  }
88
 
89
+ $item_data[$key] = array(
90
+ 'key' => $field_obj->label,
91
+ 'display' => SW_WAPF\Includes\Classes\Fields::value_to_string($field_obj, $field, $price_addition > 0, $product, 'cart'),
92
  );
93
  }
94
 
95
+ foreach (array_keys($item_data) as $key) {
96
+ if (strpos($key, 'wapf') === 0) {
97
+ unset($item_data[$key]);
98
  }
99
  }
100
 
103
  return $item_data;
104
  }
105
 
106
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_wapf', 10, 3);
107
  }
108
 
109
+ if (!function_exists('tinvwl_item_price_wapf')) {
110
 
111
  /**
112
  * Modify price for Advanced Product Fields (Product Options) for WooCommerce
117
  *
118
  * @return string
119
  */
120
+ function tinvwl_item_price_wapf($price, $wl_product, $product)
121
+ {
122
 
123
+ if (class_exists('SW_WAPF\WAPF')) {
124
 
125
+ if (empty($wl_product['meta']) || empty($wl_product['meta']['wapf']) || !is_array($wl_product['meta']['wapf']) || !isset($wl_product['meta']['wapf_field_groups'])) {
126
  return $price;
127
  }
128
 
129
+ $field_groups = SW_WAPF\Includes\Classes\Field_Groups::get_by_ids(explode(',', sanitize_text_field($wl_product['meta']['wapf_field_groups'])));
130
 
131
+ $fields = SW_WAPF\Includes\Classes\Enumerable::from($field_groups)->merge(function ($x) {
132
  return $x->fields;
133
+ })->toArray();
134
 
135
+ $quantity = empty($wl_product['quantity']) ? 1 : wc_stock_amount($wl_product['quantity']);
136
 
137
+ $base = SW_WAPF\Includes\Classes\Helper::get_product_base_price($product);
138
  $options_total = 0;
139
 
140
+ foreach ($wl_product['meta']['wapf'] as $key => $field) {
141
 
142
+ $field_id = str_replace('field_', '', $key);
143
 
144
+ $field_obj = SW_WAPF\Includes\Classes\Enumerable::from($fields)->firstOrDefault(function ($x) use ($field_id) {
145
  return $x->id === $field_id;
146
+ });
147
 
148
  $price_addition = array();
149
 
150
+ if ($field_obj->pricing_enabled()) {
151
+ $price_addition = SW_WAPF\Includes\Classes\Fields::pricing_value($field_obj, $field);
152
  }
153
 
154
+ if (!empty($price_addition)) {
155
+ foreach ($price_addition as $price) {
156
 
157
+ if ($price['value'] === 0) {
158
  continue;
159
  }
160
 
161
+ $options_total = $options_total + SW_WAPF\Includes\Classes\Fields::do_pricing($price['value'], $quantity);
162
 
163
  }
164
  }
165
  }
166
 
167
+ if ($options_total > 0) {
168
+ return wc_price($base + $options_total);
169
  }
170
 
171
  }
173
  return $price;
174
  }
175
 
176
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_wapf', 10, 3);
177
  } // End if().
178
 
179
+ if (!function_exists('tinv_wishlist_metaprepare_wapf')) {
180
 
181
  /**
182
  * Prepare save meta for Advanced Product Fields (Product Options) for WooCommerce
185
  *
186
  * @return array
187
  */
188
+ function tinv_wishlist_metaprepare_wapf($meta)
189
+ {
190
 
191
+ foreach ($meta as $key => $value) {
192
+ if ('wapf' === $key && !is_array($value)) {
193
 
194
+ $meta[$key] = json_decode($value);
195
  }
196
  }
197
 
198
  return $meta;
199
  }
200
 
201
+ add_filter('tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_wapf');
202
  }
integrations/automatewoo.php CHANGED
@@ -13,41 +13,67 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- add_filter( 'automatewoo/triggers', 'tinvwl_automatewoo_triggers' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * @param array $triggers
24
  *
25
  * @return array
26
  */
27
- function tinvwl_automatewoo_triggers( $triggers ) {
28
-
29
- // AutomateWoo Wishlist class
30
- include_once 'automatewoo/wishlist.class.php';
 
31
 
32
- // Trigger wishlist item added.
33
- include_once 'automatewoo/trigger-wishlist-item-added.php';
34
- $triggers['tinvwl_wishlist_item_added'] = 'TINVWL_Trigger_Wishlist_Item_Added';
35
 
36
- // Trigger wishlist reminder.
37
- include_once 'automatewoo/trigger-wishlist-reminder.php';
38
- $triggers['tinvwl_wishlist_reminder'] = 'TINVWL_Trigger_Wishlist_Reminder';
39
 
40
- // Trigger wishlist item added to cart.
41
- include_once 'automatewoo/trigger-wishlist-item-added-to-cart.php';
42
- $triggers['tinvwl_wishlist_item_added_to_cart'] = 'TINVWL_Trigger_Wishlist_Item_Added_To_Cart';
43
 
44
- // Trigger wishlist item purchased.
45
- include_once 'automatewoo/trigger-wishlist-item-purchased.php';
46
- $triggers['tinvwl_wishlist_item_purchased'] = 'TINVWL_Trigger_Wishlist_Item_Purchased';
47
 
48
- // Trigger wishlist item removed.
49
- include_once 'automatewoo/trigger-wishlist-item-removed.php';
50
- $triggers['tinvwl_wishlist_item_removed'] = 'TINVWL_Trigger_Wishlist_Item_Removed';
 
51
 
 
 
52
  return $triggers;
53
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "automatewoo";
24
+
25
+ $name = "AutomateWoo";
26
+
27
+ $available = class_exists('AutomateWoo');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ add_filter('automatewoo/triggers', 'tinvwl_automatewoo_triggers');
43
 
44
  /**
45
  * @param array $triggers
46
  *
47
  * @return array
48
  */
49
+ function tinvwl_automatewoo_triggers($triggers)
50
+ {
51
+ try {
52
+ // AutomateWoo Wishlist class
53
+ include_once 'automatewoo/wishlist.class.php';
54
 
55
+ // Trigger wishlist item added.
56
+ include_once 'automatewoo/trigger-wishlist-item-added.php';
57
+ $triggers['tinvwl_wishlist_item_added'] = 'TINVWL_Trigger_Wishlist_Item_Added';
58
 
59
+ // Trigger wishlist reminder.
60
+ include_once 'automatewoo/trigger-wishlist-reminder.php';
61
+ $triggers['tinvwl_wishlist_reminder'] = 'TINVWL_Trigger_Wishlist_Reminder';
62
 
63
+ // Trigger wishlist item added to cart.
64
+ include_once 'automatewoo/trigger-wishlist-item-added-to-cart.php';
65
+ $triggers['tinvwl_wishlist_item_added_to_cart'] = 'TINVWL_Trigger_Wishlist_Item_Added_To_Cart';
66
 
67
+ // Trigger wishlist item purchased.
68
+ include_once 'automatewoo/trigger-wishlist-item-purchased.php';
69
+ $triggers['tinvwl_wishlist_item_purchased'] = 'TINVWL_Trigger_Wishlist_Item_Purchased';
70
 
71
+ // Trigger wishlist item removed.
72
+ include_once 'automatewoo/trigger-wishlist-item-removed.php';
73
+ $triggers['tinvwl_wishlist_item_removed'] = 'TINVWL_Trigger_Wishlist_Item_Removed';
74
+ } catch (Exception $e) {
75
 
76
+ error_log(print_r($e->getMessage(), true));
77
+ }
78
  return $triggers;
79
  }
integrations/check-pincodezipcode-for-shipping-woocommerce.php CHANGED
@@ -13,8 +13,30 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  if ( defined( 'WCZP_PLUGIN_NAME' ) ) {
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "check-pincodezipcode-for-shipping-woocommerce";
24
+
25
+ $name = "Check Pincode/Zipcode for Shipping Woocommerce";
26
+
27
+ $available = defined( 'WCZP_PLUGIN_NAME' );
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  if ( defined( 'WCZP_PLUGIN_NAME' ) ) {
integrations/clever-swatches.php CHANGED
@@ -1,74 +1,98 @@
1
- <?php
2
- /**
3
- * TI WooCommerce Wishlist integration with:
4
- *
5
- * @name Clever Swatches
6
- *
7
- * @version 2.1.6
8
- *
9
- * @slug clever-swatches
10
- *
11
- * @url https://codecanyon.net/item/cleverswatches-woocommerce-color-or-image-variation-swatches/20594889
12
- *
13
- */
14
-
15
- // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
- }
19
-
20
- if ( ! function_exists( 'tinv_wishlist_meta_support_clever_swatches' ) ) {
21
-
22
- /**
23
- * Set description for meta Improved Product Options for WooCommerce
24
- *
25
- * @param array $meta Meta array.
26
- *
27
- * @return array
28
- */
29
- function tinv_wishlist_meta_support_clever_swatches( $meta ) {
30
-
31
- if ( class_exists( 'Zoo_Clever_Swatch_Install' ) ) {
32
- if ( ! empty( $meta['old_variation_id'] ) ) {
33
- unset( $meta['old_variation_id'] );
34
- }
35
- }
36
-
37
- return $meta;
38
- }
39
-
40
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_clever_swatches' );
41
- } // End if().
42
-
43
- function tinv_add_to_wishlist_clever_swatches() {
44
- if ( class_exists( 'Zoo_Clever_Swatch_Install' ) ) {
45
-
46
- wp_add_inline_script( 'tinvwl', "
47
- jQuery(document).ready(function($){
48
- $(document).on('cleverswatch_update_gallery cleverswatch_update_cw_gallery',function (e, data) {
49
- if (data.product_id === data.variation_id){
50
- $(data.form_add_to_cart).trigger('hide_variation');
51
- } else {
52
- $(data.form_add_to_cart).trigger('show_variation', data, true);
53
- }
54
- });
55
- $(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
56
- var button = $(el);
57
-
58
- var wrapper = button.closest('div.tinv-wraper');
59
-
60
- if (wrapper.hasClass('tinvwl-loop-button-wrapper')){
61
-
62
- var container = wrapper.closest('*.product');
63
-
64
- if (container.find('a.add_to_cart_button').length > 0){
65
- data.form.variation_id = container.find('a.add_to_cart_button').data('variation_id');
66
- }
67
- }
68
- });
69
- });
70
- " );
71
- }
72
- }
73
-
74
- add_action( 'wp_enqueue_scripts', 'tinv_add_to_wishlist_clever_swatches', 100, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TI WooCommerce Wishlist integration with:
4
+ *
5
+ * @name Clever Swatches
6
+ *
7
+ * @version 2.1.6
8
+ *
9
+ * @slug clever-swatches
10
+ *
11
+ * @url https://codecanyon.net/item/cleverswatches-woocommerce-color-or-image-variation-swatches/20594889
12
+ *
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "clever-swatches";
24
+
25
+ $name = "Clever Swatches";
26
+
27
+ $available = class_exists('Zoo_Clever_Swatch_Install');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_meta_support_clever_swatches')) {
43
+
44
+ /**
45
+ * Set description for meta Improved Product Options for WooCommerce
46
+ *
47
+ * @param array $meta Meta array.
48
+ *
49
+ * @return array
50
+ */
51
+ function tinv_wishlist_meta_support_clever_swatches($meta)
52
+ {
53
+
54
+ if (class_exists('Zoo_Clever_Swatch_Install')) {
55
+ if (!empty($meta['old_variation_id'])) {
56
+ unset($meta['old_variation_id']);
57
+ }
58
+ }
59
+
60
+ return $meta;
61
+ }
62
+
63
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_clever_swatches');
64
+ } // End if().
65
+
66
+ function tinv_add_to_wishlist_clever_swatches()
67
+ {
68
+ if (class_exists('Zoo_Clever_Swatch_Install')) {
69
+
70
+ wp_add_inline_script('tinvwl', "
71
+ jQuery(document).ready(function($){
72
+ $(document).on('cleverswatch_update_gallery cleverswatch_update_cw_gallery',function (e, data) {
73
+ if (data.product_id === data.variation_id){
74
+ $(data.form_add_to_cart).trigger('hide_variation');
75
+ } else {
76
+ $(data.form_add_to_cart).trigger('show_variation', data, true);
77
+ }
78
+ });
79
+ $(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
80
+ var button = $(el);
81
+
82
+ var wrapper = button.closest('div.tinv-wraper');
83
+
84
+ if (wrapper.hasClass('tinvwl-loop-button-wrapper')){
85
+
86
+ var container = wrapper.closest('*.product');
87
+
88
+ if (container.find('a.add_to_cart_button').length > 0){
89
+ data.form.variation_id = container.find('a.add_to_cart_button').data('variation_id');
90
+ }
91
+ }
92
+ });
93
+ });
94
+ ");
95
+ }
96
+ }
97
+
98
+ add_action('wp_enqueue_scripts', 'tinv_add_to_wishlist_clever_swatches', 100, 1);
integrations/comet-cache.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( function_exists( 'tinvwl_comet_cache_reject' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set define disabled for Comet Cache
@@ -26,16 +48,17 @@ if ( function_exists( 'tinvwl_comet_cache_reject' ) ) {
26
  *
27
  * @return mixed
28
  */
29
- function tinvwl_comet_cache_reject( $data = '' ) {
30
- define( 'COMET_CACHE_ALLOWED', false );
 
31
 
32
  return $data;
33
  }
34
 
35
- add_filter( 'tinvwl_addtowishlist_return_ajax', 'tinvwl_comet_cache_reject' );
36
- add_action( 'tinvwl_before_action_owner', 'tinvwl_comet_cache_reject' );
37
- add_action( 'tinvwl_before_action_user', 'tinvwl_comet_cache_reject' );
38
- add_action( 'tinvwl_addproduct_tocart', 'tinvwl_comet_cache_reject' );
39
- add_action( 'tinvwl_wishlist_addtowishlist_button', 'tinvwl_comet_cache_reject' );
40
- add_action( 'tinvwl_wishlist_addtowishlist_dialogbox', 'tinvwl_comet_cache_reject' );
41
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "comet-cache";
24
+
25
+ $name = "Comet Cache";
26
+
27
+ $available = class_exists('WebSharks\CometCache');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (function_exists('tinvwl_comet_cache_reject')) {
43
 
44
  /**
45
  * Set define disabled for Comet Cache
48
  *
49
  * @return mixed
50
  */
51
+ function tinvwl_comet_cache_reject($data = '')
52
+ {
53
+ define('COMET_CACHE_ALLOWED', false);
54
 
55
  return $data;
56
  }
57
 
58
+ add_filter('tinvwl_addtowishlist_return_ajax', 'tinvwl_comet_cache_reject');
59
+ add_action('tinvwl_before_action_owner', 'tinvwl_comet_cache_reject');
60
+ add_action('tinvwl_before_action_user', 'tinvwl_comet_cache_reject');
61
+ add_action('tinvwl_addproduct_tocart', 'tinvwl_comet_cache_reject');
62
+ add_action('tinvwl_wishlist_addtowishlist_button', 'tinvwl_comet_cache_reject');
63
+ add_action('tinvwl_wishlist_addtowishlist_dialogbox', 'tinvwl_comet_cache_reject');
64
  }
integrations/duracelltomi-google-tag-manager.php CHANGED
@@ -13,12 +13,34 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  // Google Tag Manager for WordPress compatibility.
21
- if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
22
 
23
  /**
24
  * Prepare save meta for WooCommerce - Google Tag Manager for WordPress
@@ -27,16 +49,17 @@ if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
27
  *
28
  * @return array
29
  */
30
- function tinv_wishlist_metaprepare_gtm4wp( $meta ) {
 
31
 
32
- foreach ( array_keys( $meta ) as $key ) {
33
- if ( strpos( $key, 'gtm4wp_' ) === 0 ) {
34
- unset( $meta[ $key ] );
35
  }
36
  }
37
 
38
  return $meta;
39
  }
40
 
41
- add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_gtm4wp' );
42
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "duracelltomi-google-tag-manager";
24
+
25
+ $name = "Google Tag Manager for WordPress";
26
+
27
+ $available = defined('GTM4WP_PATH');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  // Google Tag Manager for WordPress compatibility.
43
+ if (!function_exists('tinv_wishlist_metaprepare_gtm4wp')) {
44
 
45
  /**
46
  * Prepare save meta for WooCommerce - Google Tag Manager for WordPress
49
  *
50
  * @return array
51
  */
52
+ function tinv_wishlist_metaprepare_gtm4wp($meta)
53
+ {
54
 
55
+ foreach (array_keys($meta) as $key) {
56
+ if (strpos($key, 'gtm4wp_') === 0) {
57
+ unset($meta[$key]);
58
  }
59
  }
60
 
61
  return $meta;
62
  }
63
 
64
+ add_filter('tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_gtm4wp');
65
  }
integrations/elex-woocommerce-catalog-mode.php CHANGED
@@ -13,38 +13,62 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
 
21
  /**
22
  * Run hooks on page redirect.
23
  */
24
- function tinvwl_elex_init() {
25
- if ( class_exists( 'Elex_CM_Price_Discount_Admin' ) ) {
 
26
 
27
  global $post;
28
- $product = wc_get_product( $post->ID );
29
- if ( ! empty( $product ) ) {
30
 
31
- if ( 'yes' == get_option( 'eh_pricing_discount_cart_catalog_mode' ) && 'yes' == get_option( 'elex_catalog_remove_addtocart_product' ) ) {
32
- if ( ! ( get_option( 'eh_pricing_discount_price_catalog_mode_exclude_admin' ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
33
- add_action( 'woocommerce_single_product_summary', 'tinvwl_elex_single_product_summary', 40 );
34
  }
35
- } elseif ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog', true ) ) && ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) || ( '' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) ) ) {
36
- if ( ! ( get_post_meta( $post->ID, 'product_adjustment_exclude_admin_catalog', true ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
37
- add_action( 'woocommerce_single_product_summary', 'tinvwl_elex_single_product_summary', 40 );
38
  }
39
  }
40
  }
41
  }
42
  }
43
 
44
- add_action( 'template_redirect', 'tinvwl_elex_init' );
45
 
46
  // Add a custom hook for single page.
47
- function tinvwl_elex_single_product_summary() {
48
- add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', '__return_true' );
49
- do_action( 'tinvwl_single_product_summary' );
 
50
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "elex-woocommerce-catalog-mode";
24
+
25
+ $name = "ELEX WooCommerce Catalog Mode";
26
+
27
+ $available = class_exists('Elex_CM_Price_Discount_Admin');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
 
43
  /**
44
  * Run hooks on page redirect.
45
  */
46
+ function tinvwl_elex_init()
47
+ {
48
+ if (class_exists('Elex_CM_Price_Discount_Admin')) {
49
 
50
  global $post;
51
+ $product = wc_get_product($post->ID);
52
+ if (!empty($product)) {
53
 
54
+ if ('yes' == get_option('eh_pricing_discount_cart_catalog_mode') && 'yes' == get_option('elex_catalog_remove_addtocart_product')) {
55
+ if (!(get_option('eh_pricing_discount_price_catalog_mode_exclude_admin') == 'yes' && in_array('administrator', (array)wp_get_current_user()->roles))) {
56
+ add_action('woocommerce_single_product_summary', 'tinvwl_elex_single_product_summary', 40);
57
  }
58
+ } elseif (('yes' == get_post_meta($post->ID, 'product_adjustment_hide_addtocart_catalog', true)) && (('yes' == get_post_meta($post->ID, 'product_adjustment_hide_addtocart_catalog_product', true)) || ('' == get_post_meta($post->ID, 'product_adjustment_hide_addtocart_catalog_product', true)))) {
59
+ if (!(get_post_meta($post->ID, 'product_adjustment_exclude_admin_catalog', true) == 'yes' && in_array('administrator', (array)wp_get_current_user()->roles))) {
60
+ add_action('woocommerce_single_product_summary', 'tinvwl_elex_single_product_summary', 40);
61
  }
62
  }
63
  }
64
  }
65
  }
66
 
67
+ add_action('template_redirect', 'tinvwl_elex_init');
68
 
69
  // Add a custom hook for single page.
70
+ function tinvwl_elex_single_product_summary()
71
+ {
72
+ add_filter('tinvwl_allow_addtowishlist_single_product_summary', '__return_true');
73
+ do_action('tinvwl_single_product_summary');
74
  }
integrations/gift-cards-for-woocommerce.php CHANGED
@@ -1,144 +1,170 @@
1
- <?php
2
- /**
3
- * TI WooCommerce Wishlist integration with:
4
- *
5
- * @name WooCommerce – Gift Cards
6
- *
7
- * @version 2.6.5
8
- *
9
- * @slug gift-cards-for-woocommerce
10
- *
11
- * @url https://wordpress.org/plugins/gift-cards-for-woocommerce/
12
- *
13
- */
14
-
15
- // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
- }
19
-
20
- if ( ! function_exists( 'tinvwl_gift_card_add' ) ) {
21
-
22
- /**
23
- * Support WooCommerce - Gift Cards
24
- * Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
25
- *
26
- * @param boolean $redirect Default value to redirect.
27
- * @param \WC_Product $product Product data.
28
- *
29
- * @return boolean
30
- */
31
- function tinvwl_gift_card_add( $redirect, $product ) {
32
- if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
33
- $is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
34
-
35
- if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
36
- $is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
37
- if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
38
- return true;
39
- }
40
- }
41
- }
42
-
43
- return $redirect;
44
- }
45
-
46
- add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_gift_card_add', 20, 2 );
47
- }
48
-
49
- if ( ! function_exists( 'tinvwl_gift_card_add_url' ) ) {
50
-
51
- /**
52
- * Support WooCommerce - Gift Cards
53
- * Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
54
- *
55
- * @param string $redirect_url Default value to redirect.
56
- * @param \WC_Product $product Product data.
57
- *
58
- * @return boolean
59
- */
60
- function tinvwl_gift_card_add_url( $redirect_url, $product ) {
61
- if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
62
- $is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
63
-
64
- if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
65
- $is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
66
- if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
67
- return $product->get_permalink();
68
- }
69
- }
70
- }
71
-
72
- return $redirect_url;
73
- }
74
-
75
- add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinvwl_gift_card_add_url', 20, 2 );
76
- }
77
-
78
- if ( ! function_exists( 'tinv_wishlist_meta_support_rpgiftcards' ) ) {
79
-
80
- /**
81
- * Set description for meta WooCommerce - Gift Cards
82
- *
83
- * @param array $meta Meta array.
84
- *
85
- * @return array
86
- */
87
- function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
88
- if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
89
- foreach ( $meta as $key => $data ) {
90
- switch ( $data['key'] ) {
91
- case 'rpgc_note':
92
- $meta[ $key ]['key'] = __( 'Note', 'ti-woocommerce-wishlist' );
93
- break;
94
- case 'rpgc_to':
95
- $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
96
- break;
97
- case 'rpgc_to_email':
98
- $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
99
- break;
100
- case 'rpgc_address':
101
- $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
102
- break;
103
- case 'rpgc_reload_card':
104
- $meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'ti-woocommerce-wishlist' );
105
- break;
106
- case 'rpgc_description':
107
- case 'rpgc_reload_check':
108
- unset( $meta[ $key ] );
109
- break;
110
- }
111
- }
112
- }
113
-
114
- return $meta;
115
- }
116
-
117
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_rpgiftcards' );
118
- } // End if().
119
-
120
- if ( ! function_exists( 'tinv_wishlist_metaprepare_rpgiftcards' ) ) {
121
-
122
- /**
123
- * Prepare save meta for WooCommerce - Gift Cards
124
- *
125
- * @param array $meta Meta array.
126
- *
127
- * @return array
128
- */
129
- function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
130
- if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
131
- if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
132
- foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
133
- if ( array_key_exists( $value, $meta ) ) {
134
- unset( $meta[ $value ] );
135
- }
136
- }
137
- }
138
- }
139
-
140
- return $meta;
141
- }
142
-
143
- add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_rpgiftcards' );
144
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TI WooCommerce Wishlist integration with:
4
+ *
5
+ * @name WooCommerce – Gift Cards
6
+ *
7
+ * @version 2.6.5
8
+ *
9
+ * @slug gift-cards-for-woocommerce
10
+ *
11
+ * @url https://wordpress.org/plugins/gift-cards-for-woocommerce/
12
+ *
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "gift-cards-for-woocommerce";
24
+
25
+ $name = "WooCommerce – Gift Cards";
26
+
27
+ $available = class_exists('KODIAK_GIFTCARDS');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_gift_card_add')) {
43
+
44
+ /**
45
+ * Support WooCommerce - Gift Cards
46
+ * Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
47
+ *
48
+ * @param boolean $redirect Default value to redirect.
49
+ * @param \WC_Product $product Product data.
50
+ *
51
+ * @return boolean
52
+ */
53
+ function tinvwl_gift_card_add($redirect, $product)
54
+ {
55
+ if (class_exists('KODIAK_GIFTCARDS')) {
56
+ $is_required_field_giftcard = get_option('woocommerce_enable_giftcard_info_requirements');
57
+
58
+ if ('yes' == $is_required_field_giftcard) { // WPCS: loose comparison ok.
59
+ $is_giftcard = get_post_meta($product->get_id(), '_giftcard', true);
60
+ if ('yes' == $is_giftcard) { // WPCS: loose comparison ok.
61
+ return true;
62
+ }
63
+ }
64
+ }
65
+
66
+ return $redirect;
67
+ }
68
+
69
+ add_filter('tinvwl_product_add_to_cart_need_redirect', 'tinvwl_gift_card_add', 20, 2);
70
+ }
71
+
72
+ if (!function_exists('tinvwl_gift_card_add_url')) {
73
+
74
+ /**
75
+ * Support WooCommerce - Gift Cards
76
+ * Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
77
+ *
78
+ * @param string $redirect_url Default value to redirect.
79
+ * @param \WC_Product $product Product data.
80
+ *
81
+ * @return boolean
82
+ */
83
+ function tinvwl_gift_card_add_url($redirect_url, $product)
84
+ {
85
+ if (class_exists('KODIAK_GIFTCARDS')) {
86
+ $is_required_field_giftcard = get_option('woocommerce_enable_giftcard_info_requirements');
87
+
88
+ if ('yes' == $is_required_field_giftcard) { // WPCS: loose comparison ok.
89
+ $is_giftcard = get_post_meta($product->get_id(), '_giftcard', true);
90
+ if ('yes' == $is_giftcard) { // WPCS: loose comparison ok.
91
+ return $product->get_permalink();
92
+ }
93
+ }
94
+ }
95
+
96
+ return $redirect_url;
97
+ }
98
+
99
+ add_filter('tinvwl_product_add_to_cart_redirect_url', 'tinvwl_gift_card_add_url', 20, 2);
100
+ }
101
+
102
+ if (!function_exists('tinv_wishlist_meta_support_rpgiftcards')) {
103
+
104
+ /**
105
+ * Set description for meta WooCommerce - Gift Cards
106
+ *
107
+ * @param array $meta Meta array.
108
+ *
109
+ * @return array
110
+ */
111
+ function tinv_wishlist_metasupport_rpgiftcards($meta)
112
+ {
113
+ if (class_exists('KODIAK_GIFTCARDS')) {
114
+ foreach ($meta as $key => $data) {
115
+ switch ($data['key']) {
116
+ case 'rpgc_note':
117
+ $meta[$key]['key'] = __('Note', 'ti-woocommerce-wishlist');
118
+ break;
119
+ case 'rpgc_to':
120
+ $meta[$key]['key'] = (get_option('woocommerce_giftcard_to') <> null ? get_option('woocommerce_giftcard_to') : __('To', 'ti-woocommerce-wishlist')); // WPCS: loose comparison ok.
121
+ break;
122
+ case 'rpgc_to_email':
123
+ $meta[$key]['key'] = (get_option('woocommerce_giftcard_toEmail') <> null ? get_option('woocommerce_giftcard_toEmail') : __('To Email', 'ti-woocommerce-wishlist')); // WPCS: loose comparison ok.
124
+ break;
125
+ case 'rpgc_address':
126
+ $meta[$key]['key'] = (get_option('woocommerce_giftcard_address') <> null ? get_option('woocommerce_giftcard_address') : __('Address', 'ti-woocommerce-wishlist')); // WPCS: loose comparison ok.
127
+ break;
128
+ case 'rpgc_reload_card':
129
+ $meta[$key]['key'] = __('Reload existing Gift Card', 'ti-woocommerce-wishlist');
130
+ break;
131
+ case 'rpgc_description':
132
+ case 'rpgc_reload_check':
133
+ unset($meta[$key]);
134
+ break;
135
+ }
136
+ }
137
+ }
138
+
139
+ return $meta;
140
+ }
141
+
142
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_rpgiftcards');
143
+ } // End if().
144
+
145
+ if (!function_exists('tinv_wishlist_metaprepare_rpgiftcards')) {
146
+
147
+ /**
148
+ * Prepare save meta for WooCommerce - Gift Cards
149
+ *
150
+ * @param array $meta Meta array.
151
+ *
152
+ * @return array
153
+ */
154
+ function tinv_wishlist_metaprepare_rpgiftcards($meta)
155
+ {
156
+ if (class_exists('KODIAK_GIFTCARDS')) {
157
+ if (array_key_exists('rpgc_reload_check', $meta)) {
158
+ foreach (array('rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address') as $value) {
159
+ if (array_key_exists($value, $meta)) {
160
+ unset($meta[$value]);
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ return $meta;
167
+ }
168
+
169
+ add_filter('tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_rpgiftcards');
170
+ }
integrations/hide-price-add-to-cart-button.php CHANGED
@@ -1,429 +1,454 @@
1
- <?php
2
- /**
3
- * TI WooCommerce Wishlist integration with:
4
- *
5
- * @name Hide Price and Add to Cart Button
6
- *
7
- * @version 1.2.1
8
- *
9
- * @slug hide-price-add-to-cart-button
10
- *
11
- * @url https://woocommerce.com/products/hide-price-add-to-cart-button/
12
- *
13
- */
14
-
15
- // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
- }
19
-
20
- if ( class_exists( 'Addify_Woo_Hide_Price_Front' ) ) {
21
-
22
- function tinvwl_check_class_action( $tag, $class, $method ) {
23
- global $wp_filter;
24
- if ( isset( $wp_filter[ $tag ] ) ) {
25
- $len = strlen( $method );
26
-
27
- foreach ( $wp_filter[ $tag ] as $_priority => $actions ) {
28
-
29
- if ( $actions ) {
30
- foreach ( $actions as $function_key => $data ) {
31
-
32
- if ( $data ) {
33
- if ( substr( $function_key, - $len ) == $method ) {
34
-
35
- if ( $class !== '' ) {
36
- if ( is_string( $data['function'][0] ) ) {
37
- $_class = $data['function'][0];
38
- } elseif ( is_object( $data['function'][0] ) ) {
39
- $_class = get_class( $data['function'][0] );
40
- } else {
41
- return false;
42
- }
43
-
44
- if ( $_class !== '' && $_class == $class ) {
45
- return true;
46
- }
47
- } else {
48
- return true;
49
- }
50
-
51
- }
52
- }
53
- }
54
- }
55
- }
56
- }
57
-
58
- return false;
59
- }
60
-
61
- add_action( 'woocommerce_single_product_summary', 'tinvwl_afwhp_hooks', 31 );
62
- add_action( 'woocommerce_single_variation', 'tinvwl_afwhp_hooks', 31 );
63
-
64
- function tinvwl_afwhp_hooks() {
65
-
66
- $simple = tinvwl_check_class_action( 'woocommerce_single_product_summary', 'Addify_Woo_Hide_Price_Front', 'afwhp_custom_button_replacement' );
67
- if ( $simple ) {
68
- add_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_html', 32 );
69
- add_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 32 );
70
- }
71
-
72
- $variable = tinvwl_check_class_action( 'woocommerce_single_variation', 'Addify_Woo_Hide_Price_Front', 'afwhp_custom_button_replacement' );
73
- if ( $variable ) {
74
- add_action( 'woocommerce_single_variation', 'tinvwl_view_addto_html', 32 );
75
- add_action( 'woocommerce_single_variation', 'tinvwl_view_addto_htmlout', 32 );
76
-
77
- ob_start(); ?>
78
- <script>
79
- (function ($) {
80
- $(document).ready(function () {
81
- $(document).on('show_variation', '.variations_form', function (a, b, d) {
82
- var e = $(this).find('.tinvwl_add_to_wishlist_button');
83
- if (e.length) {
84
- e.attr('data-tinv-wl-productvariation', b.variation_id);
85
- }
86
- a.preventDefault();
87
- });
88
- });
89
- })(jQuery);
90
- </script>
91
-
92
-
93
- <?php $content = ob_get_clean();
94
- echo $content;
95
- }
96
- }
97
-
98
- //wishlist add to cart button
99
- add_filter( 'tinvwl_wishlist_item_action_add_to_cart', 'tinvwl_product_allow_add_to_cart_afwhp', 10, 3 );
100
-
101
- /**
102
- * Allow show button add to cart
103
- *
104
- * @param boolean $allow Settings flag.
105
- * @param array $wlproduct Wishlist Product.
106
- * @param WC_Product $product Product.
107
- *
108
- * @return boolean
109
- */
110
- function tinvwl_product_allow_add_to_cart_afwhp( $allow, $wlproduct, $product ) {
111
-
112
- $args = array(
113
- 'post_type' => 'addify_whp',
114
- 'post_status' => 'publish',
115
- 'numberposts' => - 1,
116
- 'orderby' => 'menu_order',
117
- 'order' => 'ASC'
118
-
119
- );
120
- $rules = get_posts( $args );
121
- foreach ( $rules as $rule ) {
122
-
123
- $afwhp_rule_type = get_post_meta( intval( $rule->ID ), 'afwhp_rule_type', true );
124
- $afwhp_hide_products = unserialize( get_post_meta( intval( $rule->ID ), 'afwhp_hide_products', true ) );
125
- $afwhp_hide_categories = unserialize( get_post_meta( intval( $rule->ID ), 'afwhp_hide_categories', true ) );
126
- $afwhp_hide_user_role = unserialize( get_post_meta( intval( $rule->ID ), 'afwhp_hide_user_role', true ) );
127
- $afwhp_is_hide_addtocart = get_post_meta( intval( $rule->ID ), 'afwhp_is_hide_addtocart', true );
128
- $afwhp_custom_button_text = get_post_meta( intval( $rule->ID ), 'afwhp_custom_button_text', true );
129
- $afwhp_custom_button_link = get_post_meta( intval( $rule->ID ), 'afwhp_custom_button_link', true );
130
- $afwhp_contact7_form = get_post_meta( intval( $rule->ID ), 'afwhp_contact7_form', true );
131
- $afwhp_hide_for_countries = unserialize( get_post_meta( intval( $rule->ID ), 'afwhp_hide_for_countries', true ) );
132
-
133
- if ( ! empty( $afwhp_hide_for_countries ) ) {
134
- //country
135
- if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
136
- $ip = sanitize_meta( '', $_SERVER['REMOTE_ADDR'], '' );
137
- } else {
138
- $ip = '';
139
- }
140
- $ch = curl_init();
141
- curl_setopt( $ch, CURLOPT_URL, 'http://www.geoplugin.net/json.gp?ip=' . $ip );
142
- curl_setopt( $ch, CURLOPT_HEADER, 0 );
143
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
144
- $ip_data_in = curl_exec( $ch ); // string
145
- curl_close( $ch );
146
-
147
- $ip_data = json_decode( $ip_data_in, true );
148
- $ip_data = str_replace( '&quot;', '"', $ip_data ); // for PHP 5.2 see stackoverflow.com/questions/3110487/
149
-
150
- if ( $ip_data && null != $ip_data['geoplugin_countryCode'] ) {
151
- $country = $ip_data['geoplugin_countryCode'];
152
- }
153
-
154
- $curr_country = $country;
155
- } else {
156
- $curr_country = '';
157
- }
158
-
159
- $istrue = false;
160
-
161
- if ( ! empty( $afwhp_hide_for_countries ) && in_array( $curr_country, $afwhp_hide_for_countries ) ) {
162
-
163
- $iscountry = true;
164
-
165
- } elseif ( empty( $afwhp_hide_for_countries ) ) {
166
-
167
- $iscountry = true;
168
-
169
- } else {
170
-
171
- $iscountry = false;
172
- }
173
-
174
- $applied_on_all_products = get_post_meta( $rule->ID, 'afwhp_apply_on_all_products', true );
175
-
176
-
177
- //Registered Users
178
- if ( 'afwhp_for_registered_users' == $afwhp_rule_type ) {
179
-
180
- if ( is_user_logged_in() ) {
181
-
182
- // get Current User Role
183
- $curr_user = wp_get_current_user();
184
- $user_data = get_user_meta( $curr_user->ID );
185
- $curr_user_role = $curr_user->roles[0];
186
-
187
- if ( 'yes' == $applied_on_all_products && empty( $afwhp_hide_user_role ) ) {
188
- $istrue = true;
189
- } elseif ( ( is_array( $afwhp_hide_user_role ) && in_array( $curr_user_role, $afwhp_hide_user_role ) ) && 'yes' == $applied_on_all_products ) {
190
- $istrue = true;
191
- } elseif ( ( is_array( $afwhp_hide_user_role ) && in_array( $curr_user_role, $afwhp_hide_user_role ) ) && ( is_array( $afwhp_hide_products ) && in_array( $product->get_id(), $afwhp_hide_products ) ) ) {
192
- $istrue = true;
193
- }
194
-
195
-
196
- //Products
197
- if ( $istrue && $iscountry ) {
198
-
199
- if ( 'yes' == $afwhp_is_hide_addtocart ) {
200
-
201
- if ( '' == $afwhp_custom_button_text ) {
202
-
203
- echo '';
204
- } else {
205
-
206
- if ( ! empty( $afwhp_custom_button_link ) ) {
207
-
208
- echo '<a href="' . esc_url( $afwhp_custom_button_link ) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
209
- } elseif ( ! empty( $afwhp_contact7_form ) ) {
210
-
211
- $contact7 = get_post( $afwhp_contact7_form );
212
-
213
- $form_title = $contact7->post_title;
214
-
215
- ?>
216
- <a href="javascript:void(0)"
217
- onclick="showPopForm('<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>')"
218
- class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr( $afwhp_custom_button_text ); ?></a>
219
- <div id="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>"
220
- class="form_popup">
221
-
222
- <button class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_close form_close_btn btn btn-default">
223
- X
224
- </button>
225
-
226
- <?php echo do_shortcode( '[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] ' ); ?>
227
-
228
- </div>
229
-
230
- <?php
231
-
232
- } else {
233
-
234
- echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
235
- }
236
-
237
- }
238
- }
239
-
240
- }
241
-
242
- //Categories
243
-
244
- if ( ! empty( $afwhp_hide_categories ) && ! $istrue && $iscountry ) {
245
-
246
- foreach ( $afwhp_hide_categories as $cat ) {
247
-
248
- if ( has_term( $cat, 'product_cat', $product->get_id() ) ) {
249
-
250
- if ( in_array( $curr_user_role, $afwhp_hide_user_role ) ) {
251
-
252
- if ( 'yes' == $afwhp_is_hide_addtocart ) {
253
-
254
- if ( '' == $afwhp_custom_button_text ) {
255
-
256
- echo '';
257
- } else {
258
-
259
- if ( ! empty( $afwhp_custom_button_link ) ) {
260
-
261
- echo '<a href="' . esc_url( $afwhp_custom_button_link ) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
262
-
263
- return;
264
- } elseif ( ! empty( $afwhp_contact7_form ) ) {
265
-
266
- $contact7 = get_post( $afwhp_contact7_form );
267
-
268
-
269
- $form_title = $contact7->post_title;
270
-
271
- ?>
272
- <a href="javascript:void(0)"
273
- onclick="showPopForm('<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>')"
274
- class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr( $afwhp_custom_button_text ); ?></a>
275
- <div id="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>"
276
- class="form_popup">
277
-
278
- <button class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_close form_close_btn btn btn-default">
279
- X
280
- </button>
281
-
282
- <?php echo do_shortcode( '[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] ' ); ?>
283
-
284
- </div>
285
-
286
- <?php
287
- return;
288
- } else {
289
-
290
- echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
291
-
292
- return;
293
- }
294
-
295
- }
296
- }
297
-
298
- }
299
-
300
- }
301
-
302
- }
303
- }
304
-
305
-
306
- }
307
-
308
- } else {
309
- //Guest Users
310
- if ( ! is_user_logged_in() ) {
311
-
312
- //Products
313
- if ( 'yes' == $applied_on_all_products ) {
314
- $istrue = true;
315
- } elseif ( is_array( $afwhp_hide_products ) && in_array( $product->get_id(), $afwhp_hide_products ) ) {
316
- $istrue = true;
317
- }
318
-
319
- if ( $istrue && $iscountry ) {
320
-
321
- if ( 'yes' == $afwhp_is_hide_addtocart ) {
322
-
323
- if ( '' == $afwhp_custom_button_text ) {
324
-
325
- echo '';
326
- } else {
327
-
328
- if ( ! empty( $afwhp_custom_button_link ) ) {
329
-
330
- echo '<a href="' . esc_url( $afwhp_custom_button_link ) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
331
- } elseif ( ! empty( $afwhp_contact7_form ) ) {
332
-
333
- $contact7 = get_post( $afwhp_contact7_form );
334
-
335
-
336
- $form_title = $contact7->post_title;
337
-
338
- ?>
339
- <a href="javascript:void(0)"
340
- onclick="showPopForm('<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>')"
341
- class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr( $afwhp_custom_button_text ); ?></a>
342
- <div id="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>"
343
- class="form_popup">
344
-
345
- <button class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_close form_close_btn btn btn-default">
346
- X
347
- </button>
348
-
349
- <?php echo do_shortcode( '[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] ' ); ?>
350
-
351
- </div>
352
-
353
- <?php
354
-
355
- } else {
356
-
357
- echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
358
- }
359
-
360
- }
361
- }
362
-
363
- }
364
-
365
-
366
- //Categories
367
- if ( ! empty( $afwhp_hide_categories ) && ! $istrue && $iscountry ) {
368
-
369
- foreach ( $afwhp_hide_categories as $cat ) {
370
-
371
- if ( has_term( $cat, 'product_cat', $product->get_id() ) ) {
372
-
373
- if ( 'yes' == $afwhp_is_hide_addtocart ) {
374
-
375
- if ( '' == $afwhp_custom_button_text ) {
376
-
377
- echo '';
378
- } else {
379
-
380
- if ( ! empty( $afwhp_custom_button_link ) ) {
381
-
382
- echo '<a href="' . esc_url( $afwhp_custom_button_link ) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
383
-
384
- return;
385
- } elseif ( ! empty( $afwhp_contact7_form ) ) {
386
-
387
- $contact7 = get_post( $afwhp_contact7_form );
388
-
389
-
390
- $form_title = $contact7->post_title;
391
-
392
- ?>
393
- <a href="javascript:void(0)"
394
- onclick="showPopForm('<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>')"
395
- class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr( $afwhp_custom_button_text ); ?></a>
396
- <div id="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>"
397
- class="form_popup">
398
-
399
- <button class="form_popup<?php echo esc_attr( $afwhp_contact7_form ) . esc_attr( $product->get_id() ); ?>_close form_close_btn btn btn-default">
400
- X
401
- </button>
402
-
403
- <?php echo do_shortcode( '[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] ' ); ?>
404
-
405
- </div>
406
-
407
- <?php
408
- return;
409
- } else {
410
-
411
- echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr( $product->get_type() ) . '">' . esc_attr( $afwhp_custom_button_text ) . '</a>';
412
-
413
- return;
414
- }
415
-
416
- }
417
- }
418
-
419
- }
420
-
421
- }
422
- }
423
-
424
- }
425
- }
426
-
427
- }
428
- }
429
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TI WooCommerce Wishlist integration with:
4
+ *
5
+ * @name Hide Price and Add to Cart Button
6
+ *
7
+ * @version 1.2.1
8
+ *
9
+ * @slug hide-price-add-to-cart-button
10
+ *
11
+ * @url https://woocommerce.com/products/hide-price-add-to-cart-button/
12
+ *
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "hide-price-add-to-cart-button";
24
+
25
+ $name = "Hide Price and Add to Cart Button";
26
+
27
+ $available = class_exists('Addify_Woo_Hide_Price_Front');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (class_exists('Addify_Woo_Hide_Price_Front')) {
43
+
44
+ function tinvwl_check_class_action($tag, $class, $method)
45
+ {
46
+ global $wp_filter;
47
+ if (isset($wp_filter[$tag])) {
48
+ $len = strlen($method);
49
+
50
+ foreach ($wp_filter[$tag] as $_priority => $actions) {
51
+
52
+ if ($actions) {
53
+ foreach ($actions as $function_key => $data) {
54
+
55
+ if ($data) {
56
+ if (substr($function_key, -$len) == $method) {
57
+
58
+ if ($class !== '') {
59
+ if (is_string($data['function'][0])) {
60
+ $_class = $data['function'][0];
61
+ } elseif (is_object($data['function'][0])) {
62
+ $_class = get_class($data['function'][0]);
63
+ } else {
64
+ return false;
65
+ }
66
+
67
+ if ($_class !== '' && $_class == $class) {
68
+ return true;
69
+ }
70
+ } else {
71
+ return true;
72
+ }
73
+
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ return false;
82
+ }
83
+
84
+ add_action('woocommerce_single_product_summary', 'tinvwl_afwhp_hooks', 31);
85
+ add_action('woocommerce_single_variation', 'tinvwl_afwhp_hooks', 31);
86
+
87
+ function tinvwl_afwhp_hooks()
88
+ {
89
+
90
+ $simple = tinvwl_check_class_action('woocommerce_single_product_summary', 'Addify_Woo_Hide_Price_Front', 'afwhp_custom_button_replacement');
91
+ if ($simple) {
92
+ add_action('woocommerce_single_product_summary', 'tinvwl_view_addto_html', 32);
93
+ add_action('woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 32);
94
+ }
95
+
96
+ $variable = tinvwl_check_class_action('woocommerce_single_variation', 'Addify_Woo_Hide_Price_Front', 'afwhp_custom_button_replacement');
97
+ if ($variable) {
98
+ add_action('woocommerce_single_variation', 'tinvwl_view_addto_html', 32);
99
+ add_action('woocommerce_single_variation', 'tinvwl_view_addto_htmlout', 32);
100
+
101
+ ob_start(); ?>
102
+ <script>
103
+ (function ($) {
104
+ $(document).ready(function () {
105
+ $(document).on('show_variation', '.variations_form', function (a, b, d) {
106
+ var e = $(this).find('.tinvwl_add_to_wishlist_button');
107
+ if (e.length) {
108
+ e.attr('data-tinv-wl-productvariation', b.variation_id);
109
+ }
110
+ a.preventDefault();
111
+ });
112
+ });
113
+ })(jQuery);
114
+ </script>
115
+
116
+
117
+ <?php $content = ob_get_clean();
118
+ echo $content;
119
+ }
120
+ }
121
+
122
+ //wishlist add to cart button
123
+ add_filter('tinvwl_wishlist_item_action_add_to_cart', 'tinvwl_product_allow_add_to_cart_afwhp', 10, 3);
124
+
125
+ /**
126
+ * Allow show button add to cart
127
+ *
128
+ * @param boolean $allow Settings flag.
129
+ * @param array $wlproduct Wishlist Product.
130
+ * @param WC_Product $product Product.
131
+ *
132
+ * @return boolean
133
+ */
134
+ function tinvwl_product_allow_add_to_cart_afwhp($allow, $wlproduct, $product)
135
+ {
136
+
137
+ $args = array(
138
+ 'post_type' => 'addify_whp',
139
+ 'post_status' => 'publish',
140
+ 'numberposts' => -1,
141
+ 'orderby' => 'menu_order',
142
+ 'order' => 'ASC'
143
+
144
+ );
145
+ $rules = get_posts($args);
146
+ foreach ($rules as $rule) {
147
+
148
+ $afwhp_rule_type = get_post_meta(intval($rule->ID), 'afwhp_rule_type', true);
149
+ $afwhp_hide_products = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_products', true));
150
+ $afwhp_hide_categories = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_categories', true));
151
+ $afwhp_hide_user_role = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_user_role', true));
152
+ $afwhp_is_hide_addtocart = get_post_meta(intval($rule->ID), 'afwhp_is_hide_addtocart', true);
153
+ $afwhp_custom_button_text = get_post_meta(intval($rule->ID), 'afwhp_custom_button_text', true);
154
+ $afwhp_custom_button_link = get_post_meta(intval($rule->ID), 'afwhp_custom_button_link', true);
155
+ $afwhp_contact7_form = get_post_meta(intval($rule->ID), 'afwhp_contact7_form', true);
156
+ $afwhp_hide_for_countries = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_for_countries', true));
157
+
158
+ if (!empty($afwhp_hide_for_countries)) {
159
+ //country
160
+ if (!empty($_SERVER['REMOTE_ADDR'])) {
161
+ $ip = sanitize_meta('', $_SERVER['REMOTE_ADDR'], '');
162
+ } else {
163
+ $ip = '';
164
+ }
165
+ $ch = curl_init();
166
+ curl_setopt($ch, CURLOPT_URL, 'http://www.geoplugin.net/json.gp?ip=' . $ip);
167
+ curl_setopt($ch, CURLOPT_HEADER, 0);
168
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
169
+ $ip_data_in = curl_exec($ch); // string
170
+ curl_close($ch);
171
+
172
+ $ip_data = json_decode($ip_data_in, true);
173
+ $ip_data = str_replace('&quot;', '"', $ip_data); // for PHP 5.2 see stackoverflow.com/questions/3110487/
174
+
175
+ if ($ip_data && null != $ip_data['geoplugin_countryCode']) {
176
+ $country = $ip_data['geoplugin_countryCode'];
177
+ }
178
+
179
+ $curr_country = $country;
180
+ } else {
181
+ $curr_country = '';
182
+ }
183
+
184
+ $istrue = false;
185
+
186
+ if (!empty($afwhp_hide_for_countries) && in_array($curr_country, $afwhp_hide_for_countries)) {
187
+
188
+ $iscountry = true;
189
+
190
+ } elseif (empty($afwhp_hide_for_countries)) {
191
+
192
+ $iscountry = true;
193
+
194
+ } else {
195
+
196
+ $iscountry = false;
197
+ }
198
+
199
+ $applied_on_all_products = get_post_meta($rule->ID, 'afwhp_apply_on_all_products', true);
200
+
201
+
202
+ //Registered Users
203
+ if ('afwhp_for_registered_users' == $afwhp_rule_type) {
204
+
205
+ if (is_user_logged_in()) {
206
+
207
+ // get Current User Role
208
+ $curr_user = wp_get_current_user();
209
+ $user_data = get_user_meta($curr_user->ID);
210
+ $curr_user_role = $curr_user->roles[0];
211
+
212
+ if ('yes' == $applied_on_all_products && empty($afwhp_hide_user_role)) {
213
+ $istrue = true;
214
+ } elseif ((is_array($afwhp_hide_user_role) && in_array($curr_user_role, $afwhp_hide_user_role)) && 'yes' == $applied_on_all_products) {
215
+ $istrue = true;
216
+ } elseif ((is_array($afwhp_hide_user_role) && in_array($curr_user_role, $afwhp_hide_user_role)) && (is_array($afwhp_hide_products) && in_array($product->get_id(), $afwhp_hide_products))) {
217
+ $istrue = true;
218
+ }
219
+
220
+
221
+ //Products
222
+ if ($istrue && $iscountry) {
223
+
224
+ if ('yes' == $afwhp_is_hide_addtocart) {
225
+
226
+ if ('' == $afwhp_custom_button_text) {
227
+
228
+ echo '';
229
+ } else {
230
+
231
+ if (!empty($afwhp_custom_button_link)) {
232
+
233
+ echo '<a href="' . esc_url($afwhp_custom_button_link) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
234
+ } elseif (!empty($afwhp_contact7_form)) {
235
+
236
+ $contact7 = get_post($afwhp_contact7_form);
237
+
238
+ $form_title = $contact7->post_title;
239
+
240
+ ?>
241
+ <a href="javascript:void(0)"
242
+ onclick="showPopForm('<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>')"
243
+ class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr($afwhp_custom_button_text); ?></a>
244
+ <div id="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>"
245
+ class="form_popup">
246
+
247
+ <button class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_close form_close_btn btn btn-default">
248
+ X
249
+ </button>
250
+
251
+ <?php echo do_shortcode('[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] '); ?>
252
+
253
+ </div>
254
+
255
+ <?php
256
+
257
+ } else {
258
+
259
+ echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
260
+ }
261
+
262
+ }
263
+ }
264
+
265
+ }
266
+
267
+ //Categories
268
+
269
+ if (!empty($afwhp_hide_categories) && !$istrue && $iscountry) {
270
+
271
+ foreach ($afwhp_hide_categories as $cat) {
272
+
273
+ if (has_term($cat, 'product_cat', $product->get_id())) {
274
+
275
+ if (in_array($curr_user_role, $afwhp_hide_user_role)) {
276
+
277
+ if ('yes' == $afwhp_is_hide_addtocart) {
278
+
279
+ if ('' == $afwhp_custom_button_text) {
280
+
281
+ echo '';
282
+ } else {
283
+
284
+ if (!empty($afwhp_custom_button_link)) {
285
+
286
+ echo '<a href="' . esc_url($afwhp_custom_button_link) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
287
+
288
+ return;
289
+ } elseif (!empty($afwhp_contact7_form)) {
290
+
291
+ $contact7 = get_post($afwhp_contact7_form);
292
+
293
+
294
+ $form_title = $contact7->post_title;
295
+
296
+ ?>
297
+ <a href="javascript:void(0)"
298
+ onclick="showPopForm('<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>')"
299
+ class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr($afwhp_custom_button_text); ?></a>
300
+ <div id="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>"
301
+ class="form_popup">
302
+
303
+ <button class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_close form_close_btn btn btn-default">
304
+ X
305
+ </button>
306
+
307
+ <?php echo do_shortcode('[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] '); ?>
308
+
309
+ </div>
310
+
311
+ <?php
312
+ return;
313
+ } else {
314
+
315
+ echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
316
+
317
+ return;
318
+ }
319
+
320
+ }
321
+ }
322
+
323
+ }
324
+
325
+ }
326
+
327
+ }
328
+ }
329
+
330
+
331
+ }
332
+
333
+ } else {
334
+ //Guest Users
335
+ if (!is_user_logged_in()) {
336
+
337
+ //Products
338
+ if ('yes' == $applied_on_all_products) {
339
+ $istrue = true;
340
+ } elseif (is_array($afwhp_hide_products) && in_array($product->get_id(), $afwhp_hide_products)) {
341
+ $istrue = true;
342
+ }
343
+
344
+ if ($istrue && $iscountry) {
345
+
346
+ if ('yes' == $afwhp_is_hide_addtocart) {
347
+
348
+ if ('' == $afwhp_custom_button_text) {
349
+
350
+ echo '';
351
+ } else {
352
+
353
+ if (!empty($afwhp_custom_button_link)) {
354
+
355
+ echo '<a href="' . esc_url($afwhp_custom_button_link) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
356
+ } elseif (!empty($afwhp_contact7_form)) {
357
+
358
+ $contact7 = get_post($afwhp_contact7_form);
359
+
360
+
361
+ $form_title = $contact7->post_title;
362
+
363
+ ?>
364
+ <a href="javascript:void(0)"
365
+ onclick="showPopForm('<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>')"
366
+ class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr($afwhp_custom_button_text); ?></a>
367
+ <div id="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>"
368
+ class="form_popup">
369
+
370
+ <button class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_close form_close_btn btn btn-default">
371
+ X
372
+ </button>
373
+
374
+ <?php echo do_shortcode('[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] '); ?>
375
+
376
+ </div>
377
+
378
+ <?php
379
+
380
+ } else {
381
+
382
+ echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
383
+ }
384
+
385
+ }
386
+ }
387
+
388
+ }
389
+
390
+
391
+ //Categories
392
+ if (!empty($afwhp_hide_categories) && !$istrue && $iscountry) {
393
+
394
+ foreach ($afwhp_hide_categories as $cat) {
395
+
396
+ if (has_term($cat, 'product_cat', $product->get_id())) {
397
+
398
+ if ('yes' == $afwhp_is_hide_addtocart) {
399
+
400
+ if ('' == $afwhp_custom_button_text) {
401
+
402
+ echo '';
403
+ } else {
404
+
405
+ if (!empty($afwhp_custom_button_link)) {
406
+
407
+ echo '<a href="' . esc_url($afwhp_custom_button_link) . '" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
408
+
409
+ return;
410
+ } elseif (!empty($afwhp_contact7_form)) {
411
+
412
+ $contact7 = get_post($afwhp_contact7_form);
413
+
414
+
415
+ $form_title = $contact7->post_title;
416
+
417
+ ?>
418
+ <a href="javascript:void(0)"
419
+ onclick="showPopForm('<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>')"
420
+ class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_open button product_type_simple add_to_cart_button"><?php echo esc_attr($afwhp_custom_button_text); ?></a>
421
+ <div id="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>"
422
+ class="form_popup">
423
+
424
+ <button class="form_popup<?php echo esc_attr($afwhp_contact7_form) . esc_attr($product->get_id()); ?>_close form_close_btn btn btn-default">
425
+ X
426
+ </button>
427
+
428
+ <?php echo do_shortcode('[contact-form-7 id="' . $afwhp_contact7_form . '" title="' . $form_title . '" ] '); ?>
429
+
430
+ </div>
431
+
432
+ <?php
433
+ return;
434
+ } else {
435
+
436
+ echo '<a href="javascript:void(0)" rel="nofollow" class="button add_to_cart_button product_type_' . esc_attr($product->get_type()) . '">' . esc_attr($afwhp_custom_button_text) . '</a>';
437
+
438
+ return;
439
+ }
440
+
441
+ }
442
+ }
443
+
444
+ }
445
+
446
+ }
447
+ }
448
+
449
+ }
450
+ }
451
+
452
+ }
453
+ }
454
+ }
integrations/improved-variable-product-attributes.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_meta_support_ivpa' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta Improved Product Options for WooCommerce
@@ -26,56 +48,57 @@ if ( ! function_exists( 'tinv_wishlist_meta_support_ivpa' ) ) {
26
  *
27
  * @return array
28
  */
29
- function tinv_wishlist_meta_support_ivpa( $meta ) {
 
30
  global $product;
31
 
32
- if ( class_exists( 'XforWC_Improved_Options' ) ) {
33
 
34
  $curr_customizations = XforWC_Improved_Options_Frontend::get_settings();
35
 
36
- foreach ( $meta as $k => $v ) {
37
 
38
- $prefix = 'ivpac_';
39
- $k_ivpac = ( 0 === strpos( $k, $prefix ) ) ? substr( $k, strlen( $prefix ) ) : $k;
40
 
41
- $prefix = 'attribute_';
42
- $k_ivpac = ( 0 === strpos( $k, $prefix ) ) ? substr( $k, strlen( $prefix ) ) : $k_ivpac;
43
- $local_attribute = ( 0 === strpos( $k, $prefix ) ) ? true : false;
44
- $v = is_array( $v['display'] ) ? implode( ', ', $v['display'] ) : $v['display'];
45
 
46
- if ( isset( $curr_customizations['ivpa_attr'][ $k_ivpac ] ) ) {
47
- if ( $curr_customizations['ivpa_attr'][ $k_ivpac ] == 'ivpa_custom' ) {
48
- $meta[ $k ] = array(
49
- 'key' => $curr_customizations['ivpa_title'][ $k_ivpac ],
50
  'display' => $v,
51
  );
52
  }
53
  }
54
 
55
- if ( in_array( $k_ivpac, $curr_customizations['ivpa_attr'] ) ) {
56
 
57
  $attributes = $product->get_attributes();
58
- $attribute = sanitize_title( $k_ivpac );
59
 
60
  $term_slug = '';
61
 
62
- if ( isset( $attributes[ $attribute ] ) ) {
63
- $term_slug = $attributes[ $attribute ];
64
- } elseif ( isset( $attributes[ 'pa_' . $attribute ] ) ) {
65
- $term_slug = $attributes[ 'pa_' . $attribute ];
66
  }
67
 
68
- if ( $product->is_type( 'variation' ) && $term_slug === $v ) {
69
- unset( $meta[ $k ] );
70
  } else {
71
- $meta[ $k ] = array(
72
- 'key' => wc_attribute_label( $k_ivpac ),
73
  'display' => $v,
74
  );
75
  }
76
- } elseif ( wc_attribute_label( $k_ivpac ) && $local_attribute ) {
77
- $meta[ $k ] = array(
78
- 'key' => wc_attribute_label( $k_ivpac ),
79
  'display' => $v,
80
  );
81
  }
@@ -85,14 +108,15 @@ if ( ! function_exists( 'tinv_wishlist_meta_support_ivpa' ) ) {
85
  return $meta;
86
  }
87
 
88
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_ivpa' );
89
  } // End if().
90
 
91
 
92
- function tinv_add_to_wishlist_ivpa() {
93
- if ( class_exists( 'XforWC_Improved_Options' ) ) {
 
94
 
95
- wp_add_inline_script( 'tinvwl', "
96
  jQuery(document).ready(function($){
97
  $(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
98
  if (typeof ivpa === 'undefined' || !ivpa) {
@@ -153,8 +177,8 @@ function tinv_add_to_wishlist_ivpa() {
153
  }
154
  });
155
  });
156
- " );
157
  }
158
  }
159
 
160
- add_action( 'wp_enqueue_scripts', 'tinv_add_to_wishlist_ivpa', 100, 1 );
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "improved-variable-product-attributes";
24
+
25
+ $name = "Improved Product Options for WooCommerce";
26
+
27
+ $available = class_exists('XforWC_Improved_Options');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_meta_support_ivpa')) {
43
 
44
  /**
45
  * Set description for meta Improved Product Options for WooCommerce
48
  *
49
  * @return array
50
  */
51
+ function tinv_wishlist_meta_support_ivpa($meta)
52
+ {
53
  global $product;
54
 
55
+ if (class_exists('XforWC_Improved_Options')) {
56
 
57
  $curr_customizations = XforWC_Improved_Options_Frontend::get_settings();
58
 
59
+ foreach ($meta as $k => $v) {
60
 
61
+ $prefix = 'ivpac_';
62
+ $k_ivpac = (0 === strpos($k, $prefix)) ? substr($k, strlen($prefix)) : $k;
63
 
64
+ $prefix = 'attribute_';
65
+ $k_ivpac = (0 === strpos($k, $prefix)) ? substr($k, strlen($prefix)) : $k_ivpac;
66
+ $local_attribute = (0 === strpos($k, $prefix)) ? true : false;
67
+ $v = is_array($v['display']) ? implode(', ', $v['display']) : $v['display'];
68
 
69
+ if (isset($curr_customizations['ivpa_attr'][$k_ivpac])) {
70
+ if ($curr_customizations['ivpa_attr'][$k_ivpac] == 'ivpa_custom') {
71
+ $meta[$k] = array(
72
+ 'key' => $curr_customizations['ivpa_title'][$k_ivpac],
73
  'display' => $v,
74
  );
75
  }
76
  }
77
 
78
+ if (in_array($k_ivpac, $curr_customizations['ivpa_attr'])) {
79
 
80
  $attributes = $product->get_attributes();
81
+ $attribute = sanitize_title($k_ivpac);
82
 
83
  $term_slug = '';
84
 
85
+ if (isset($attributes[$attribute])) {
86
+ $term_slug = $attributes[$attribute];
87
+ } elseif (isset($attributes['pa_' . $attribute])) {
88
+ $term_slug = $attributes['pa_' . $attribute];
89
  }
90
 
91
+ if ($product->is_type('variation') && $term_slug === $v) {
92
+ unset($meta[$k]);
93
  } else {
94
+ $meta[$k] = array(
95
+ 'key' => wc_attribute_label($k_ivpac),
96
  'display' => $v,
97
  );
98
  }
99
+ } elseif (wc_attribute_label($k_ivpac) && $local_attribute) {
100
+ $meta[$k] = array(
101
+ 'key' => wc_attribute_label($k_ivpac),
102
  'display' => $v,
103
  );
104
  }
108
  return $meta;
109
  }
110
 
111
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_ivpa');
112
  } // End if().
113
 
114
 
115
+ function tinv_add_to_wishlist_ivpa()
116
+ {
117
+ if (class_exists('XforWC_Improved_Options')) {
118
 
119
+ wp_add_inline_script('tinvwl', "
120
  jQuery(document).ready(function($){
121
  $(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
122
  if (typeof ivpa === 'undefined' || !ivpa) {
177
  }
178
  });
179
  });
180
+ ");
181
  }
182
  }
183
 
184
+ add_action('wp_enqueue_scripts', 'tinv_add_to_wishlist_ivpa', 100, 1);
integrations/litespeed-cache.php CHANGED
@@ -13,57 +13,82 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
- if ( defined( 'LSWCP_PLUGIN_URL' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  // Force ESI nonce.
23
- if ( ! function_exists( 'tinvwl_litespeed_conf_esi_nonce' ) ) {
24
- add_action( 'wp_enqueue_scripts', 'tinvwl_litespeed_conf_esi_nonce', 9 );
25
 
26
- function tinvwl_litespeed_conf_esi_nonce() {
27
- do_action( 'litespeed_nonce', 'wp_rest' );
 
28
  }
29
 
30
  }
31
 
32
  // Force exclude URL
33
- if ( ! function_exists( 'tinvwl_litespeed_conf_exc_uri' ) ) {
34
- add_action( 'init', 'tinvwl_litespeed_conf_exc_uri' );
35
 
36
- function tinvwl_litespeed_conf_exc_uri() {
37
- $val = apply_filters( 'litespeed_conf', 'cache-exc' );
 
38
 
39
- $ids = array(
40
- tinv_get_option( 'page', 'wishlist' ),
41
  );
42
- $pages = $ids;
43
- $languages = apply_filters( 'wpml_active_languages', array(), array(
44
  'skip_missing' => 0,
45
- 'orderby' => 'code',
46
- ) );
47
- if ( ! empty( $languages ) ) {
48
- foreach ( $ids as $id ) {
49
- foreach ( $languages as $l ) {
50
- $pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
51
  }
52
  }
53
- $pages = array_unique( $pages );
54
  }
55
- $pages = array_filter( $pages );
56
 
57
- if ( ! empty( $pages ) ) {
58
- foreach ( $pages as $i => $page ) {
59
- $pages[ $i ] = preg_replace( "/^\//", '', rtrim( str_replace( get_site_url(), '', get_permalink( absint( $page ) ) ), '/' ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
60
  }
61
  }
62
- $pages = array_unique( $pages );
63
- $pages = array_filter( $pages );
64
 
65
- $val = array_unique( array_merge( $val, $pages ) );
66
- do_action( 'litespeed_conf_force', 'cache-exc', $val );
67
  }
68
  }
69
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "litespeed-cache";
24
+
25
+ $name = "LiteSpeed Cache";
26
+
27
+ $available = defined('LSWCP_PLUGIN_URL');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (defined('LSWCP_PLUGIN_URL')) {
43
 
44
 
45
  // Force ESI nonce.
46
+ if (!function_exists('tinvwl_litespeed_conf_esi_nonce')) {
47
+ add_action('wp_enqueue_scripts', 'tinvwl_litespeed_conf_esi_nonce', 9);
48
 
49
+ function tinvwl_litespeed_conf_esi_nonce()
50
+ {
51
+ do_action('litespeed_nonce', 'wp_rest');
52
  }
53
 
54
  }
55
 
56
  // Force exclude URL
57
+ if (!function_exists('tinvwl_litespeed_conf_exc_uri')) {
58
+ add_action('init', 'tinvwl_litespeed_conf_exc_uri');
59
 
60
+ function tinvwl_litespeed_conf_exc_uri()
61
+ {
62
+ $val = apply_filters('litespeed_conf', 'cache-exc');
63
 
64
+ $ids = array(
65
+ tinv_get_option('page', 'wishlist'),
66
  );
67
+ $pages = $ids;
68
+ $languages = apply_filters('wpml_active_languages', array(), array(
69
  'skip_missing' => 0,
70
+ 'orderby' => 'code',
71
+ ));
72
+ if (!empty($languages)) {
73
+ foreach ($ids as $id) {
74
+ foreach ($languages as $l) {
75
+ $pages[] = apply_filters('wpml_object_id', $id, 'page', true, $l['language_code']);
76
  }
77
  }
78
+ $pages = array_unique($pages);
79
  }
80
+ $pages = array_filter($pages);
81
 
82
+ if (!empty($pages)) {
83
+ foreach ($pages as $i => $page) {
84
+ $pages[$i] = preg_replace("/^\//", '', rtrim(str_replace(get_site_url(), '', get_permalink(absint($page))), '/')); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
85
  }
86
  }
87
+ $pages = array_unique($pages);
88
+ $pages = array_filter($pages);
89
 
90
+ $val = array_unique(array_merge($val, $pages));
91
+ do_action('litespeed_conf_force', 'cache-exc', $val);
92
  }
93
  }
94
  }
integrations/mycred.php CHANGED
@@ -1,313 +1,345 @@
1
- <?php
2
- /**
3
- * TI WooCommerce Wishlist integration with:
4
- *
5
- * @name myCRED
6
- *
7
- * @version 1.8.4.2
8
- *
9
- * @slug mycred
10
- *
11
- * @url https://wordpress.org/plugins/mycred/
12
- *
13
- */
14
-
15
- // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
- }
19
-
20
- // myCred hooks
21
- if ( defined( 'myCRED_VERSION' ) ) {
22
-
23
- /**
24
- * Register Hook
25
- */
26
- add_filter( 'mycred_setup_hooks', 'tinvwl_mycred_register_ti_woocommerce_wishlist_hook', 100 );
27
- function tinvwl_mycred_register_ti_woocommerce_wishlist_hook( $installed ) {
28
-
29
- $installed['tinvwl'] = array(
30
- 'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
31
- 'description' => __( 'Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist.', 'ti-woocommerce-wishlist' ),
32
- 'callback' => array( 'myCRED_Hook_TinvWL' ),
33
- );
34
-
35
- return $installed;
36
-
37
- }
38
-
39
- /**
40
- * TI WooCommerce Wihslist Hook
41
- */
42
- add_action( 'mycred_load_hooks', 'tinvwl_mycred_load_ti_woocommerce_wishlist_hook', 100 );
43
- function tinvwl_mycred_load_ti_woocommerce_wishlist_hook() {
44
-
45
- // If the hook has been replaced or if plugin is not installed, exit now
46
- if ( class_exists( 'myCRED_Hook_TinvWL' ) ) {
47
- return;
48
- }
49
-
50
- class myCRED_Hook_TinvWL extends myCRED_Hook {
51
-
52
- /**
53
- * Construct
54
- */
55
- public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
56
-
57
- parent::__construct( array(
58
- 'id' => 'tinvwl',
59
- 'defaults' => array(
60
- 'tinvwl_added' => array(
61
- 'creds' => 1,
62
- 'log' => '%plural% for adding a product to a wishlist',
63
- 'limit' => '0/x',
64
- ),
65
- 'tinvwl_purchased' => array(
66
- 'creds' => 1,
67
- 'log' => '%plural% for purchasing a product from a wishlist',
68
- 'limit' => '0/x',
69
- ),
70
- ),
71
- ), $hook_prefs, $type );
72
-
73
- }
74
-
75
- /**
76
- * Run
77
- */
78
- public function run() {
79
- add_action( 'tinvwl_product_added', array( $this, 'added' ) );
80
- add_action( 'tinvwl_product_purchased', array( $this, 'purchased' ), 10, 3 );
81
- }
82
-
83
- /**
84
- * Added product to a wishlist
85
- *
86
- * @param array $data product data including author and wishlist IDs.
87
- */
88
- public function added( $data ) {
89
-
90
- // Must be logged in
91
- if ( ! is_user_logged_in() ) {
92
- return;
93
- }
94
-
95
- $user_id = get_current_user_id();
96
-
97
- // Award the user adding to wishlist
98
- if ( $this->prefs['tinvwl_added']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
99
-
100
- // Limit
101
- if ( ! $this->over_hook_limit( 'tinvwl_added', 'added_to_wishlist', $user_id ) ) {
102
-
103
- // Make sure this is unique event
104
- if ( ! $this->core->has_entry( 'added_to_wishlist', $data['product_id'], $user_id ) ) {
105
-
106
- // Execute
107
- $this->core->add_creds(
108
- 'added_to_wishlist',
109
- $user_id,
110
- $this->prefs['tinvwl_added']['creds'],
111
- $this->prefs['tinvwl_added']['log'],
112
- $data['product_id'],
113
- array( 'ref_type' => 'post' ),
114
- $this->mycred_type
115
- );
116
-
117
- }
118
-
119
- }
120
-
121
- }
122
- }
123
-
124
- /**
125
- * Purchased product from a wishlist
126
- *
127
- * @param WC_order $order Order object.
128
- * @param WC_Order_Item_Product $item Order item product object.
129
- * @param array $wishlist A wishlist data where product added from.
130
- */
131
- public function purchased( $order, $item, $wishlist ) {
132
-
133
- // Must be logged in
134
- if ( ! is_user_logged_in() ) {
135
- return;
136
- }
137
-
138
- $user_id = get_current_user_id();
139
-
140
- // Award the user adding to wishlist
141
- if ( $this->prefs['tinvwl_purchased']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
142
-
143
- // Limit
144
- if ( ! $this->over_hook_limit( 'tinvwl_purchased', 'purchased_from_wishlist', $user_id ) ) {
145
-
146
- // Make sure this is unique event
147
- if ( ! $this->core->has_entry( 'purchased_from_wishlist', $item->get_id(), $user_id ) ) {
148
-
149
- // Execute
150
- $this->core->add_creds(
151
- 'purchased_from_wishlist',
152
- $user_id,
153
- $this->prefs['tinvwl_purchased']['creds'],
154
- $this->prefs['tinvwl_purchased']['log'],
155
- $item->get_id(),
156
- array( 'ref_type' => 'post' ),
157
- $this->mycred_type
158
- );
159
-
160
- }
161
-
162
- }
163
-
164
- }
165
-
166
- }
167
-
168
- /**
169
- * Preferences
170
- */
171
- public function preferences() {
172
-
173
- $prefs = $this->prefs;
174
-
175
- ?>
176
- <div class="hook-instance">
177
- <h3><?php _e( 'Adding Product to Wishlist', 'ti-woocommerce-wishlist' ); ?></h3>
178
- <div class="row">
179
- <div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
180
- <div class="form-group">
181
- <label
182
- for="<?php echo $this->field_id( array( 'tinvwl_added' => 'creds' ) ); ?>"><?php _e( 'Points', 'ti-woocommerce-wishlist' ); ?></label>
183
- <input type="text"
184
- name="<?php echo $this->field_name( array( 'tinvwl_added' => 'creds' ) ); ?>"
185
- id="<?php echo $this->field_id( array( 'tinvwl_added' => 'creds' ) ); ?>"
186
- value="<?php echo $this->core->number( $prefs['tinvwl_added']['creds'] ); ?>"
187
- class="form-control"/>
188
- </div>
189
- </div>
190
- <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
191
- <div class="form-group">
192
- <label for="<?php echo $this->field_id( array(
193
- 'tinvwl_added',
194
- 'limit',
195
- ) ); ?>"><?php _e( 'Limit', 'ti-woocommerce-wishlist' ); ?></label>
196
- <?php echo $this->hook_limit_setting( $this->field_name( array(
197
- 'tinvwl_added',
198
- 'limit',
199
- ) ), $this->field_id( array(
200
- 'tinvwl_added',
201
- 'limit',
202
- ) ), $prefs['tinvwl_added']['limit'] ); ?>
203
- </div>
204
- </div>
205
- <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
206
- <div class="form-group">
207
- <label
208
- for="<?php echo $this->field_id( array( 'tinvwl_added' => 'log' ) ); ?>"><?php _e( 'Log Template', 'ti-woocommerce-wishlist' ); ?></label>
209
- <input type="text"
210
- name="<?php echo $this->field_name( array( 'tinvwl_added' => 'log' ) ); ?>"
211
- id="<?php echo $this->field_id( array( 'tinvwl_added' => 'log' ) ); ?>"
212
- placeholder="<?php _e( 'required', 'ti-woocommerce-wishlist' ); ?>"
213
- value="<?php echo esc_attr( $prefs['tinvwl_added']['log'] ); ?>"
214
- class="form-control"/>
215
- <span class="description"><?php echo $this->available_template_tags( array(
216
- 'general',
217
- 'post',
218
- ) ); ?></span>
219
- </div>
220
- </div>
221
- </div>
222
- <h3><?php _e( 'Purchasing Product from Wishlist', 'ti-woocommerce-wishlist' ); ?></h3>
223
- <div class="row">
224
- <div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
225
- <div class="form-group">
226
- <label
227
- for="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'creds' ) ); ?>"><?php _e( 'Points', 'ti-woocommerce-wishlist' ); ?></label>
228
- <input type="text"
229
- name="<?php echo $this->field_name( array( 'tinvwl_purchased' => 'creds' ) ); ?>"
230
- id="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'creds' ) ); ?>"
231
- value="<?php echo $this->core->number( $prefs['tinvwl_purchased']['creds'] ); ?>"
232
- class="form-control"/>
233
- </div>
234
- </div>
235
- <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
236
- <div class="form-group">
237
- <label for="<?php echo $this->field_id( array(
238
- 'tinvwl_purchased',
239
- 'limit',
240
- ) ); ?>"><?php _e( 'Limit', 'ti-woocommerce-wishlist' ); ?></label>
241
- <?php echo $this->hook_limit_setting( $this->field_name( array(
242
- 'tinvwl_purchased',
243
- 'limit',
244
- ) ), $this->field_id( array(
245
- 'tinvwl_purchased',
246
- 'limit',
247
- ) ), $prefs['tinvwl_purchased']['limit'] ); ?>
248
- </div>
249
- </div>
250
- <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
251
- <div class="form-group">
252
- <label
253
- for="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'log' ) ); ?>"><?php _e( 'Log Template', 'ti-woocommerce-wishlist' ); ?></label>
254
- <input type="text"
255
- name="<?php echo $this->field_name( array( 'tinvwl_purchased' => 'log' ) ); ?>"
256
- id="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'log' ) ); ?>"
257
- placeholder="<?php _e( 'required', 'ti-woocommerce-wishlist' ); ?>"
258
- value="<?php echo esc_attr( $prefs['tinvwl_purchased']['log'] ); ?>"
259
- class="form-control"/>
260
- <span class="description"><?php echo $this->available_template_tags( array(
261
- 'general',
262
- 'post',
263
- ) ); ?></span>
264
- </div>
265
- </div>
266
- </div>
267
- </div>
268
-
269
- <?php
270
-
271
- }
272
-
273
- /**
274
- * Sanitise Preferences
275
- */
276
- public function sanitise_preferences( $data ) {
277
-
278
- if ( isset( $data['tinvwl_added']['limit'] ) && isset( $data['tinvwl_added']['limit_by'] ) ) {
279
- $limit = sanitize_text_field( $data['tinvwl_added']['limit'] );
280
- if ( $limit == '' ) {
281
- $limit = 0;
282
- }
283
- $data['tinvwl_added']['limit'] = $limit . '/' . $data['tinvwl_added']['limit_by'];
284
- unset( $data['tinvwl_added']['limit_by'] );
285
- }
286
-
287
- if ( isset( $data['tinvwl_purchased']['limit'] ) && isset( $data['tinvwl_purchased']['limit_by'] ) ) {
288
- $limit = sanitize_text_field( $data['tinvwl_purchased']['limit'] );
289
- if ( $limit == '' ) {
290
- $limit = 0;
291
- }
292
- $data['tinvwl_purchased']['limit'] = $limit . '/' . $data['tinvwl_purchased']['limit_by'];
293
- unset( $data['tinvwl_purchased']['limit_by'] );
294
- }
295
-
296
- return $data;
297
-
298
- }
299
-
300
- }
301
-
302
- }
303
-
304
- add_filter( 'mycred_all_references', 'tinvwl_mycred_references' );
305
-
306
- function tinvwl_mycred_references( $references ) {
307
-
308
- $references['purchased_from_wishlist'] = __( 'Purchased From Wishlist', 'ti-woocommerce-wishlist' );
309
- $references['added_to_wishlist'] = __( 'Added To Wishlist', 'ti-woocommerce-wishlist' );
310
-
311
- return $references;
312
- }
313
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TI WooCommerce Wishlist integration with:
4
+ *
5
+ * @name myCRED
6
+ *
7
+ * @version 1.8.4.2
8
+ *
9
+ * @slug mycred
10
+ *
11
+ * @url https://wordpress.org/plugins/mycred/
12
+ *
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "mycred";
24
+
25
+ $name = "myCRED";
26
+
27
+ $available = defined('myCRED_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ // myCred hooks
43
+ if (defined('myCRED_VERSION')) {
44
+
45
+ /**
46
+ * Register Hook
47
+ */
48
+ add_filter('mycred_setup_hooks', 'tinvwl_mycred_register_ti_woocommerce_wishlist_hook', 100);
49
+ function tinvwl_mycred_register_ti_woocommerce_wishlist_hook($installed)
50
+ {
51
+
52
+ $installed['tinvwl'] = array(
53
+ 'title' => __('WooCommerce Wishlist', 'ti-woocommerce-wishlist'),
54
+ 'description' => __('Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist.', 'ti-woocommerce-wishlist'),
55
+ 'callback' => array('myCRED_Hook_TinvWL'),
56
+ );
57
+
58
+ return $installed;
59
+
60
+ }
61
+
62
+ /**
63
+ * TI WooCommerce Wihslist Hook
64
+ */
65
+ add_action('mycred_load_hooks', 'tinvwl_mycred_load_ti_woocommerce_wishlist_hook', 100);
66
+ function tinvwl_mycred_load_ti_woocommerce_wishlist_hook()
67
+ {
68
+
69
+ // If the hook has been replaced or if plugin is not installed, exit now
70
+ if (class_exists('myCRED_Hook_TinvWL')) {
71
+ return;
72
+ }
73
+
74
+ class myCRED_Hook_TinvWL extends myCRED_Hook
75
+ {
76
+
77
+ /**
78
+ * Construct
79
+ */
80
+ public function __construct($hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY)
81
+ {
82
+
83
+ parent::__construct(array(
84
+ 'id' => 'tinvwl',
85
+ 'defaults' => array(
86
+ 'tinvwl_added' => array(
87
+ 'creds' => 1,
88
+ 'log' => '%plural% for adding a product to a wishlist',
89
+ 'limit' => '0/x',
90
+ ),
91
+ 'tinvwl_purchased' => array(
92
+ 'creds' => 1,
93
+ 'log' => '%plural% for purchasing a product from a wishlist',
94
+ 'limit' => '0/x',
95
+ ),
96
+ ),
97
+ ), $hook_prefs, $type);
98
+
99
+ }
100
+
101
+ /**
102
+ * Run
103
+ */
104
+ public function run()
105
+ {
106
+ add_action('tinvwl_product_added', array($this, 'added'));
107
+ add_action('tinvwl_product_purchased', array($this, 'purchased'), 10, 3);
108
+ }
109
+
110
+ /**
111
+ * Added product to a wishlist
112
+ *
113
+ * @param array $data product data including author and wishlist IDs.
114
+ */
115
+ public function added($data)
116
+ {
117
+
118
+ // Must be logged in
119
+ if (!is_user_logged_in()) {
120
+ return;
121
+ }
122
+
123
+ $user_id = get_current_user_id();
124
+
125
+ // Award the user adding to wishlist
126
+ if ($this->prefs['tinvwl_added']['creds'] != 0 && !$this->core->exclude_user($user_id)) {
127
+
128
+ // Limit
129
+ if (!$this->over_hook_limit('tinvwl_added', 'added_to_wishlist', $user_id)) {
130
+
131
+ // Make sure this is unique event
132
+ if (!$this->core->has_entry('added_to_wishlist', $data['product_id'], $user_id)) {
133
+
134
+ // Execute
135
+ $this->core->add_creds(
136
+ 'added_to_wishlist',
137
+ $user_id,
138
+ $this->prefs['tinvwl_added']['creds'],
139
+ $this->prefs['tinvwl_added']['log'],
140
+ $data['product_id'],
141
+ array('ref_type' => 'post'),
142
+ $this->mycred_type
143
+ );
144
+
145
+ }
146
+
147
+ }
148
+
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Purchased product from a wishlist
154
+ *
155
+ * @param WC_order $order Order object.
156
+ * @param WC_Order_Item_Product $item Order item product object.
157
+ * @param array $wishlist A wishlist data where product added from.
158
+ */
159
+ public function purchased($order, $item, $wishlist)
160
+ {
161
+
162
+ // Must be logged in
163
+ if (!is_user_logged_in()) {
164
+ return;
165
+ }
166
+
167
+ $user_id = get_current_user_id();
168
+
169
+ // Award the user adding to wishlist
170
+ if ($this->prefs['tinvwl_purchased']['creds'] != 0 && !$this->core->exclude_user($user_id)) {
171
+
172
+ // Limit
173
+ if (!$this->over_hook_limit('tinvwl_purchased', 'purchased_from_wishlist', $user_id)) {
174
+
175
+ // Make sure this is unique event
176
+ if (!$this->core->has_entry('purchased_from_wishlist', $item->get_id(), $user_id)) {
177
+
178
+ // Execute
179
+ $this->core->add_creds(
180
+ 'purchased_from_wishlist',
181
+ $user_id,
182
+ $this->prefs['tinvwl_purchased']['creds'],
183
+ $this->prefs['tinvwl_purchased']['log'],
184
+ $item->get_id(),
185
+ array('ref_type' => 'post'),
186
+ $this->mycred_type
187
+ );
188
+
189
+ }
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ /**
198
+ * Preferences
199
+ */
200
+ public function preferences()
201
+ {
202
+
203
+ $prefs = $this->prefs;
204
+
205
+ ?>
206
+ <div class="hook-instance">
207
+ <h3><?php _e('Adding Product to Wishlist', 'ti-woocommerce-wishlist'); ?></h3>
208
+ <div class="row">
209
+ <div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
210
+ <div class="form-group">
211
+ <label
212
+ for="<?php echo $this->field_id(array('tinvwl_added' => 'creds')); ?>"><?php _e('Points', 'ti-woocommerce-wishlist'); ?></label>
213
+ <input type="text"
214
+ name="<?php echo $this->field_name(array('tinvwl_added' => 'creds')); ?>"
215
+ id="<?php echo $this->field_id(array('tinvwl_added' => 'creds')); ?>"
216
+ value="<?php echo $this->core->number($prefs['tinvwl_added']['creds']); ?>"
217
+ class="form-control"/>
218
+ </div>
219
+ </div>
220
+ <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
221
+ <div class="form-group">
222
+ <label for="<?php echo $this->field_id(array(
223
+ 'tinvwl_added',
224
+ 'limit',
225
+ )); ?>"><?php _e('Limit', 'ti-woocommerce-wishlist'); ?></label>
226
+ <?php echo $this->hook_limit_setting($this->field_name(array(
227
+ 'tinvwl_added',
228
+ 'limit',
229
+ )), $this->field_id(array(
230
+ 'tinvwl_added',
231
+ 'limit',
232
+ )), $prefs['tinvwl_added']['limit']); ?>
233
+ </div>
234
+ </div>
235
+ <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
236
+ <div class="form-group">
237
+ <label
238
+ for="<?php echo $this->field_id(array('tinvwl_added' => 'log')); ?>"><?php _e('Log Template', 'ti-woocommerce-wishlist'); ?></label>
239
+ <input type="text"
240
+ name="<?php echo $this->field_name(array('tinvwl_added' => 'log')); ?>"
241
+ id="<?php echo $this->field_id(array('tinvwl_added' => 'log')); ?>"
242
+ placeholder="<?php _e('required', 'ti-woocommerce-wishlist'); ?>"
243
+ value="<?php echo esc_attr($prefs['tinvwl_added']['log']); ?>"
244
+ class="form-control"/>
245
+ <span class="description"><?php echo $this->available_template_tags(array(
246
+ 'general',
247
+ 'post',
248
+ )); ?></span>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ <h3><?php _e('Purchasing Product from Wishlist', 'ti-woocommerce-wishlist'); ?></h3>
253
+ <div class="row">
254
+ <div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
255
+ <div class="form-group">
256
+ <label
257
+ for="<?php echo $this->field_id(array('tinvwl_purchased' => 'creds')); ?>"><?php _e('Points', 'ti-woocommerce-wishlist'); ?></label>
258
+ <input type="text"
259
+ name="<?php echo $this->field_name(array('tinvwl_purchased' => 'creds')); ?>"
260
+ id="<?php echo $this->field_id(array('tinvwl_purchased' => 'creds')); ?>"
261
+ value="<?php echo $this->core->number($prefs['tinvwl_purchased']['creds']); ?>"
262
+ class="form-control"/>
263
+ </div>
264
+ </div>
265
+ <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
266
+ <div class="form-group">
267
+ <label for="<?php echo $this->field_id(array(
268
+ 'tinvwl_purchased',
269
+ 'limit',
270
+ )); ?>"><?php _e('Limit', 'ti-woocommerce-wishlist'); ?></label>
271
+ <?php echo $this->hook_limit_setting($this->field_name(array(
272
+ 'tinvwl_purchased',
273
+ 'limit',
274
+ )), $this->field_id(array(
275
+ 'tinvwl_purchased',
276
+ 'limit',
277
+ )), $prefs['tinvwl_purchased']['limit']); ?>
278
+ </div>
279
+ </div>
280
+ <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
281
+ <div class="form-group">
282
+ <label
283
+ for="<?php echo $this->field_id(array('tinvwl_purchased' => 'log')); ?>"><?php _e('Log Template', 'ti-woocommerce-wishlist'); ?></label>
284
+ <input type="text"
285
+ name="<?php echo $this->field_name(array('tinvwl_purchased' => 'log')); ?>"
286
+ id="<?php echo $this->field_id(array('tinvwl_purchased' => 'log')); ?>"
287
+ placeholder="<?php _e('required', 'ti-woocommerce-wishlist'); ?>"
288
+ value="<?php echo esc_attr($prefs['tinvwl_purchased']['log']); ?>"
289
+ class="form-control"/>
290
+ <span class="description"><?php echo $this->available_template_tags(array(
291
+ 'general',
292
+ 'post',
293
+ )); ?></span>
294
+ </div>
295
+ </div>
296
+ </div>
297
+ </div>
298
+
299
+ <?php
300
+
301
+ }
302
+
303
+ /**
304
+ * Sanitise Preferences
305
+ */
306
+ public function sanitise_preferences($data)
307
+ {
308
+
309
+ if (isset($data['tinvwl_added']['limit']) && isset($data['tinvwl_added']['limit_by'])) {
310
+ $limit = sanitize_text_field($data['tinvwl_added']['limit']);
311
+ if ($limit == '') {
312
+ $limit = 0;
313
+ }
314
+ $data['tinvwl_added']['limit'] = $limit . '/' . $data['tinvwl_added']['limit_by'];
315
+ unset($data['tinvwl_added']['limit_by']);
316
+ }
317
+
318
+ if (isset($data['tinvwl_purchased']['limit']) && isset($data['tinvwl_purchased']['limit_by'])) {
319
+ $limit = sanitize_text_field($data['tinvwl_purchased']['limit']);
320
+ if ($limit == '') {
321
+ $limit = 0;
322
+ }
323
+ $data['tinvwl_purchased']['limit'] = $limit . '/' . $data['tinvwl_purchased']['limit_by'];
324
+ unset($data['tinvwl_purchased']['limit_by']);
325
+ }
326
+
327
+ return $data;
328
+
329
+ }
330
+
331
+ }
332
+
333
+ }
334
+
335
+ add_filter('mycred_all_references', 'tinvwl_mycred_references');
336
+
337
+ function tinvwl_mycred_references($references)
338
+ {
339
+
340
+ $references['purchased_from_wishlist'] = __('Purchased From Wishlist', 'ti-woocommerce-wishlist');
341
+ $references['added_to_wishlist'] = __('Added To Wishlist', 'ti-woocommerce-wishlist');
342
+
343
+ return $references;
344
+ }
345
+ }
integrations/product-extras-for-woocommerce.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_item_meta_pewc' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Product Add-Ons Ultimate
@@ -29,90 +51,91 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_pewc' ) ) {
29
  * @return array
30
  */
31
 
32
- function tinv_wishlist_item_meta_pewc( $item_data, $product_id, $variation_id ) {
 
33
 
34
- if ( defined( 'PEWC_FILE' ) ) {
35
  // Check for product_extra groups
36
- $product_extra_groups = pewc_get_extra_fields( $product_id );
37
- $hidden_group_types = apply_filters( 'pewc_hidden_field_types_in_cart', array() );
38
- if ( $product_extra_groups ) {
39
 
40
- foreach ( $product_extra_groups as $group ) {
41
 
42
- if ( isset( $group['items'] ) ) {
43
 
44
- foreach ( $group['items'] as $item ) {
45
 
46
 
47
- if ( in_array( $item['field_type'], $hidden_group_types ) ) {
48
  // Don't add this to the cart if it's a hidden field type
49
  continue;
50
  }
51
 
52
  // Don't display hidden fields
53
- if ( isset( $item['hidden_calculation'] ) ) {
54
  continue;
55
  }
56
 
57
  // Added in 3.5.3 to allow us to link parent products with children in cart
58
- $display_product_meta = apply_filters( 'pewc_display_child_product_meta', false, $item );
59
 
60
- if ( isset( $item['field_type'] ) ) {
61
 
62
- if ( $item['field_type'] == 'products' && ! $display_product_meta ) {
63
  continue;
64
  }
65
 
66
  $price = '';
67
 
68
- if ( isset( $item['field_flatrate'] ) ) {
69
- $price = '<span class="pewc-flat-rate-cart-label">(' . __( 'Flat rate cost', 'ti-woocommerce-wishlist' ) . ')</span>';
70
  }
71
 
72
- $price = apply_filters( 'pewc_filter_cart_item_price', $price, $item );
73
 
74
- $item['label'] = isset( $item['field_label'] ) ? sanitize_text_field( $item['field_label'] ) : '';
75
 
76
- $value = ( isset( $item_data[ $item['id'] ] ) && isset( $item_data[ $item['id'] ]['display'] ) ) ? $item_data[ $item['id'] ]['display'] : '';
77
 
78
- if ( $item['field_type'] == 'textarea' ) {
79
- $value = sanitize_textarea_field( stripslashes( $value ) );
80
- } else if ( in_array( $item['field_type'], array(
81
  'image_swatch',
82
  'radio',
83
  'upload'
84
- ) ) ) {
85
- $value = wp_kses_post( stripslashes( $value[0] ) );
86
  } else {
87
- $value = sanitize_text_field( stripslashes( $value ) );
88
  }
89
 
90
  $item['value'] = $value;
91
 
92
- if ( $item['field_type'] == 'upload' || $item['field_type'] == 'information' ) {
93
  continue;
94
  }
95
 
96
- if ( $item['field_type'] == 'checkbox' ) {
97
  $item_data[] = array(
98
- 'key' => sanitize_text_field( $item['label'] ),
99
- 'display' => '<span class="pewc-price pewc-cart-item-price">' . sanitize_text_field( $price ) . '</span>',
100
  );
101
- } else if ( $item['field_type'] == 'checkbox_group' ) {
102
  $item_data[] = array(
103
- 'key' => sanitize_text_field( $item['label'] ),
104
- 'display' => str_replace( ' | ', '<br>', $item['value'] ),
105
  );
106
- } else if ( $item['field_type'] == 'name_price' ) {
107
- $value = wc_price( $item['value'] );
108
  $item_data[] = array(
109
- 'key' => sanitize_text_field( $item['label'] ),
110
- 'display' => sanitize_text_field( $value ),
111
  );
112
  } else {
113
  $item_data[] = array(
114
- 'key' => sanitize_text_field( $item['label'] ),
115
- 'display' => sanitize_text_field( $item['value'] ),
116
  );
117
  }
118
  }
@@ -122,19 +145,19 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_pewc' ) ) {
122
  }
123
  }
124
 
125
- foreach ( array_keys( $item_data ) as $key ) {
126
- if ( strpos( $key, 'pewc' ) === 0 ) {
127
- unset( $item_data[ $key ] );
128
  }
129
  }
130
 
131
  return $item_data;
132
  }
133
 
134
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_pewc', 10, 3 );
135
  }
136
 
137
- if ( ! function_exists( 'tinvwl_item_price_pewc' ) ) {
138
 
139
  /**
140
  * Modify price for WooCommerce Product Add-Ons Ultimate
@@ -145,67 +168,68 @@ if ( ! function_exists( 'tinvwl_item_price_pewc' ) ) {
145
  *
146
  * @return string
147
  */
148
- function tinvwl_item_price_pewc( $price, $wl_product, $product ) {
 
149
 
150
- if ( defined( 'PEWC_FILE' ) ) {
151
 
152
  $product_price = $product->get_price();
153
- $product_id = $product->get_id();
154
- $extra_price = 0;
155
 
156
- $product_extra_groups = pewc_get_extra_fields( $product_id );
157
 
158
- if ( $product_extra_groups ) {
159
 
160
- foreach ( $product_extra_groups as $group ) {
161
 
162
- if ( isset( $group['items'] ) ) {
163
 
164
- foreach ( $group['items'] as $item ) {
165
 
166
- $show_option_prices_in_cart = pewc_show_option_prices_in_cart( $item );
167
 
168
 
169
- $group_id = $item['group_id'];
170
- $field_id = $item['field_id'];
171
  $field_type = $item['field_type'];
172
 
173
- if ( isset( $item['field_type'] ) && $item['field_type'] != 'upload' && $item['field_type'] != 'products' ) {
174
 
175
- $id = $item['id'];
176
  $price = 0;
177
- $value = isset( $wl_product['meta'][ $id ] ) ? $wl_product['meta'][ $id ] : '';
178
 
179
 
180
  // If an extra is flat rate, it's not charged per product
181
  // It's a one-off fee that's added separately in the cart
182
- $is_flat_rate = isset( $item['field_flatrate'] ) ? true : false;
183
 
184
- $is_percentage = ! empty( $item['field_percentage'] ) ? true : false;
185
 
186
  // Only add item if it's visible
187
- if ( ! empty( $wl_product['meta'][ $id ] ) ) {
188
 
189
- $field_price = pewc_get_field_price( $item, $product );
190
 
191
  // Add the value of the field (not including the value of options)
192
- if ( ! $is_flat_rate ) {
193
- $price = floatval( $field_price );
194
  }
195
 
196
  // Check for Name Your Price
197
- if ( $field_type == 'name_price' ) {
198
- if ( ! $is_flat_rate ) {
199
  $price = $value;
200
  }
201
  }
202
 
203
  // Check for Calculation fields
204
- if ( $field_type == 'calculation' ) {
205
 
206
- if ( isset( $item['formula_action'] ) && $item['formula_action'] == 'cost' ) {
207
 
208
- if ( ! $is_flat_rate ) {
209
  $price = $value;
210
  }
211
 
@@ -214,75 +238,75 @@ if ( ! function_exists( 'tinvwl_item_price_pewc' ) ) {
214
  }
215
 
216
  // Calculate price for per character fields
217
- if ( ! empty( $item['per_character'] ) && ( $field_type == 'text' || $field_type == 'textarea' ) ) {
218
- $remove_line_breaks = preg_replace( "/\r|\n/", "", $value );
219
- $str_length = mb_strlen( str_replace( ' ', '', $remove_line_breaks ) );
220
- if ( ! empty( $item['field_freechars'] ) ) {
221
- $str_length -= absint( $item['field_freechars'] );
222
- $str_length = max( 0, $str_length );
223
  }
224
- if ( ! $is_flat_rate ) {
225
  $price = $str_length * $price;
226
  }
227
  }
228
 
229
  // Calculate price for multiply fields
230
- if ( ! empty( $item['multiply'] ) && ( $field_type == 'number' || $field_type == 'name_price' ) ) {
231
- if ( ! $is_flat_rate ) {
232
  $price = $value * $price;
233
  }
234
  }
235
 
236
  // Calculate price for percentage fields
237
- if ( $is_percentage && $field_type != 'calculation' ) {
238
- if ( ! $is_flat_rate ) {
239
- $price = pewc_calculate_percentage_price( $field_price, $product );
240
  // $price = $value * $price;
241
  }
242
  }
243
 
244
  // Filtered by Bookings to include per unit cost for extras
245
- $price = apply_filters( 'pewc_filter_cart_item_data_price', $price, array(), $item, $group_id, $field_id );
246
 
247
  // Find any additional cost for options and select fields
248
- if ( ! empty( $item['field_options'] ) ) {
249
 
250
  // Record checkbox group values differently
251
  $checkbox_group_values = array();
252
  // Radio buttons are arrays, select are simple values
253
- if ( $field_type == 'radio' || ( $field_type == 'image_swatch' && empty( $item['allow_multiple'] ) ) ) {
254
  $option_value = $value[0];
255
  } else {
256
  $option_value = $value;
257
  }
258
 
259
 
260
- foreach ( $item['field_options'] as $option ) {
261
 
262
  // If it's a checkbox group, we need to total all selected options
263
- if ( $field_type == 'checkbox_group' || ( $field_type == 'image_swatch' && ! empty( $item['allow_multiple'] ) ) ) {
264
 
265
- if ( ! empty( $option['price'] ) && in_array( $option['value'], $option_value ) ) {
266
  $option_price = $option['price'];
267
- if ( $is_percentage ) {
268
- $option_price = pewc_calculate_percentage_price( $option_price, $product );
269
  }
270
 
271
- if ( ! $is_flat_rate ) {
272
- $price += floatval( $option_price );
273
- $option_price = pewc_maybe_include_tax( $product, $option_price );
274
- $checkbox_group_values[] = $show_option_prices_in_cart === true ? $option['value'] . ' (' . wc_price( $option_price ) . ')' : $option['value'];
275
  }
276
  }
277
 
278
- } else if ( ! empty( $option['price'] ) && $option['value'] == $option_value ) {
279
  $option_price = $option['price'];
280
- if ( $is_percentage ) {
281
- $option_price = pewc_calculate_percentage_price( $option_price, $product );
282
  }
283
 
284
- if ( ! $is_flat_rate ) {
285
- $price += floatval( $option_price );
286
  break;
287
  }
288
  }
@@ -293,20 +317,20 @@ if ( ! function_exists( 'tinvwl_item_price_pewc' ) ) {
293
  }
294
 
295
  // Filter the price of the product extra
296
- $price = apply_filters( 'pewc_add_cart_item_data_price', $price, $item, $product_id );
297
 
298
- $extra_price += floatval( $price );
299
  }
300
  }
301
  }
302
 
303
  // Ensure price can't be less than 0
304
- $new_price = floatval( $product_price ) + floatval( $extra_price );
305
- if ( $new_price < 0 ) {
306
  $new_price = 0;
307
  }
308
 
309
- return wc_price( $new_price );
310
  }
311
  }
312
  }
@@ -315,5 +339,5 @@ if ( ! function_exists( 'tinvwl_item_price_pewc' ) ) {
315
  return $price;
316
  }
317
 
318
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_pewc', 10, 3 );
319
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "product-extras-for-woocommerce";
24
+
25
+ $name = "WooCommerce Product Add-Ons Ultimate";
26
+
27
+ $available = defined('PEWC_FILE');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_item_meta_pewc')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Product Add-Ons Ultimate
51
  * @return array
52
  */
53
 
54
+ function tinv_wishlist_item_meta_pewc($item_data, $product_id, $variation_id)
55
+ {
56
 
57
+ if (defined('PEWC_FILE')) {
58
  // Check for product_extra groups
59
+ $product_extra_groups = pewc_get_extra_fields($product_id);
60
+ $hidden_group_types = apply_filters('pewc_hidden_field_types_in_cart', array());
61
+ if ($product_extra_groups) {
62
 
63
+ foreach ($product_extra_groups as $group) {
64
 
65
+ if (isset($group['items'])) {
66
 
67
+ foreach ($group['items'] as $item) {
68
 
69
 
70
+ if (in_array($item['field_type'], $hidden_group_types)) {
71
  // Don't add this to the cart if it's a hidden field type
72
  continue;
73
  }
74
 
75
  // Don't display hidden fields
76
+ if (isset($item['hidden_calculation'])) {
77
  continue;
78
  }
79
 
80
  // Added in 3.5.3 to allow us to link parent products with children in cart
81
+ $display_product_meta = apply_filters('pewc_display_child_product_meta', false, $item);
82
 
83
+ if (isset($item['field_type'])) {
84
 
85
+ if ($item['field_type'] == 'products' && !$display_product_meta) {
86
  continue;
87
  }
88
 
89
  $price = '';
90
 
91
+ if (isset($item['field_flatrate'])) {
92
+ $price = '<span class="pewc-flat-rate-cart-label">(' . __('Flat rate cost', 'ti-woocommerce-wishlist') . ')</span>';
93
  }
94
 
95
+ $price = apply_filters('pewc_filter_cart_item_price', $price, $item);
96
 
97
+ $item['label'] = isset($item['field_label']) ? sanitize_text_field($item['field_label']) : '';
98
 
99
+ $value = (isset($item_data[$item['id']]) && isset($item_data[$item['id']]['display'])) ? $item_data[$item['id']]['display'] : '';
100
 
101
+ if ($item['field_type'] == 'textarea') {
102
+ $value = sanitize_textarea_field(stripslashes($value));
103
+ } else if (in_array($item['field_type'], array(
104
  'image_swatch',
105
  'radio',
106
  'upload'
107
+ ))) {
108
+ $value = wp_kses_post(stripslashes($value[0]));
109
  } else {
110
+ $value = sanitize_text_field(stripslashes($value));
111
  }
112
 
113
  $item['value'] = $value;
114
 
115
+ if ($item['field_type'] == 'upload' || $item['field_type'] == 'information') {
116
  continue;
117
  }
118
 
119
+ if ($item['field_type'] == 'checkbox') {
120
  $item_data[] = array(
121
+ 'key' => sanitize_text_field($item['label']),
122
+ 'display' => '<span class="pewc-price pewc-cart-item-price">' . sanitize_text_field($price) . '</span>',
123
  );
124
+ } else if ($item['field_type'] == 'checkbox_group') {
125
  $item_data[] = array(
126
+ 'key' => sanitize_text_field($item['label']),
127
+ 'display' => str_replace(' | ', '<br>', $item['value']),
128
  );
129
+ } else if ($item['field_type'] == 'name_price') {
130
+ $value = wc_price($item['value']);
131
  $item_data[] = array(
132
+ 'key' => sanitize_text_field($item['label']),
133
+ 'display' => sanitize_text_field($value),
134
  );
135
  } else {
136
  $item_data[] = array(
137
+ 'key' => sanitize_text_field($item['label']),
138
+ 'display' => sanitize_text_field($item['value']),
139
  );
140
  }
141
  }
145
  }
146
  }
147
 
148
+ foreach (array_keys($item_data) as $key) {
149
+ if (strpos($key, 'pewc') === 0) {
150
+ unset($item_data[$key]);
151
  }
152
  }
153
 
154
  return $item_data;
155
  }
156
 
157
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_pewc', 10, 3);
158
  }
159
 
160
+ if (!function_exists('tinvwl_item_price_pewc')) {
161
 
162
  /**
163
  * Modify price for WooCommerce Product Add-Ons Ultimate
168
  *
169
  * @return string
170
  */
171
+ function tinvwl_item_price_pewc($price, $wl_product, $product)
172
+ {
173
 
174
+ if (defined('PEWC_FILE')) {
175
 
176
  $product_price = $product->get_price();
177
+ $product_id = $product->get_id();
178
+ $extra_price = 0;
179
 
180
+ $product_extra_groups = pewc_get_extra_fields($product_id);
181
 
182
+ if ($product_extra_groups) {
183
 
184
+ foreach ($product_extra_groups as $group) {
185
 
186
+ if (isset($group['items'])) {
187
 
188
+ foreach ($group['items'] as $item) {
189
 
190
+ $show_option_prices_in_cart = pewc_show_option_prices_in_cart($item);
191
 
192
 
193
+ $group_id = $item['group_id'];
194
+ $field_id = $item['field_id'];
195
  $field_type = $item['field_type'];
196
 
197
+ if (isset($item['field_type']) && $item['field_type'] != 'upload' && $item['field_type'] != 'products') {
198
 
199
+ $id = $item['id'];
200
  $price = 0;
201
+ $value = isset($wl_product['meta'][$id]) ? $wl_product['meta'][$id] : '';
202
 
203
 
204
  // If an extra is flat rate, it's not charged per product
205
  // It's a one-off fee that's added separately in the cart
206
+ $is_flat_rate = isset($item['field_flatrate']) ? true : false;
207
 
208
+ $is_percentage = !empty($item['field_percentage']) ? true : false;
209
 
210
  // Only add item if it's visible
211
+ if (!empty($wl_product['meta'][$id])) {
212
 
213
+ $field_price = pewc_get_field_price($item, $product);
214
 
215
  // Add the value of the field (not including the value of options)
216
+ if (!$is_flat_rate) {
217
+ $price = floatval($field_price);
218
  }
219
 
220
  // Check for Name Your Price
221
+ if ($field_type == 'name_price') {
222
+ if (!$is_flat_rate) {
223
  $price = $value;
224
  }
225
  }
226
 
227
  // Check for Calculation fields
228
+ if ($field_type == 'calculation') {
229
 
230
+ if (isset($item['formula_action']) && $item['formula_action'] == 'cost') {
231
 
232
+ if (!$is_flat_rate) {
233
  $price = $value;
234
  }
235
 
238
  }
239
 
240
  // Calculate price for per character fields
241
+ if (!empty($item['per_character']) && ($field_type == 'text' || $field_type == 'textarea')) {
242
+ $remove_line_breaks = preg_replace("/\r|\n/", "", $value);
243
+ $str_length = mb_strlen(str_replace(' ', '', $remove_line_breaks));
244
+ if (!empty($item['field_freechars'])) {
245
+ $str_length -= absint($item['field_freechars']);
246
+ $str_length = max(0, $str_length);
247
  }
248
+ if (!$is_flat_rate) {
249
  $price = $str_length * $price;
250
  }
251
  }
252
 
253
  // Calculate price for multiply fields
254
+ if (!empty($item['multiply']) && ($field_type == 'number' || $field_type == 'name_price')) {
255
+ if (!$is_flat_rate) {
256
  $price = $value * $price;
257
  }
258
  }
259
 
260
  // Calculate price for percentage fields
261
+ if ($is_percentage && $field_type != 'calculation') {
262
+ if (!$is_flat_rate) {
263
+ $price = pewc_calculate_percentage_price($field_price, $product);
264
  // $price = $value * $price;
265
  }
266
  }
267
 
268
  // Filtered by Bookings to include per unit cost for extras
269
+ $price = apply_filters('pewc_filter_cart_item_data_price', $price, array(), $item, $group_id, $field_id);
270
 
271
  // Find any additional cost for options and select fields
272
+ if (!empty($item['field_options'])) {
273
 
274
  // Record checkbox group values differently
275
  $checkbox_group_values = array();
276
  // Radio buttons are arrays, select are simple values
277
+ if ($field_type == 'radio' || ($field_type == 'image_swatch' && empty($item['allow_multiple']))) {
278
  $option_value = $value[0];
279
  } else {
280
  $option_value = $value;
281
  }
282
 
283
 
284
+ foreach ($item['field_options'] as $option) {
285
 
286
  // If it's a checkbox group, we need to total all selected options
287
+ if ($field_type == 'checkbox_group' || ($field_type == 'image_swatch' && !empty($item['allow_multiple']))) {
288
 
289
+ if (!empty($option['price']) && in_array($option['value'], $option_value)) {
290
  $option_price = $option['price'];
291
+ if ($is_percentage) {
292
+ $option_price = pewc_calculate_percentage_price($option_price, $product);
293
  }
294
 
295
+ if (!$is_flat_rate) {
296
+ $price += floatval($option_price);
297
+ $option_price = pewc_maybe_include_tax($product, $option_price);
298
+ $checkbox_group_values[] = $show_option_prices_in_cart === true ? $option['value'] . ' (' . wc_price($option_price) . ')' : $option['value'];
299
  }
300
  }
301
 
302
+ } else if (!empty($option['price']) && $option['value'] == $option_value) {
303
  $option_price = $option['price'];
304
+ if ($is_percentage) {
305
+ $option_price = pewc_calculate_percentage_price($option_price, $product);
306
  }
307
 
308
+ if (!$is_flat_rate) {
309
+ $price += floatval($option_price);
310
  break;
311
  }
312
  }
317
  }
318
 
319
  // Filter the price of the product extra
320
+ $price = apply_filters('pewc_add_cart_item_data_price', $price, $item, $product_id);
321
 
322
+ $extra_price += floatval($price);
323
  }
324
  }
325
  }
326
 
327
  // Ensure price can't be less than 0
328
+ $new_price = floatval($product_price) + floatval($extra_price);
329
+ if ($new_price < 0) {
330
  $new_price = 0;
331
  }
332
 
333
+ return wc_price($new_price);
334
  }
335
  }
336
  }
339
  return $price;
340
  }
341
 
342
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_pewc', 10, 3);
343
  } // End if().
integrations/pw-woocommerce-gift-cards.php CHANGED
@@ -14,7 +14,29 @@
14
 
15
  // If this file is called directly, abort.
16
  if (!defined('ABSPATH')) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  if (defined('PWGC_VERSION')) {
14
 
15
  // If this file is called directly, abort.
16
  if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "pw-woocommerce-gift-cards";
24
+
25
+ $name = "PW WooCommerce Gift Cards";
26
+
27
+ $available = defined('PWGC_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  if (defined('PWGC_VERSION')) {
integrations/show-single-variations.php CHANGED
@@ -13,15 +13,38 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( class_exists( 'Iconic_WSSV_Product_Variation' ) && ! function_exists( 'tinvwl_product_visibility_fix' ) ) {
 
21
 
22
- add_action( 'tinvwl_wishlist_contents_before', 'tinvwl_product_visibility_fix' );
23
 
24
- function tinvwl_product_visibility_fix() {
25
- add_filter( 'woocommerce_product_is_visible', '__return_true', 100, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
 
23
+ $slug = "show-single-variations-premium";
24
 
25
+ $name = "WooCommerce Show Single Variations by Iconic";
26
+
27
+ $available = class_exists('Iconic_WSSV_Product_Variation');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (class_exists('Iconic_WSSV_Product_Variation') && !function_exists('tinvwl_product_visibility_fix')) {
43
+
44
+ add_action('tinvwl_wishlist_contents_before', 'tinvwl_product_visibility_fix');
45
+
46
+ function tinvwl_product_visibility_fix()
47
+ {
48
+ add_filter('woocommerce_product_is_visible', '__return_true', 100, 2);
49
  }
50
  }
integrations/sitepress-multilingual-cms.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_wpml_product_get' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Change product data if product need translate
@@ -26,26 +48,27 @@ if ( ! function_exists( 'tinvwl_wpml_product_get' ) ) {
26
  *
27
  * @return array
28
  */
29
- function tinvwl_wpml_product_get( $product ) {
30
- if ( array_key_exists( 'data', $product ) ) {
31
- $_product_id = $product_id = $product['product_id'];
 
32
  $_variation_id = $variation_id = $product['variation_id'];
33
- $_product_id = apply_filters( 'wpml_object_id', $_product_id, 'product', true );
34
- if ( ! empty( $_variation_id ) ) {
35
- $_variation_id = apply_filters( 'wpml_object_id', $_variation_id, 'product', true );
36
  }
37
- if ( $_product_id !== $product_id || $_variation_id !== $variation_id ) {
38
- $product['data'] = wc_get_product( $variation_id ? $_variation_id : $_product_id );
39
  }
40
  }
41
 
42
  return $product;
43
  }
44
 
45
- add_filter( 'tinvwl_wishlist_product_get', 'tinvwl_wpml_product_get' );
46
  }
47
 
48
- if ( ! function_exists( 'tinvwl_wpml_filter_link' ) ) {
49
 
50
  /**
51
  * Correct add wishlist key for WPML plugin.
@@ -55,26 +78,27 @@ if ( ! function_exists( 'tinvwl_wpml_filter_link' ) ) {
55
  *
56
  * @return string
57
  */
58
- function tinvwl_wpml_filter_link( $full_link, $l ) {
59
- $share_key = get_query_var( 'tinvwlID', null );
60
- if ( ! empty( $share_key ) ) {
61
- if ( get_option( 'permalink_structure' ) ) {
 
62
  $suffix = '';
63
- if ( preg_match( '/([^\?]+)\?*?(.*)/i', $full_link, $_full_link ) ) {
64
  $full_link = $_full_link[1];
65
- $suffix = $_full_link[2];
66
  }
67
- if ( ! preg_match( '/\/$/', $full_link ) ) {
68
  $full_link .= '/';
69
  }
70
  $full_link .= $share_key . '/' . $suffix;
71
  } else {
72
- $full_link .= add_query_arg( 'tinvwlID', $share_key, $full_link );
73
  }
74
  }
75
 
76
  return $full_link;
77
  }
78
 
79
- add_filter( 'WPML_filter_link', 'tinvwl_wpml_filter_link', 0, 2 );
80
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "sitepress-multilingual-cms";
24
+
25
+ $name = "WPML Multilingual CMS";
26
+
27
+ $available = defined('ICL_SITEPRESS_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_wpml_product_get')) {
43
 
44
  /**
45
  * Change product data if product need translate
48
  *
49
  * @return array
50
  */
51
+ function tinvwl_wpml_product_get($product)
52
+ {
53
+ if (array_key_exists('data', $product)) {
54
+ $_product_id = $product_id = $product['product_id'];
55
  $_variation_id = $variation_id = $product['variation_id'];
56
+ $_product_id = apply_filters('wpml_object_id', $_product_id, 'product', true);
57
+ if (!empty($_variation_id)) {
58
+ $_variation_id = apply_filters('wpml_object_id', $_variation_id, 'product', true);
59
  }
60
+ if ($_product_id !== $product_id || $_variation_id !== $variation_id) {
61
+ $product['data'] = wc_get_product($variation_id ? $_variation_id : $_product_id);
62
  }
63
  }
64
 
65
  return $product;
66
  }
67
 
68
+ add_filter('tinvwl_wishlist_product_get', 'tinvwl_wpml_product_get');
69
  }
70
 
71
+ if (!function_exists('tinvwl_wpml_filter_link')) {
72
 
73
  /**
74
  * Correct add wishlist key for WPML plugin.
78
  *
79
  * @return string
80
  */
81
+ function tinvwl_wpml_filter_link($full_link, $l)
82
+ {
83
+ $share_key = get_query_var('tinvwlID', null);
84
+ if (!empty($share_key)) {
85
+ if (get_option('permalink_structure')) {
86
  $suffix = '';
87
+ if (preg_match('/([^\?]+)\?*?(.*)/i', $full_link, $_full_link)) {
88
  $full_link = $_full_link[1];
89
+ $suffix = $_full_link[2];
90
  }
91
+ if (!preg_match('/\/$/', $full_link)) {
92
  $full_link .= '/';
93
  }
94
  $full_link .= $share_key . '/' . $suffix;
95
  } else {
96
+ $full_link .= add_query_arg('tinvwlID', $share_key, $full_link);
97
  }
98
  }
99
 
100
  return $full_link;
101
  }
102
 
103
+ add_filter('WPML_filter_link', 'tinvwl_wpml_filter_link', 0, 2);
104
  }
integrations/theme-divi.php CHANGED
@@ -6,36 +6,59 @@
6
  *
7
  * @version 4.4.6
8
  *
9
- * @slug Divi
10
  *
11
  * @url http://www.elegantthemes.com/gallery/divi/
12
  *
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  /**
22
  * Run hooks on page redirect.
23
  */
24
- function tinvwl_divi_init() {
25
- if ( class_exists( 'ET_Builder_Element' ) && is_product() && version_compare( ET_BUILDER_PRODUCT_VERSION, '4.0.0', '>=' ) ) {
 
26
  global $post;
27
- $product = wc_get_product( $post->ID );
28
- if ( ! empty( $product ) && ! $product->is_in_stock() ) {
29
- remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 29 );
30
- remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 31 );
31
- add_action( 'woocommerce_' . $product->get_type() . '_add_to_cart', 'tinvwl_divi_single_product_summary', 40 );
32
  }
33
  }
34
  }
35
 
36
- add_action( 'template_redirect', 'tinvwl_divi_init' );
37
 
38
  // Add a custom hook for single page.
39
- function tinvwl_divi_single_product_summary() {
40
- do_action( 'tinvwl_single_product_summary' );
 
41
  }
6
  *
7
  * @version 4.4.6
8
  *
9
+ * @slug divi
10
  *
11
  * @url http://www.elegantthemes.com/gallery/divi/
12
  *
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "divi";
24
+
25
+ $name = "Divi Theme";
26
+
27
+ $available = class_exists('ET_Builder_Element');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
 
42
  /**
43
  * Run hooks on page redirect.
44
  */
45
+ function tinvwl_divi_init()
46
+ {
47
+ if (class_exists('ET_Builder_Element') && is_product() && version_compare(ET_BUILDER_PRODUCT_VERSION, '4.0.0', '>=')) {
48
  global $post;
49
+ $product = wc_get_product($post->ID);
50
+ if (!empty($product) && !$product->is_in_stock()) {
51
+ remove_action('woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 29);
52
+ remove_action('woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 31);
53
+ add_action('woocommerce_' . $product->get_type() . '_add_to_cart', 'tinvwl_divi_single_product_summary', 40);
54
  }
55
  }
56
  }
57
 
58
+ add_action('template_redirect', 'tinvwl_divi_init');
59
 
60
  // Add a custom hook for single page.
61
+ function tinvwl_divi_single_product_summary()
62
+ {
63
+ do_action('tinvwl_single_product_summary');
64
  }
integrations/theme-flatsome.php CHANGED
@@ -14,8 +14,31 @@
14
 
15
  // If this file is called directly, abort.
16
  if (!defined('ABSPATH')) {
17
- die;
18
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  add_action('after_setup_theme', 'tinvwl_flatsome');
20
 
21
  function tinvwl_flatsome()
14
 
15
  // If this file is called directly, abort.
16
  if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "flatsome";
24
+
25
+ $name = "Flatsome Theme";
26
+
27
+ $available = class_exists('Flatsome_Default');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
  add_action('after_setup_theme', 'tinvwl_flatsome');
43
 
44
  function tinvwl_flatsome()
integrations/theme-kallyas.php CHANGED
@@ -13,26 +13,49 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_kallyas_init' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Run hooks after theme init.
24
  */
25
- function tinvwl_kallyas_init() {
26
- if ( function_exists( 'zget_option' ) ) {
 
27
 
28
- $show_cart_to_visitors = zget_option( 'show_cart_to_visitors', 'zn_woocommerce_options', false, 'yes' );
29
- if ( $show_cart_to_visitors == 'no' && ! is_user_logged_in() ) {
30
- add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', '__return_true' );
31
  }
32
 
33
 
34
  }
35
  }
36
 
37
- add_action( 'init', 'tinvwl_kallyas_init' );
38
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "kallyas";
24
+
25
+ $name = "Kallyas Theme";
26
+
27
+ $available = function_exists('zget_option');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_kallyas_init')) {
43
 
44
  /**
45
  * Run hooks after theme init.
46
  */
47
+ function tinvwl_kallyas_init()
48
+ {
49
+ if (function_exists('zget_option')) {
50
 
51
+ $show_cart_to_visitors = zget_option('show_cart_to_visitors', 'zn_woocommerce_options', false, 'yes');
52
+ if ($show_cart_to_visitors == 'no' && !is_user_logged_in()) {
53
+ add_filter('tinvwl_allow_addtowishlist_single_product_summary', '__return_true');
54
  }
55
 
56
 
57
  }
58
  }
59
 
60
+ add_action('init', 'tinvwl_kallyas_init');
61
  }
integrations/theme-oceanwp.php CHANGED
@@ -6,28 +6,51 @@
6
  *
7
  * @version
8
  *
9
- * @slug
10
  *
11
  * @url https://oceanwp.org/
12
  *
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  // OceanWP theme compatibility;
21
- if ( ! function_exists( 'tinvwl_oceanwp_fix_archive_markup' ) ) {
22
- add_action( 'init', 'tinvwl_oceanwp_fix_archive_markup' );
23
 
24
  /**
25
  * OceanWP theme fix for catalog add to wishlist button position
26
  */
27
- function tinvwl_oceanwp_fix_archive_markup() {
28
- if ( class_exists( 'OceanWP_WooCommerce_Config' ) && 'above_thumb' === tinv_get_option( 'add_to_wishlist_catalog', 'position' ) ) {
29
- remove_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 9 );
30
- add_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 10 );
 
31
  }
32
  }
33
  }
6
  *
7
  * @version
8
  *
9
+ * @slug oceanwp
10
  *
11
  * @url https://oceanwp.org/
12
  *
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "oceanwp";
24
+
25
+ $name = "OceanWP Theme";
26
+
27
+ $available = class_exists('OceanWP_WooCommerce_Config');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  // OceanWP theme compatibility;
43
+ if (!function_exists('tinvwl_oceanwp_fix_archive_markup')) {
44
+ add_action('init', 'tinvwl_oceanwp_fix_archive_markup');
45
 
46
  /**
47
  * OceanWP theme fix for catalog add to wishlist button position
48
  */
49
+ function tinvwl_oceanwp_fix_archive_markup()
50
+ {
51
+ if (class_exists('OceanWP_WooCommerce_Config') && 'above_thumb' === tinv_get_option('add_to_wishlist_catalog', 'position')) {
52
+ remove_action('woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 9);
53
+ add_action('woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 10);
54
  }
55
  }
56
  }
integrations/uni-woo-custom-product-options.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_item_meta_uni_woo_custom_product_options' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta Product Options and Price Calculation Formulas for WooCommerce – Uni CPO
@@ -29,56 +51,57 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_uni_woo_custom_product_options'
29
  * @return array
30
  */
31
 
32
- function tinv_wishlist_item_meta_uni_woo_custom_product_options( $item_data, $product_id, $variation_id ) {
 
33
 
34
- if ( class_exists( 'Uni_Cpo' ) ) {
35
- foreach ( array_keys( $item_data ) as $key ) {
36
- if ( strpos( $key, 'cpo_' ) === 0 ) {
37
- unset( $item_data[ $key ] );
38
  }
39
  }
40
 
41
- if ( ! empty( $item_data ) ) {
42
 
43
  $form_data = array();
44
 
45
- foreach ( $item_data as $key => $value ) {
46
- $form_data[ $key ] = $value['display'];
47
  }
48
 
49
- $filtered_form_data = array_filter( $form_data, function ( $k ) use ( $form_data ) {
50
- return false !== strpos( $k, UniCpo()->get_var_slug() ) && ! empty( $form_data[ $k ] );
51
- }, ARRAY_FILTER_USE_KEY );
52
-
53
- if ( ! empty( $filtered_form_data ) ) {
54
- $posts = uni_cpo_get_posts_by_slugs( array_keys( $filtered_form_data ) );
55
-
56
- if ( ! empty( $posts ) ) {
57
- $posts_ids = wp_list_pluck( $posts, 'ID' );
58
- foreach ( $posts_ids as $post_id ) {
59
- $option = uni_cpo_get_option( $post_id );
60
- if ( is_object( $option ) ) {
61
- $calculate_result = $option->calculate( $filtered_form_data );
62
- if ( is_array( $calculate_result ) && isset( $calculate_result[ $option->get_slug() ] ) ) {
63
- if ( is_array( $calculate_result[ $option->get_slug() ]['order_meta'] ) ) {
64
- $calculate_result[ $option->get_slug() ]['order_meta'] = array_map( function ( $item ) {
65
- if ( ! is_numeric( $item ) ) {
66
- return esc_html__( $item );
67
  } else {
68
  return $item;
69
  }
70
- }, $calculate_result[ $option->get_slug() ]['order_meta'] );
71
- $display_value = implode( ', ', $calculate_result[ $option->get_slug() ]['order_meta'] );
72
  } else {
73
- if ( ! is_numeric( $calculate_result[ $option->get_slug() ]['order_meta'] ) ) {
74
- $display_value = esc_html__( $calculate_result[ $option->get_slug() ]['order_meta'] );
75
  } else {
76
- $display_value = $calculate_result[ $option->get_slug() ]['order_meta'];
77
  }
78
  }
79
- $item_data[ $option->get_slug() ]['display'] = $display_value;
80
  }
81
- $item_data[ $option->get_slug() ]['key'] = uni_cpo_sanitize_label( $option->cpo_order_label() );
82
  }
83
  }
84
  }
@@ -92,10 +115,10 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_uni_woo_custom_product_options'
92
  return $item_data;
93
  }
94
 
95
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_uni_woo_custom_product_options', 10, 3 );
96
  }
97
 
98
- if ( ! function_exists( 'tinvwl_item_price_uni_woo_custom_product_options' ) ) {
99
 
100
  /**
101
  * Modify price for Product Options and Price Calculation Formulas for WooCommerce – Uni CPO.
@@ -106,34 +129,35 @@ if ( ! function_exists( 'tinvwl_item_price_uni_woo_custom_product_options' ) ) {
106
  *
107
  * @return string
108
  */
109
- function tinvwl_item_price_uni_woo_custom_product_options( $price, $wl_product, $product ) {
 
110
 
111
- if ( class_exists( 'Uni_Cpo' ) ) {
112
- $product_data = Uni_Cpo_Product::get_product_data_by_id( $product->get_id() );
113
- $form_data = $wl_product['meta'];
114
  $options_eval_result = array();
115
- $variables = array();
116
- $is_calc_disabled = false;
117
- $formatted_vars = array();
118
 
119
- $main_formula = $product_data['formula_data']['main_formula'];
120
- $filtered_form_data = array_filter( $form_data, function ( $k ) use ( $form_data ) {
121
- return false !== strpos( $k, UniCpo()->get_var_slug() ) && ! empty( $form_data[ $k ] );
122
- }, ARRAY_FILTER_USE_KEY );
123
 
124
 
125
- if ( ! empty( $filtered_form_data ) ) {
126
- $posts = uni_cpo_get_posts_by_slugs( array_keys( $filtered_form_data ) );
127
 
128
- if ( ! empty( $posts ) ) {
129
- $posts_ids = wp_list_pluck( $posts, 'ID' );
130
- foreach ( $posts_ids as $post_id ) {
131
- $option = uni_cpo_get_option( $post_id );
132
 
133
- if ( is_object( $option ) ) {
134
- $calculate_result = $option->calculate( $filtered_form_data );
135
- if ( ! empty( $calculate_result ) ) {
136
- $options_eval_result[ $option->get_slug() ] = $calculate_result;
137
  }
138
  }
139
 
@@ -142,49 +166,49 @@ if ( ! function_exists( 'tinvwl_item_price_uni_woo_custom_product_options' ) ) {
142
 
143
  }
144
 
145
- array_walk( $options_eval_result, function ( $v ) use ( &$variables, &$formatted_vars ) {
146
- foreach ( $v as $slug => $value ) {
147
  // prepare $variables for calculation purpose
148
- $variables[ '{' . $slug . '}' ] = $value['calc'];
149
  // prepare $formatted_vars for conditional logic purpose
150
- $formatted_vars[ $slug ] = $value['cart_meta'];
151
  }
152
- } );
153
- $variables['{uni_cpo_price}'] = $product->get_price( 'edit' );
154
  // non option variables
155
- if ( 'on' === $product_data['nov_data']['nov_enable'] && ! empty( $product_data['nov_data']['nov'] ) ) {
156
- $variables = uni_cpo_process_formula_with_non_option_vars( $variables, $product_data, $formatted_vars );
157
  }
158
  // formula conditional logic
159
 
160
- if ( 'on' === $product_data['formula_data']['rules_enable'] && ! empty( $product_data['formula_data']['formula_scheme'] ) && is_array( $product_data['formula_data']['formula_scheme'] ) ) {
161
- $conditional_formula = uni_cpo_process_formula_scheme( $formatted_vars, $product_data );
162
- if ( $conditional_formula ) {
163
  $main_formula = $conditional_formula;
164
  }
165
  }
166
 
167
- if ( 'disable' === $main_formula ) {
168
  $is_calc_disabled = true;
169
  }
170
  //
171
 
172
- if ( ! $is_calc_disabled ) {
173
- $main_formula = uni_cpo_process_formula_with_vars( $main_formula, $variables );
174
  // calculates formula
175
- $price_calculated = uni_cpo_calculate_formula( $main_formula );
176
- $price_min = $product_data['settings_data']['min_price'];
177
- $price_max = $product_data['settings_data']['max_price'];
178
  // check for min price
179
- if ( $price_calculated < $price_min ) {
180
  $price_calculated = $price_min;
181
  }
182
  // check for max price
183
- if ( ! empty( $price_max ) && $price_calculated >= $price_max ) {
184
  $is_calc_disabled = true;
185
  }
186
 
187
- if ( true !== $is_calc_disabled ) {
188
  // filter, so 3rd party scripts can hook up
189
  $price_calculated = apply_filters(
190
  'uni_cpo_in_cart_calculated_price',
@@ -193,13 +217,13 @@ if ( ! function_exists( 'tinvwl_item_price_uni_woo_custom_product_options' ) ) {
193
  $filtered_form_data
194
  );
195
 
196
- return wc_price( $price_calculated );
197
  } else {
198
- return wc_price( $price_max );
199
  }
200
 
201
  } else {
202
- return wc_price( 0 );
203
  }
204
 
205
  }
@@ -207,5 +231,5 @@ if ( ! function_exists( 'tinvwl_item_price_uni_woo_custom_product_options' ) ) {
207
  return $price;
208
  }
209
 
210
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_uni_woo_custom_product_options', 10, 3 );
211
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "uni-woo-custom-product-options";
24
+
25
+ $name = "Product Options and Price Calculation Formulas for WooCommerce – Uni CPO";
26
+
27
+ $available = class_exists('Uni_Cpo');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_item_meta_uni_woo_custom_product_options')) {
43
 
44
  /**
45
  * Set description for meta Product Options and Price Calculation Formulas for WooCommerce – Uni CPO
51
  * @return array
52
  */
53
 
54
+ function tinv_wishlist_item_meta_uni_woo_custom_product_options($item_data, $product_id, $variation_id)
55
+ {
56
 
57
+ if (class_exists('Uni_Cpo')) {
58
+ foreach (array_keys($item_data) as $key) {
59
+ if (strpos($key, 'cpo_') === 0) {
60
+ unset($item_data[$key]);
61
  }
62
  }
63
 
64
+ if (!empty($item_data)) {
65
 
66
  $form_data = array();
67
 
68
+ foreach ($item_data as $key => $value) {
69
+ $form_data[$key] = $value['display'];
70
  }
71
 
72
+ $filtered_form_data = array_filter($form_data, function ($k) use ($form_data) {
73
+ return false !== strpos($k, UniCpo()->get_var_slug()) && !empty($form_data[$k]);
74
+ }, ARRAY_FILTER_USE_KEY);
75
+
76
+ if (!empty($filtered_form_data)) {
77
+ $posts = uni_cpo_get_posts_by_slugs(array_keys($filtered_form_data));
78
+
79
+ if (!empty($posts)) {
80
+ $posts_ids = wp_list_pluck($posts, 'ID');
81
+ foreach ($posts_ids as $post_id) {
82
+ $option = uni_cpo_get_option($post_id);
83
+ if (is_object($option)) {
84
+ $calculate_result = $option->calculate($filtered_form_data);
85
+ if (is_array($calculate_result) && isset($calculate_result[$option->get_slug()])) {
86
+ if (is_array($calculate_result[$option->get_slug()]['order_meta'])) {
87
+ $calculate_result[$option->get_slug()]['order_meta'] = array_map(function ($item) {
88
+ if (!is_numeric($item)) {
89
+ return esc_html__($item);
90
  } else {
91
  return $item;
92
  }
93
+ }, $calculate_result[$option->get_slug()]['order_meta']);
94
+ $display_value = implode(', ', $calculate_result[$option->get_slug()]['order_meta']);
95
  } else {
96
+ if (!is_numeric($calculate_result[$option->get_slug()]['order_meta'])) {
97
+ $display_value = esc_html__($calculate_result[$option->get_slug()]['order_meta']);
98
  } else {
99
+ $display_value = $calculate_result[$option->get_slug()]['order_meta'];
100
  }
101
  }
102
+ $item_data[$option->get_slug()]['display'] = $display_value;
103
  }
104
+ $item_data[$option->get_slug()]['key'] = uni_cpo_sanitize_label($option->cpo_order_label());
105
  }
106
  }
107
  }
115
  return $item_data;
116
  }
117
 
118
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_uni_woo_custom_product_options', 10, 3);
119
  }
120
 
121
+ if (!function_exists('tinvwl_item_price_uni_woo_custom_product_options')) {
122
 
123
  /**
124
  * Modify price for Product Options and Price Calculation Formulas for WooCommerce – Uni CPO.
129
  *
130
  * @return string
131
  */
132
+ function tinvwl_item_price_uni_woo_custom_product_options($price, $wl_product, $product)
133
+ {
134
 
135
+ if (class_exists('Uni_Cpo')) {
136
+ $product_data = Uni_Cpo_Product::get_product_data_by_id($product->get_id());
137
+ $form_data = $wl_product['meta'];
138
  $options_eval_result = array();
139
+ $variables = array();
140
+ $is_calc_disabled = false;
141
+ $formatted_vars = array();
142
 
143
+ $main_formula = $product_data['formula_data']['main_formula'];
144
+ $filtered_form_data = array_filter($form_data, function ($k) use ($form_data) {
145
+ return false !== strpos($k, UniCpo()->get_var_slug()) && !empty($form_data[$k]);
146
+ }, ARRAY_FILTER_USE_KEY);
147
 
148
 
149
+ if (!empty($filtered_form_data)) {
150
+ $posts = uni_cpo_get_posts_by_slugs(array_keys($filtered_form_data));
151
 
152
+ if (!empty($posts)) {
153
+ $posts_ids = wp_list_pluck($posts, 'ID');
154
+ foreach ($posts_ids as $post_id) {
155
+ $option = uni_cpo_get_option($post_id);
156
 
157
+ if (is_object($option)) {
158
+ $calculate_result = $option->calculate($filtered_form_data);
159
+ if (!empty($calculate_result)) {
160
+ $options_eval_result[$option->get_slug()] = $calculate_result;
161
  }
162
  }
163
 
166
 
167
  }
168
 
169
+ array_walk($options_eval_result, function ($v) use (&$variables, &$formatted_vars) {
170
+ foreach ($v as $slug => $value) {
171
  // prepare $variables for calculation purpose
172
+ $variables['{' . $slug . '}'] = $value['calc'];
173
  // prepare $formatted_vars for conditional logic purpose
174
+ $formatted_vars[$slug] = $value['cart_meta'];
175
  }
176
+ });
177
+ $variables['{uni_cpo_price}'] = $product->get_price('edit');
178
  // non option variables
179
+ if ('on' === $product_data['nov_data']['nov_enable'] && !empty($product_data['nov_data']['nov'])) {
180
+ $variables = uni_cpo_process_formula_with_non_option_vars($variables, $product_data, $formatted_vars);
181
  }
182
  // formula conditional logic
183
 
184
+ if ('on' === $product_data['formula_data']['rules_enable'] && !empty($product_data['formula_data']['formula_scheme']) && is_array($product_data['formula_data']['formula_scheme'])) {
185
+ $conditional_formula = uni_cpo_process_formula_scheme($formatted_vars, $product_data);
186
+ if ($conditional_formula) {
187
  $main_formula = $conditional_formula;
188
  }
189
  }
190
 
191
+ if ('disable' === $main_formula) {
192
  $is_calc_disabled = true;
193
  }
194
  //
195
 
196
+ if (!$is_calc_disabled) {
197
+ $main_formula = uni_cpo_process_formula_with_vars($main_formula, $variables);
198
  // calculates formula
199
+ $price_calculated = uni_cpo_calculate_formula($main_formula);
200
+ $price_min = $product_data['settings_data']['min_price'];
201
+ $price_max = $product_data['settings_data']['max_price'];
202
  // check for min price
203
+ if ($price_calculated < $price_min) {
204
  $price_calculated = $price_min;
205
  }
206
  // check for max price
207
+ if (!empty($price_max) && $price_calculated >= $price_max) {
208
  $is_calc_disabled = true;
209
  }
210
 
211
+ if (true !== $is_calc_disabled) {
212
  // filter, so 3rd party scripts can hook up
213
  $price_calculated = apply_filters(
214
  'uni_cpo_in_cart_calculated_price',
217
  $filtered_form_data
218
  );
219
 
220
+ return wc_price($price_calculated);
221
  } else {
222
+ return wc_price($price_max);
223
  }
224
 
225
  } else {
226
+ return wc_price(0);
227
  }
228
 
229
  }
231
  return $price;
232
  }
233
 
234
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_uni_woo_custom_product_options', 10, 3);
235
  } // End if().
integrations/woo-advanced-qty.php CHANGED
@@ -13,12 +13,34 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  // WooCommerce Advanced Quantity compatibility.
21
- if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_qty' ) ) {
22
 
23
  /**
24
  * Force quantity to minimum.
@@ -28,16 +50,17 @@ if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_qty' ) ) {
28
  *
29
  * @return mixed
30
  */
31
- function tinv_wishlist_qty_woo_advanced_qty( $quantity, $product ) {
 
32
 
33
- if ( class_exists( 'Woo_Advanced_QTY_Public' ) ) {
34
- $advanced_qty = new Woo_Advanced_QTY_Public( null, null );
35
 
36
- $args = $advanced_qty->qty_input_args( array(
37
  'min_value' => 1,
38
  'max_value' => '',
39
- 'step' => 1,
40
- ), $product );
41
 
42
  $quantity = $args['input_value'];
43
  }
@@ -45,11 +68,11 @@ if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_qty' ) ) {
45
  return $quantity;
46
  }
47
 
48
- add_filter( 'tinvwl_product_add_to_cart_quantity', 'tinv_wishlist_qty_woo_advanced_qty', 10, 2 );
49
  }
50
 
51
  // WooCommerce Advanced Quantity compatibility.
52
- if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_url' ) ) {
53
 
54
  /**
55
  * @param $url
@@ -57,18 +80,19 @@ if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_url' ) ) {
57
  *
58
  * @return string|string[]|null
59
  */
60
- function tinv_wishlist_qty_woo_advanced_url( $url, $product ) {
 
61
 
62
- if ( class_exists( 'Woo_Advanced_QTY_Public' ) ) {
63
- if ( strpos( $url, 'add-to-cart=' ) ) {
64
- $advanced_qty = new Woo_Advanced_QTY_Public( null, null );
65
- $args = $advanced_qty->qty_input_args( array(
66
  'min_value' => 1,
67
  'max_value' => '',
68
- 'step' => 1,
69
- ), $product );
70
 
71
- $url = preg_replace( '/&quantity=[0-9.]*/', '', $url );
72
 
73
  $url .= '&quantity=' . $args['input_value'];
74
  }
@@ -77,7 +101,7 @@ if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_url' ) ) {
77
  return $url;
78
  }
79
 
80
- add_filter( 'tinvwl_product_add_to_cart_redirect_slug_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
81
- add_filter( 'tinvwl_product_add_to_cart_redirect_url_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
82
- add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
83
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woo-advanced-qty";
24
+
25
+ $name = "WooCommerce Advanced Quantity";
26
+
27
+ $available = class_exists('Woo_Advanced_QTY_Public');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  // WooCommerce Advanced Quantity compatibility.
43
+ if (!function_exists('tinv_wishlist_qty_woo_advanced_qty')) {
44
 
45
  /**
46
  * Force quantity to minimum.
50
  *
51
  * @return mixed
52
  */
53
+ function tinv_wishlist_qty_woo_advanced_qty($quantity, $product)
54
+ {
55
 
56
+ if (class_exists('Woo_Advanced_QTY_Public')) {
57
+ $advanced_qty = new Woo_Advanced_QTY_Public(null, null);
58
 
59
+ $args = $advanced_qty->qty_input_args(array(
60
  'min_value' => 1,
61
  'max_value' => '',
62
+ 'step' => 1,
63
+ ), $product);
64
 
65
  $quantity = $args['input_value'];
66
  }
68
  return $quantity;
69
  }
70
 
71
+ add_filter('tinvwl_product_add_to_cart_quantity', 'tinv_wishlist_qty_woo_advanced_qty', 10, 2);
72
  }
73
 
74
  // WooCommerce Advanced Quantity compatibility.
75
+ if (!function_exists('tinv_wishlist_qty_woo_advanced_url')) {
76
 
77
  /**
78
  * @param $url
80
  *
81
  * @return string|string[]|null
82
  */
83
+ function tinv_wishlist_qty_woo_advanced_url($url, $product)
84
+ {
85
 
86
+ if (class_exists('Woo_Advanced_QTY_Public')) {
87
+ if (strpos($url, 'add-to-cart=')) {
88
+ $advanced_qty = new Woo_Advanced_QTY_Public(null, null);
89
+ $args = $advanced_qty->qty_input_args(array(
90
  'min_value' => 1,
91
  'max_value' => '',
92
+ 'step' => 1,
93
+ ), $product);
94
 
95
+ $url = preg_replace('/&quantity=[0-9.]*/', '', $url);
96
 
97
  $url .= '&quantity=' . $args['input_value'];
98
  }
101
  return $url;
102
  }
103
 
104
+ add_filter('tinvwl_product_add_to_cart_redirect_slug_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2);
105
+ add_filter('tinvwl_product_add_to_cart_redirect_url_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2);
106
+ add_filter('tinvwl_product_add_to_cart_redirect_url', 'tinv_wishlist_qty_woo_advanced_url', 10, 2);
107
  }
integrations/woo-custom-product-addons.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addons' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Custom Product Addons
@@ -29,70 +51,71 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addo
29
  * @return array
30
  */
31
 
32
- function tinv_wishlist_item_meta_woocommerce_custom_product_addons( $item_data, $product_id, $variation_id ) {
33
- if ( defined( 'WCPA_POST_TYPE' ) && class_exists( 'WCPA_Form' ) && class_exists( 'WCPA_Front_End' ) ) {
34
- $form = new WCPA_Form();
 
35
  $frontend = new WCPA_Front_End();
36
- $data = array();
37
- $post_ids = $form->get_form_ids( $product_id );
38
 
39
- if ( isset( $item_data['wcpa_field_key_checker'] ) ) {
40
- unset( $item_data['wcpa_field_key_checker'] );
41
  }
42
 
43
- if ( wcpa_get_option( 'form_loading_order_by_date' ) === true ) {
44
- if ( is_array( $post_ids ) && count( $post_ids ) ) {
45
- $post_ids = get_posts( array(
46
- 'posts_per_page' => - 1,
47
- 'include' => $post_ids,
48
- 'fields' => 'ids',
49
- 'post_type' => WCPA_POST_TYPE,
50
- 'posts_per_page' => - 1,
51
- ) );
52
  }
53
  }
54
- foreach ( $post_ids as $id ) {
55
- if ( get_post_status( $id ) == 'publish' ) {
56
- $json_string = get_post_meta( $id, WCPA_FORM_META_KEY, true );
57
- $json_encoded = json_decode( $json_string );
58
- if ( $json_encoded && is_array( $json_encoded ) ) {
59
- $data = array_merge( $data, $json_encoded );
60
  }
61
  }
62
  }
63
 
64
- foreach ( $data as $v ) {
65
  $form_data = clone $v;
66
- unset( $form_data->values ); //avoid saving large number of data
67
- unset( $form_data->className ); //avoid saving no use data
68
- if ( ! in_array( $v->type, array( 'header', 'paragraph' ) ) ) {
69
- if ( isset( $item_data[ $v->name ] ) ) {
70
-
71
- if ( ! is_object( $v ) ) {
72
- $value = sanitize_text_field( $v );
73
- } else if ( ( isset( $v->name ) ) ) {
74
- if ( is_array( $item_data[ $v->name ] ) ) {
75
-
76
- $_values = $item_data[ $v->name ];
77
- array_walk( $_values, function ( &$a ) {
78
- sanitize_text_field( $a );
79
- } ); // using this array_wal method to preserve the keys
80
  $value = $_values;
81
- } else if ( $v->type == 'textarea' ) {
82
- $value = sanitize_textarea_field( wp_unslash( $item_data[ $v->name ] ) );
83
  } else {
84
- $value = sanitize_text_field( wp_unslash( $item_data[ $v->name ] ) );
85
  }
86
  }
87
- $item_data[ $v->name ]['key'] = ( isset( $v->label ) ) ? $v->label : '';
88
- $item_data[ $v->name ]['display'] = $frontend->cart_display( array(
89
- 'type' => $v->type,
90
- 'name' => $v->name,
91
- 'label' => ( isset( $v->label ) ) ? $v->label : '',
92
- 'value' => $value['display'],
93
- 'price' => ( isset( $v->price ) ) ? $v->price : false,
94
  'form_data' => $form_data,
95
- ), wc_get_product( $product_id ) );
96
  }
97
  }
98
  }
@@ -101,10 +124,10 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addo
101
  return $item_data;
102
  }
103
 
104
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_product_addons', 10, 3 );
105
  }
106
 
107
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons' ) ) {
108
 
109
  /**
110
  * Modify price for WooCommerce Custom Product Addons.
@@ -115,50 +138,51 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons' )
115
  *
116
  * @return string
117
  */
118
- function tinvwl_item_price_woocommerce_custom_product_addons( $price, $wl_product, $product ) {
119
- if ( defined( 'WCPA_ITEM_ID' ) && class_exists( 'WCPA_Form' ) && class_exists( 'WCPA_MC' ) ) {
120
-
121
- $price = 0;
122
- $form = new WCPA_Form();
123
- $data = array();
124
- $post_ids = $form->get_form_ids( $wl_product['product_id'] );
125
-
126
- if ( wcpa_get_option( 'form_loading_order_by_date' ) === true ) {
127
- if ( is_array( $post_ids ) && count( $post_ids ) ) {
128
- $post_ids = get_posts( array(
129
- 'posts_per_page' => - 1,
130
- 'include' => $post_ids,
131
- 'fields' => 'ids',
132
- 'post_type' => WCPA_POST_TYPE,
133
- 'posts_per_page' => - 1,
134
- ) );
 
135
  }
136
  }
137
- foreach ( $post_ids as $id ) {
138
- if ( get_post_status( $id ) == 'publish' ) {
139
- $json_string = get_post_meta( $id, WCPA_FORM_META_KEY, true );
140
- $json_encoded = json_decode( $json_string );
141
- if ( $json_encoded && is_array( $json_encoded ) ) {
142
- $data = array_merge( $data, $json_encoded );
143
  }
144
  }
145
  }
146
 
147
- foreach ( $data as $v ) {
148
  $form_data = clone $v;
149
- unset( $form_data->values ); //avoid saving large number of data
150
- unset( $form_data->className ); //avoid saving no use data
151
- if ( ! in_array( $v->type, array( 'header', 'paragraph' ) ) ) {
152
- if ( isset( $wl_product['meta'][ $v->name ] ) ) {
153
- if ( ! is_object( $v ) ) {
154
  continue;
155
- } else if ( ( isset( $v->name ) ) ) {
156
- if ( ( ! isset( $v->is_fee ) || $v->is_fee === false ) && ( ! isset( $v->is_show_price ) || $v->is_show_price === false ) ) {
157
- if ( isset( $v->price ) && is_array( $v->price ) ) {
158
- foreach ( $v->price as $p ) {
159
  $price += $p;
160
  }
161
- } else if ( isset( $v->price ) && $v->price ) {
162
  $price += $v->price;
163
  }
164
  }
@@ -167,20 +191,20 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons' )
167
  }
168
  }
169
 
170
- $mc = new WCPA_MC();
171
- $price = $mc->mayBeConvert( $price ) + $product->get_price( 'edit' );
172
 
173
- $price = wc_price( $price );
174
 
175
  }
176
 
177
  return $price;
178
  }
179
 
180
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_product_addons', 10, 3 );
181
  } // End if().
182
 
183
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons_text_button' ) ) {
184
 
185
  /**
186
  * Change text for button add to cart
@@ -191,47 +215,48 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons_tex
191
  *
192
  * @return string
193
  */
194
- function tinvwl_item_price_woocommerce_custom_product_addons_text_button( $text_add_to_cart, $wl_product, $product ) {
 
195
 
196
- if ( defined( 'WCPA_POST_TYPE' ) && class_exists( 'WCPA_Form' ) && class_exists( 'WCPA_Front_End' ) ) {
197
  $product_id = $product->get_id();
198
- $form = new WCPA_Form();
199
- $post_ids = $form->get_form_ids( $product_id );
200
- $data = array();
201
- if ( wcpa_get_option( 'form_loading_order_by_date' ) === true ) {
202
- if ( is_array( $post_ids ) && count( $post_ids ) ) {
203
- $post_ids = get_posts( array(
204
- 'posts_per_page' => - 1,
205
- 'include' => $post_ids,
206
- 'fields' => 'ids',
207
- 'post_type' => WCPA_POST_TYPE,
208
- 'posts_per_page' => - 1
209
- ) );
210
  }
211
  }
212
- foreach ( $post_ids as $id ) {
213
- if ( get_post_status( $id ) == 'publish' ) {
214
- $json_string = get_post_meta( $id, WCPA_FORM_META_KEY, true );
215
- $json_encoded = json_decode( $json_string );
216
- if ( $json_encoded && is_array( $json_encoded ) ) {
217
- $data = array_merge( $data, $json_encoded );
218
  }
219
  }
220
  }
221
 
222
  $status = true;
223
 
224
- foreach ( $data as $v ) {
225
- if ( $v->type != 'file' && isset( $v->required ) && $v->required && ( ! isset( $wl_product['meta'][ $v->name ] ) || empty( $wl_product['meta'][ $v->name ] ) ) ) {
226
  $status = false;
227
  }
228
  }
229
 
230
- if ( ! $status ) {
231
 
232
  $WCPA = new WCPA_Front_End();
233
 
234
- return $WCPA->add_to_cart_text( $text_add_to_cart, $product );
235
  }
236
  }
237
 
@@ -239,5 +264,5 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons_tex
239
 
240
  }
241
 
242
- add_filter( 'tinvwl_wishlist_item_add_to_cart', 'tinvwl_item_price_woocommerce_custom_product_addons_text_button', 10, 3 );
243
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woo-custom-product-addons";
24
+
25
+ $name = "WooCommerce Custom Product Addons";
26
+
27
+ $available = defined('WCPA_POST_TYPE');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_item_meta_woocommerce_custom_product_addons')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Custom Product Addons
51
  * @return array
52
  */
53
 
54
+ function tinv_wishlist_item_meta_woocommerce_custom_product_addons($item_data, $product_id, $variation_id)
55
+ {
56
+ if (defined('WCPA_POST_TYPE') && class_exists('WCPA_Form') && class_exists('WCPA_Front_End')) {
57
+ $form = new WCPA_Form();
58
  $frontend = new WCPA_Front_End();
59
+ $data = array();
60
+ $post_ids = $form->get_form_ids($product_id);
61
 
62
+ if (isset($item_data['wcpa_field_key_checker'])) {
63
+ unset($item_data['wcpa_field_key_checker']);
64
  }
65
 
66
+ if (wcpa_get_option('form_loading_order_by_date') === true) {
67
+ if (is_array($post_ids) && count($post_ids)) {
68
+ $post_ids = get_posts(array(
69
+ 'posts_per_page' => -1,
70
+ 'include' => $post_ids,
71
+ 'fields' => 'ids',
72
+ 'post_type' => WCPA_POST_TYPE,
73
+ 'posts_per_page' => -1,
74
+ ));
75
  }
76
  }
77
+ foreach ($post_ids as $id) {
78
+ if (get_post_status($id) == 'publish') {
79
+ $json_string = get_post_meta($id, WCPA_FORM_META_KEY, true);
80
+ $json_encoded = json_decode($json_string);
81
+ if ($json_encoded && is_array($json_encoded)) {
82
+ $data = array_merge($data, $json_encoded);
83
  }
84
  }
85
  }
86
 
87
+ foreach ($data as $v) {
88
  $form_data = clone $v;
89
+ unset($form_data->values); //avoid saving large number of data
90
+ unset($form_data->className); //avoid saving no use data
91
+ if (!in_array($v->type, array('header', 'paragraph'))) {
92
+ if (isset($item_data[$v->name])) {
93
+
94
+ if (!is_object($v)) {
95
+ $value = sanitize_text_field($v);
96
+ } else if ((isset($v->name))) {
97
+ if (is_array($item_data[$v->name])) {
98
+
99
+ $_values = $item_data[$v->name];
100
+ array_walk($_values, function (&$a) {
101
+ sanitize_text_field($a);
102
+ }); // using this array_wal method to preserve the keys
103
  $value = $_values;
104
+ } else if ($v->type == 'textarea') {
105
+ $value = sanitize_textarea_field(wp_unslash($item_data[$v->name]));
106
  } else {
107
+ $value = sanitize_text_field(wp_unslash($item_data[$v->name]));
108
  }
109
  }
110
+ $item_data[$v->name]['key'] = (isset($v->label)) ? $v->label : '';
111
+ $item_data[$v->name]['display'] = $frontend->cart_display(array(
112
+ 'type' => $v->type,
113
+ 'name' => $v->name,
114
+ 'label' => (isset($v->label)) ? $v->label : '',
115
+ 'value' => $value['display'],
116
+ 'price' => (isset($v->price)) ? $v->price : false,
117
  'form_data' => $form_data,
118
+ ), wc_get_product($product_id));
119
  }
120
  }
121
  }
124
  return $item_data;
125
  }
126
 
127
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_product_addons', 10, 3);
128
  }
129
 
130
+ if (!function_exists('tinvwl_item_price_woocommerce_custom_product_addons')) {
131
 
132
  /**
133
  * Modify price for WooCommerce Custom Product Addons.
138
  *
139
  * @return string
140
  */
141
+ function tinvwl_item_price_woocommerce_custom_product_addons($price, $wl_product, $product)
142
+ {
143
+ if (defined('WCPA_ITEM_ID') && class_exists('WCPA_Form') && class_exists('WCPA_MC')) {
144
+
145
+ $price = 0;
146
+ $form = new WCPA_Form();
147
+ $data = array();
148
+ $post_ids = $form->get_form_ids($wl_product['product_id']);
149
+
150
+ if (wcpa_get_option('form_loading_order_by_date') === true) {
151
+ if (is_array($post_ids) && count($post_ids)) {
152
+ $post_ids = get_posts(array(
153
+ 'posts_per_page' => -1,
154
+ 'include' => $post_ids,
155
+ 'fields' => 'ids',
156
+ 'post_type' => WCPA_POST_TYPE,
157
+ 'posts_per_page' => -1,
158
+ ));
159
  }
160
  }
161
+ foreach ($post_ids as $id) {
162
+ if (get_post_status($id) == 'publish') {
163
+ $json_string = get_post_meta($id, WCPA_FORM_META_KEY, true);
164
+ $json_encoded = json_decode($json_string);
165
+ if ($json_encoded && is_array($json_encoded)) {
166
+ $data = array_merge($data, $json_encoded);
167
  }
168
  }
169
  }
170
 
171
+ foreach ($data as $v) {
172
  $form_data = clone $v;
173
+ unset($form_data->values); //avoid saving large number of data
174
+ unset($form_data->className); //avoid saving no use data
175
+ if (!in_array($v->type, array('header', 'paragraph'))) {
176
+ if (isset($wl_product['meta'][$v->name])) {
177
+ if (!is_object($v)) {
178
  continue;
179
+ } else if ((isset($v->name))) {
180
+ if ((!isset($v->is_fee) || $v->is_fee === false) && (!isset($v->is_show_price) || $v->is_show_price === false)) {
181
+ if (isset($v->price) && is_array($v->price)) {
182
+ foreach ($v->price as $p) {
183
  $price += $p;
184
  }
185
+ } else if (isset($v->price) && $v->price) {
186
  $price += $v->price;
187
  }
188
  }
191
  }
192
  }
193
 
194
+ $mc = new WCPA_MC();
195
+ $price = $mc->mayBeConvert($price) + $product->get_price('edit');
196
 
197
+ $price = wc_price($price);
198
 
199
  }
200
 
201
  return $price;
202
  }
203
 
204
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_product_addons', 10, 3);
205
  } // End if().
206
 
207
+ if (!function_exists('tinvwl_item_price_woocommerce_custom_product_addons_text_button')) {
208
 
209
  /**
210
  * Change text for button add to cart
215
  *
216
  * @return string
217
  */
218
+ function tinvwl_item_price_woocommerce_custom_product_addons_text_button($text_add_to_cart, $wl_product, $product)
219
+ {
220
 
221
+ if (defined('WCPA_POST_TYPE') && class_exists('WCPA_Form') && class_exists('WCPA_Front_End')) {
222
  $product_id = $product->get_id();
223
+ $form = new WCPA_Form();
224
+ $post_ids = $form->get_form_ids($product_id);
225
+ $data = array();
226
+ if (wcpa_get_option('form_loading_order_by_date') === true) {
227
+ if (is_array($post_ids) && count($post_ids)) {
228
+ $post_ids = get_posts(array(
229
+ 'posts_per_page' => -1,
230
+ 'include' => $post_ids,
231
+ 'fields' => 'ids',
232
+ 'post_type' => WCPA_POST_TYPE,
233
+ 'posts_per_page' => -1
234
+ ));
235
  }
236
  }
237
+ foreach ($post_ids as $id) {
238
+ if (get_post_status($id) == 'publish') {
239
+ $json_string = get_post_meta($id, WCPA_FORM_META_KEY, true);
240
+ $json_encoded = json_decode($json_string);
241
+ if ($json_encoded && is_array($json_encoded)) {
242
+ $data = array_merge($data, $json_encoded);
243
  }
244
  }
245
  }
246
 
247
  $status = true;
248
 
249
+ foreach ($data as $v) {
250
+ if ($v->type != 'file' && isset($v->required) && $v->required && (!isset($wl_product['meta'][$v->name]) || empty($wl_product['meta'][$v->name]))) {
251
  $status = false;
252
  }
253
  }
254
 
255
+ if (!$status) {
256
 
257
  $WCPA = new WCPA_Front_End();
258
 
259
+ return $WCPA->add_to_cart_text($text_add_to_cart, $product);
260
  }
261
  }
262
 
264
 
265
  }
266
 
267
+ add_filter('tinvwl_wishlist_item_add_to_cart', 'tinvwl_item_price_woocommerce_custom_product_addons_text_button', 10, 3);
268
  }
integrations/woo-payment-gateway.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_item_meta_woo_payment_gateway' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta Braintree For WooCommerce
@@ -29,17 +51,18 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woo_payment_gateway' ) ) {
29
  * @return array
30
  */
31
 
32
- function tinv_wishlist_item_meta_woo_payment_gateway( $item_data, $product_id, $variation_id ) {
33
- if ( defined( 'WC_BRAINTREE_PLUGIN_NAME' ) ) {
34
- foreach ( array_keys( $item_data ) as $key ) {
35
- if ( strpos( $key, 'billing_' ) === 0 ) {
36
- unset( $item_data[ $key ] );
 
37
  }
38
- if ( strpos( $key, 'shipping_' ) === 0 ) {
39
- unset( $item_data[ $key ] );
40
  }
41
- if ( strpos( $key, 'wc_braintree_' ) === 0 ) {
42
- unset( $item_data[ $key ] );
43
  }
44
  }
45
  }
@@ -47,6 +70,6 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woo_payment_gateway' ) ) {
47
  return $item_data;
48
  }
49
 
50
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woo_payment_gateway', 10, 3 );
51
  }
52
  // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woo-payment-gateway";
24
+
25
+ $name = "Braintree For WooCommerce";
26
+
27
+ $available = defined('WC_BRAINTREE_PLUGIN_NAME');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_item_meta_woo_payment_gateway')) {
43
 
44
  /**
45
  * Set description for meta Braintree For WooCommerce
51
  * @return array
52
  */
53
 
54
+ function tinv_wishlist_item_meta_woo_payment_gateway($item_data, $product_id, $variation_id)
55
+ {
56
+ if (defined('WC_BRAINTREE_PLUGIN_NAME')) {
57
+ foreach (array_keys($item_data) as $key) {
58
+ if (strpos($key, 'billing_') === 0) {
59
+ unset($item_data[$key]);
60
  }
61
+ if (strpos($key, 'shipping_') === 0) {
62
+ unset($item_data[$key]);
63
  }
64
+ if (strpos($key, 'wc_braintree_') === 0) {
65
+ unset($item_data[$key]);
66
  }
67
  }
68
  }
70
  return $item_data;
71
  }
72
 
73
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woo_payment_gateway', 10, 3);
74
  }
75
  // End if().
integrations/woo-product-bundle.php CHANGED
@@ -13,27 +13,50 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( defined( 'WOOSB_VERSION' ) ) {
 
21
 
22
- add_action( 'tinvwl_wishlist_addtowishlist_button', 'tinvwl_woo_product_bundle_loop_data', 10, 2 );
23
 
24
- function tinvwl_woo_product_bundle_loop_data( $product, $loop ) {
25
 
26
- if ( $loop && 'woosb' === $product->get_type() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  $ids_str = '';
28
 
29
- if ( get_post_meta( $product->get_id(), 'woosb_ids', true ) ) {
30
- $ids_str = get_post_meta( $product->get_id(), 'woosb_ids', true );
31
  }
32
 
33
- $ids_str = WPCleverWoosb_Helper::woosb_clean_ids( $ids_str );
34
  ?>
35
  <input name="woosb_ids" class="woosb_ids woosb-ids" type="hidden"
36
- value="<?php echo esc_attr( $ids_str ); ?>"/>
37
  <?php
38
  }
39
  }
@@ -45,72 +68,73 @@ if ( defined( 'WOOSB_VERSION' ) ) {
45
  * @param \WC_Product $product Woocommerce Product.
46
  * @param int $discount_extra possible discount on bundle row.
47
  */
48
- function tinvwl_row_woo_product_bundle( $wl_product, $product, $discount_extra = 0 ) {
49
- if ( is_object( $product ) && $product->is_type( 'woosb' ) && isset( $wl_product['meta'] ) && isset( $wl_product['meta']['woosb_ids'] ) ) {
 
50
 
51
  $bundle = WPCleverWoosb::instance();
52
 
53
- $bundled_items = $bundle->woosb_get_bundled( 0, $wl_product['meta']['woosb_ids'] );
54
- if ( ! empty( $bundled_items ) ) {
55
- foreach ( $bundled_items as $key => $data ) {
56
 
57
  $bundled_item = new stdClass();
58
 
59
- $bundled_item->product = wc_get_product( $data['id'] );
60
 
61
- if ( ! $bundled_item->product ) {
62
  continue;
63
  }
64
 
65
  $bundled_product_qty = $data['qty'];
66
- $product_url = ( get_option( '_woosb_bundled_link', 'yes' ) !== 'no' ) ? $product->get_permalink() : $bundled_item->product->get_permalink();
67
- $product_image = $bundled_item->product->get_image();
68
 
69
- $product_title = is_callable( array(
70
  $bundled_item->product,
71
  'get_name'
72
- ) ) ? $bundled_item->product->get_name() : $bundled_item->product->get_title();
73
 
74
  $product_price = $bundled_item->product->get_price_html();
75
 
76
- if ( $bundled_item->product->is_visible() ) {
77
- $product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
78
- $product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
79
  }
80
- $product_title .= tinv_wishlist_get_item_data( $bundled_item->product, $wl_product );
81
 
82
- $availability = (array) $bundled_item->product->get_availability();
83
- if ( ! array_key_exists( 'availability', $availability ) ) {
84
  $availability['availability'] = '';
85
  }
86
- if ( ! array_key_exists( 'class', $availability ) ) {
87
  $availability['class'] = '';
88
  }
89
- $availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
90
- $row_string = '<tr>';
91
- $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">&#10149; %2$s</td>';
92
- if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
93
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
94
  }
95
- if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
96
  $row_string .= '<td class="product-date">&nbsp;</td>';
97
  }
98
- if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
99
  $row_string .= '<td class="product-stock">%4$s</td>';
100
  }
101
 
102
- if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
103
  $row_string .= '<td class="product-action">&nbsp;</td>';
104
  }
105
  $row_string .= '</tr>';
106
 
107
- echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty ); // WPCS: xss ok.
108
  } // End foreach().
109
  } // End if().
110
  } // End if().
111
  }
112
 
113
- add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woo_product_bundle', 10, 2 );
114
 
115
  /**
116
  * Set description for meta WPC Product Bundles for WooCommerce
@@ -122,11 +146,12 @@ if ( defined( 'WOOSB_VERSION' ) ) {
122
  * @return array
123
  */
124
 
125
- function tinv_wishlist_item_meta_woo_product_bundle( $item_data, $product_id, $variation_id ) {
 
126
 
127
- foreach ( array_keys( $item_data ) as $key ) {
128
- if ( strpos( $key, 'woosb_' ) === 0 ) {
129
- unset( $item_data[ $key ] );
130
  }
131
  }
132
 
@@ -134,5 +159,5 @@ if ( defined( 'WOOSB_VERSION' ) ) {
134
  return $item_data;
135
  }
136
 
137
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woo_product_bundle', 10, 3 );
138
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
 
23
+ $slug = "woo-product-bundle";
24
 
25
+ $name = "WPC Product Bundles for WooCommerce";
26
 
27
+ $available = defined('WOOSB_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (defined('WOOSB_VERSION')) {
43
+
44
+ add_action('tinvwl_wishlist_addtowishlist_button', 'tinvwl_woo_product_bundle_loop_data', 10, 2);
45
+
46
+ function tinvwl_woo_product_bundle_loop_data($product, $loop)
47
+ {
48
+
49
+ if ($loop && 'woosb' === $product->get_type()) {
50
  $ids_str = '';
51
 
52
+ if (get_post_meta($product->get_id(), 'woosb_ids', true)) {
53
+ $ids_str = get_post_meta($product->get_id(), 'woosb_ids', true);
54
  }
55
 
56
+ $ids_str = WPCleverWoosb_Helper::woosb_clean_ids($ids_str);
57
  ?>
58
  <input name="woosb_ids" class="woosb_ids woosb-ids" type="hidden"
59
+ value="<?php echo esc_attr($ids_str); ?>"/>
60
  <?php
61
  }
62
  }
68
  * @param \WC_Product $product Woocommerce Product.
69
  * @param int $discount_extra possible discount on bundle row.
70
  */
71
+ function tinvwl_row_woo_product_bundle($wl_product, $product, $discount_extra = 0)
72
+ {
73
+ if (is_object($product) && $product->is_type('woosb') && isset($wl_product['meta']) && isset($wl_product['meta']['woosb_ids'])) {
74
 
75
  $bundle = WPCleverWoosb::instance();
76
 
77
+ $bundled_items = $bundle->woosb_get_bundled(0, $wl_product['meta']['woosb_ids']);
78
+ if (!empty($bundled_items)) {
79
+ foreach ($bundled_items as $key => $data) {
80
 
81
  $bundled_item = new stdClass();
82
 
83
+ $bundled_item->product = wc_get_product($data['id']);
84
 
85
+ if (!$bundled_item->product) {
86
  continue;
87
  }
88
 
89
  $bundled_product_qty = $data['qty'];
90
+ $product_url = (get_option('_woosb_bundled_link', 'yes') !== 'no') ? $product->get_permalink() : $bundled_item->product->get_permalink();
91
+ $product_image = $bundled_item->product->get_image();
92
 
93
+ $product_title = is_callable(array(
94
  $bundled_item->product,
95
  'get_name'
96
+ )) ? $bundled_item->product->get_name() : $bundled_item->product->get_title();
97
 
98
  $product_price = $bundled_item->product->get_price_html();
99
 
100
+ if ($bundled_item->product->is_visible()) {
101
+ $product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
102
+ $product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
103
  }
104
+ $product_title .= tinv_wishlist_get_item_data($bundled_item->product, $wl_product);
105
 
106
+ $availability = (array)$bundled_item->product->get_availability();
107
+ if (!array_key_exists('availability', $availability)) {
108
  $availability['availability'] = '';
109
  }
110
+ if (!array_key_exists('class', $availability)) {
111
  $availability['class'] = '';
112
  }
113
+ $availability_html = empty($availability['availability']) ? '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__('In stock', 'ti-woocommerce-wishlist') . '</span></p>' : '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html($availability['availability']) . '</span></p>';
114
+ $row_string = '<tr>';
115
+ $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">&#10149; %2$s</td>';
116
+ if (tinv_get_option('product_table', 'colm_price')) {
117
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
118
  }
119
+ if (tinv_get_option('product_table', 'colm_date')) {
120
  $row_string .= '<td class="product-date">&nbsp;</td>';
121
  }
122
+ if (tinv_get_option('product_table', 'colm_stock')) {
123
  $row_string .= '<td class="product-stock">%4$s</td>';
124
  }
125
 
126
+ if (tinv_get_option('product_table', 'add_to_cart')) {
127
  $row_string .= '<td class="product-action">&nbsp;</td>';
128
  }
129
  $row_string .= '</tr>';
130
 
131
+ echo sprintf($row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty); // WPCS: xss ok.
132
  } // End foreach().
133
  } // End if().
134
  } // End if().
135
  }
136
 
137
+ add_action('tinvwl_wishlist_row_after', 'tinvwl_row_woo_product_bundle', 10, 2);
138
 
139
  /**
140
  * Set description for meta WPC Product Bundles for WooCommerce
146
  * @return array
147
  */
148
 
149
+ function tinv_wishlist_item_meta_woo_product_bundle($item_data, $product_id, $variation_id)
150
+ {
151
 
152
+ foreach (array_keys($item_data) as $key) {
153
+ if (strpos($key, 'woosb_') === 0) {
154
+ unset($item_data[$key]);
155
  }
156
  }
157
 
159
  return $item_data;
160
  }
161
 
162
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woo_product_bundle', 10, 3);
163
  }
integrations/woo-variation-swatches-pro.php CHANGED
@@ -13,27 +13,52 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( class_exists( 'Woo_Variation_Swatches_Pro' ) ) {
 
21
 
22
- add_action( 'before_get_redirect_url', 'tinvwl_remove_custom_url_woo_variation_swatches_pro' );
23
 
24
- function tinvwl_remove_custom_url_woo_variation_swatches_pro() {
25
- remove_filter( 'woocommerce_product_add_to_cart_url', 'wvs_simple_product_cart_url', 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
- add_action( 'after_get_redirect_url', 'tinvwl_add_custom_url_woo_variation_swatches_pro' );
29
 
30
- function tinvwl_add_custom_url_woo_variation_swatches_pro() {
31
- add_filter( 'woocommerce_product_add_to_cart_url', 'wvs_simple_product_cart_url', 10, 2 );
 
32
  }
33
 
34
- function tinv_add_to_wishlist_woo_variation_swatches_pro() {
 
35
 
36
- wp_add_inline_script( 'tinvwl', "
37
  jQuery(document).ready(function($){
38
  $(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
39
  var button = $(el);
@@ -50,8 +75,8 @@ if ( class_exists( 'Woo_Variation_Swatches_Pro' ) ) {
50
  }
51
  });
52
  });
53
- " );
54
  }
55
 
56
- add_action( 'wp_enqueue_scripts', 'tinv_add_to_wishlist_woo_variation_swatches_pro', 100, 1 );
57
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
 
23
+ $slug = "woo-variation-swatches-pro";
24
 
25
+ $name = "WooCommerce Variation Swatches - Pro";
26
+
27
+ $available = class_exists('Woo_Variation_Swatches_Pro');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (class_exists('Woo_Variation_Swatches_Pro')) {
43
+
44
+ add_action('before_get_redirect_url', 'tinvwl_remove_custom_url_woo_variation_swatches_pro');
45
+
46
+ function tinvwl_remove_custom_url_woo_variation_swatches_pro()
47
+ {
48
+ remove_filter('woocommerce_product_add_to_cart_url', 'wvs_simple_product_cart_url', 10, 2);
49
  }
50
 
51
+ add_action('after_get_redirect_url', 'tinvwl_add_custom_url_woo_variation_swatches_pro');
52
 
53
+ function tinvwl_add_custom_url_woo_variation_swatches_pro()
54
+ {
55
+ add_filter('woocommerce_product_add_to_cart_url', 'wvs_simple_product_cart_url', 10, 2);
56
  }
57
 
58
+ function tinv_add_to_wishlist_woo_variation_swatches_pro()
59
+ {
60
 
61
+ wp_add_inline_script('tinvwl', "
62
  jQuery(document).ready(function($){
63
  $(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
64
  var button = $(el);
75
  }
76
  });
77
  });
78
+ ");
79
  }
80
 
81
+ add_action('wp_enqueue_scripts', 'tinv_add_to_wishlist_woo_variation_swatches_pro', 100, 1);
82
  }
integrations/woo-variations-table-grid.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_vartable_force_current_product' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Force current variation as global product object
@@ -26,31 +48,33 @@ if ( ! function_exists( 'tinvwl_vartable_force_current_product' ) ) {
26
  * @param array $values array of vartable values
27
  *
28
  */
29
- function tinvwl_vartable_force_current_product( $product_id, $values ) {
30
- if ( ! empty( $values['variation_id'] ) ) {
31
- $_product = wc_get_product( $values['variation_id'] );
32
- if ( $_product ) {
 
33
  global $vartable_product;
34
  $vartable_product = $_product;
35
 
36
- add_action( 'woocommerce_before_add_to_cart_button', 'tinvwl_vartable_set_product', 19 );
37
- add_action( 'woocommerce_before_add_to_cart_button', 'tinvwl_vartable_reset_product', 21 );
38
 
39
- add_action( 'woocommerce_after_add_to_cart_button', 'tinvwl_vartable_set_product', - 1 );
40
- add_action( 'woocommerce_after_add_to_cart_button', 'tinvwl_vartable_reset_product', 1 );
41
 
42
  }
43
  }
44
 
45
  }
46
 
47
- add_action( 'vartable_inside_add_to_cart_form', 'tinvwl_vartable_force_current_product', 10, 2 );
48
  }
49
 
50
  /**
51
  *
52
  */
53
- function tinvwl_vartable_set_product() {
 
54
  global $product, $vartable_product, $_product_tmp;
55
  // store global product data.
56
  $_product_tmp = $product;
@@ -61,13 +85,14 @@ function tinvwl_vartable_set_product() {
61
  /**
62
  *
63
  */
64
- function tinvwl_vartable_reset_product() {
 
65
  global $product, $_product_tmp;
66
  // store global post data.
67
  $product = $_product_tmp;
68
  }
69
 
70
- if ( ! function_exists( 'tinv_wishlist_meta_support_vartable' ) ) {
71
 
72
  /**
73
  * Clear custom meta
@@ -76,14 +101,15 @@ if ( ! function_exists( 'tinv_wishlist_meta_support_vartable' ) ) {
76
  *
77
  * @return array
78
  */
79
- function tinv_wishlist_meta_support_vartable( $meta ) {
 
80
 
81
- if ( function_exists( 'vartable_activate' ) ) {
82
 
83
- foreach ( $meta as $k => $v ) {
84
  $prefix = 'form_vartable';
85
- if ( 0 === strpos( $k, $prefix ) ) {
86
- unset( $meta[ $k ] );
87
  }
88
  }
89
  }
@@ -91,5 +117,5 @@ if ( ! function_exists( 'tinv_wishlist_meta_support_vartable' ) ) {
91
  return $meta;
92
  }
93
 
94
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_vartable' );
95
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woo-variations-table-grid";
24
+
25
+ $name = "Woocommerce Variations Table - Grid";
26
+
27
+ $available = function_exists('vartable_activate');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_vartable_force_current_product')) {
43
 
44
  /**
45
  * Force current variation as global product object
48
  * @param array $values array of vartable values
49
  *
50
  */
51
+ function tinvwl_vartable_force_current_product($product_id, $values)
52
+ {
53
+ if (!empty($values['variation_id'])) {
54
+ $_product = wc_get_product($values['variation_id']);
55
+ if ($_product) {
56
  global $vartable_product;
57
  $vartable_product = $_product;
58
 
59
+ add_action('woocommerce_before_add_to_cart_button', 'tinvwl_vartable_set_product', 19);
60
+ add_action('woocommerce_before_add_to_cart_button', 'tinvwl_vartable_reset_product', 21);
61
 
62
+ add_action('woocommerce_after_add_to_cart_button', 'tinvwl_vartable_set_product', -1);
63
+ add_action('woocommerce_after_add_to_cart_button', 'tinvwl_vartable_reset_product', 1);
64
 
65
  }
66
  }
67
 
68
  }
69
 
70
+ add_action('vartable_inside_add_to_cart_form', 'tinvwl_vartable_force_current_product', 10, 2);
71
  }
72
 
73
  /**
74
  *
75
  */
76
+ function tinvwl_vartable_set_product()
77
+ {
78
  global $product, $vartable_product, $_product_tmp;
79
  // store global product data.
80
  $_product_tmp = $product;
85
  /**
86
  *
87
  */
88
+ function tinvwl_vartable_reset_product()
89
+ {
90
  global $product, $_product_tmp;
91
  // store global post data.
92
  $product = $_product_tmp;
93
  }
94
 
95
+ if (!function_exists('tinv_wishlist_meta_support_vartable')) {
96
 
97
  /**
98
  * Clear custom meta
101
  *
102
  * @return array
103
  */
104
+ function tinv_wishlist_meta_support_vartable($meta)
105
+ {
106
 
107
+ if (function_exists('vartable_activate')) {
108
 
109
+ foreach ($meta as $k => $v) {
110
  $prefix = 'form_vartable';
111
+ if (0 === strpos($k, $prefix)) {
112
+ unset($meta[$k]);
113
  }
114
  }
115
  }
117
  return $meta;
118
  }
119
 
120
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_vartable');
121
  } // End if().
integrations/woocommerce-booking.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_booking' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta Booking & Appointment Plugin for WooCommerce
@@ -28,41 +50,42 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_booking' ) ) {
28
  *
29
  * @return array
30
  */
31
- function tinv_wishlist_metasupport_woocommerce_booking( $meta, $product_id, $variation_id ) {
32
- if ( ! class_exists( 'woocommerce_booking' ) ) {
 
33
  return $meta;
34
  }
35
 
36
- if ( ! empty( $meta['bkap_price_charged'] ) ) {
37
 
38
  $item_data = array(
39
  'bkap_booking' => array(),
40
- 'product_id' => $product_id,
41
  );
42
 
43
- if ( ! empty( $meta['booking_calender'] ) ) {
44
  $item_data['bkap_booking'][0]['date'] = $meta['booking_calender']['display'];
45
  }
46
 
47
- if ( ! empty( $meta['booking_calender_checkout'] ) ) {
48
  $item_data['bkap_booking'][0]['date_checkout'] = $meta['booking_calender_checkout']['display'];
49
  }
50
 
51
- if ( ! empty( $meta['time_slot'] ) ) {
52
  $item_data['bkap_booking'][0]['time_slot'] = $meta['time_slot']['display'];
53
  }
54
- if ( ! empty( $meta['bkap_front_resource_selection'] ) ) {
55
  $item_data['bkap_booking'][0]['resource_id'] = $meta['bkap_front_resource_selection']['display'];
56
  }
57
 
58
- $custom_meta = bkap_cart::bkap_get_item_data_booking( array(), $item_data );
59
 
60
- foreach ( $custom_meta as $key => $item ) {
61
- $custom_meta[ $key ]['key'] = $item['name'];
62
- unset( $custom_meta[ $key ]['name'] );
63
  }
64
 
65
- if ( $custom_meta ) {
66
  return $custom_meta;
67
  }
68
  }
@@ -70,10 +93,10 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_booking' ) ) {
70
  return $meta;
71
  }
72
 
73
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_booking', 20, 3 );
74
  } // End if().
75
 
76
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_booking' ) ) {
77
 
78
  /**
79
  * Modify price for Booking & Appointment Plugin for WooCommerce
@@ -84,22 +107,23 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_booking' ) ) {
84
  *
85
  * @return string
86
  */
87
- function tinvwl_item_price_woocommerce_booking( $price, $wl_product, $product ) {
88
- if ( ! class_exists( 'woocommerce_booking' ) ) {
 
89
  return $price;
90
  }
91
 
92
  $meta = $wl_product['meta'];
93
 
94
- if ( ! empty( $meta['bkap_price_charged'] ) ) {
95
 
96
  $price = $meta['bkap_price_charged'];
97
 
98
- return wc_price( $price );
99
  }
100
 
101
  return $price;
102
  }
103
 
104
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_booking', 20, 3 );
105
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-booking";
24
+
25
+ $name = "Booking & Appointment Plugin for WooCommerce";
26
+
27
+ $available = class_exists('woocommerce_booking');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_booking')) {
43
 
44
  /**
45
  * Set description for meta Booking & Appointment Plugin for WooCommerce
50
  *
51
  * @return array
52
  */
53
+ function tinv_wishlist_metasupport_woocommerce_booking($meta, $product_id, $variation_id)
54
+ {
55
+ if (!class_exists('woocommerce_booking')) {
56
  return $meta;
57
  }
58
 
59
+ if (!empty($meta['bkap_price_charged'])) {
60
 
61
  $item_data = array(
62
  'bkap_booking' => array(),
63
+ 'product_id' => $product_id,
64
  );
65
 
66
+ if (!empty($meta['booking_calender'])) {
67
  $item_data['bkap_booking'][0]['date'] = $meta['booking_calender']['display'];
68
  }
69
 
70
+ if (!empty($meta['booking_calender_checkout'])) {
71
  $item_data['bkap_booking'][0]['date_checkout'] = $meta['booking_calender_checkout']['display'];
72
  }
73
 
74
+ if (!empty($meta['time_slot'])) {
75
  $item_data['bkap_booking'][0]['time_slot'] = $meta['time_slot']['display'];
76
  }
77
+ if (!empty($meta['bkap_front_resource_selection'])) {
78
  $item_data['bkap_booking'][0]['resource_id'] = $meta['bkap_front_resource_selection']['display'];
79
  }
80
 
81
+ $custom_meta = bkap_cart::bkap_get_item_data_booking(array(), $item_data);
82
 
83
+ foreach ($custom_meta as $key => $item) {
84
+ $custom_meta[$key]['key'] = $item['name'];
85
+ unset($custom_meta[$key]['name']);
86
  }
87
 
88
+ if ($custom_meta) {
89
  return $custom_meta;
90
  }
91
  }
93
  return $meta;
94
  }
95
 
96
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_booking', 20, 3);
97
  } // End if().
98
 
99
+ if (!function_exists('tinvwl_item_price_woocommerce_booking')) {
100
 
101
  /**
102
  * Modify price for Booking & Appointment Plugin for WooCommerce
107
  *
108
  * @return string
109
  */
110
+ function tinvwl_item_price_woocommerce_booking($price, $wl_product, $product)
111
+ {
112
+ if (!class_exists('woocommerce_booking')) {
113
  return $price;
114
  }
115
 
116
  $meta = $wl_product['meta'];
117
 
118
+ if (!empty($meta['bkap_price_charged'])) {
119
 
120
  $price = $meta['bkap_price_charged'];
121
 
122
+ return wc_price($price);
123
  }
124
 
125
  return $price;
126
  }
127
 
128
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_booking', 20, 3);
129
  } // End if().
integrations/woocommerce-bookings.php CHANGED
@@ -13,13 +13,35 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( class_exists( 'WC_Bookings' ) ) {
 
21
 
22
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_bookings' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  /**
25
  * Set description for meta WooCommerce Bookings
@@ -30,23 +52,24 @@ if ( class_exists( 'WC_Bookings' ) ) {
30
  *
31
  * @return array
32
  */
33
- function tinv_wishlist_metasupport_woocommerce_bookings( $meta, $product_id, $variation_id ) {
34
- if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
 
35
  return $meta;
36
  }
37
- $product = wc_get_product( $variation_id ? $variation_id : $product_id );
38
- if ( is_wc_booking_product( $product ) ) {
39
- $booking_form = ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) ? new WC_Booking_Form( $product ) : new WC_Bookings_Cost_Calculation();
40
- $post_data = array();
41
- foreach ( $meta as $data ) {
42
- $post_data[ $data['key'] ] = $data['display'];
43
  }
44
- $booking_data = ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) ? $booking_form->get_posted_data( $post_data ) : wc_bookings_get_posted_data( $post_data, $product );
45
- $meta = array();
46
- foreach ( $booking_data as $key => $value ) {
47
- if ( ! preg_match( '/^_/', $key ) ) {
48
- $meta[ $key ] = array(
49
- 'key' => get_wc_booking_data_label( $key, $product ),
50
  'display' => $value,
51
  );
52
  }
@@ -56,10 +79,10 @@ if ( class_exists( 'WC_Bookings' ) ) {
56
  return $meta;
57
  }
58
 
59
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_bookings', 10, 3 );
60
  } // End if().
61
 
62
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_bookings' ) ) {
63
 
64
  /**
65
  * Modify price for WooCommerce Bookings
@@ -70,46 +93,47 @@ if ( class_exists( 'WC_Bookings' ) ) {
70
  *
71
  * @return string
72
  */
73
- function tinvwl_item_price_woocommerce_bookings( $price, $wl_product, $product ) {
74
- if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
 
75
  return $price;
76
  }
77
- if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
78
- $booking_form = ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) ? new WC_Booking_Form( $product ) : new WC_Bookings_Cost_Calculation();
79
- $cost = ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) ? $booking_form->calculate_booking_cost( $wl_product['meta'] ) : $booking_form->calculate_booking_cost( wc_bookings_get_posted_data( $wl_product['meta'], $product ), $product );
80
- if ( is_wp_error( $cost ) ) {
81
  return $price;
82
  }
83
 
84
- if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
85
- if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
86
- $display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
87
  } else {
88
- $display_price = $product->get_price_including_tax( 1, $cost );
89
  }
90
  } else {
91
- if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
92
- $display_price = wc_get_price_excluding_tax( $product, array( 'price' => $cost ) );
93
  } else {
94
- $display_price = $product->get_price_excluding_tax( 1, $cost );
95
  }
96
  }
97
 
98
- if ( version_compare( WC_VERSION, '2.4.0', '>=' ) ) {
99
- $price_suffix = $product->get_price_suffix( $cost, 1 );
100
  } else {
101
  $price_suffix = $product->get_price_suffix();
102
  }
103
- $price = wc_price( $display_price ) . $price_suffix;
104
  }
105
 
106
  return $price;
107
  }
108
 
109
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_bookings', 10, 3 );
110
  } // End if().
111
 
112
- if ( ! function_exists( 'tinvwl_item_status_woocommerce_bookings' ) ) {
113
 
114
  /**
115
  * Modify availability for WooCommerce Bookings
@@ -121,14 +145,15 @@ if ( class_exists( 'WC_Bookings' ) ) {
121
  *
122
  * @return type
123
  */
124
- function tinvwl_item_status_woocommerce_bookings( $status, $availability, $wl_product, $product ) {
125
- if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
 
126
  return $status;
127
  }
128
- if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
129
- $booking_form = ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) ? new WC_Booking_Form( $product ) : new WC_Bookings_Cost_Calculation();
130
- $cost = ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) ? $booking_form->calculate_booking_cost( $wl_product['meta'] ) : $booking_form->calculate_booking_cost( wc_bookings_get_posted_data( $wl_product['meta'], $product ), $product );
131
- if ( is_wp_error( $cost ) ) {
132
  return '<p class="stock out-of-stock"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . $cost->get_error_message() . '</span></p>';
133
  }
134
  }
@@ -136,16 +161,17 @@ if ( class_exists( 'WC_Bookings' ) ) {
136
  return $status;
137
  }
138
 
139
- add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_woocommerce_bookings', 10, 4 );
140
  }
141
 
142
 
143
- add_filter( 'woocommerce_product_object_query_args', 'tinvwl_item_product_type_woocommerce_bookings' );
144
 
145
- function tinvwl_item_product_type_woocommerce_bookings( $args ) {
 
146
 
147
- if ( ! is_array( $args['type'] ) ) {
148
- $args['type'] = [ $args['type'] ];
149
  }
150
 
151
  $args['type'][] = 'booking';
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
 
23
+ $slug = "woocommerce-bookings";
24
+
25
+ $name = "WooCommerce Bookings";
26
+
27
+ $available = class_exists('WC_Bookings');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (class_exists('WC_Bookings')) {
43
+
44
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_bookings')) {
45
 
46
  /**
47
  * Set description for meta WooCommerce Bookings
52
  *
53
  * @return array
54
  */
55
+ function tinv_wishlist_metasupport_woocommerce_bookings($meta, $product_id, $variation_id)
56
+ {
57
+ if (!class_exists('WC_Booking_Form') || !function_exists('is_wc_booking_product')) {
58
  return $meta;
59
  }
60
+ $product = wc_get_product($variation_id ? $variation_id : $product_id);
61
+ if (is_wc_booking_product($product)) {
62
+ $booking_form = (version_compare(WC_BOOKINGS_VERSION, '1.15.0', '<')) ? new WC_Booking_Form($product) : new WC_Bookings_Cost_Calculation();
63
+ $post_data = array();
64
+ foreach ($meta as $data) {
65
+ $post_data[$data['key']] = $data['display'];
66
  }
67
+ $booking_data = (version_compare(WC_BOOKINGS_VERSION, '1.15.0', '<')) ? $booking_form->get_posted_data($post_data) : wc_bookings_get_posted_data($post_data, $product);
68
+ $meta = array();
69
+ foreach ($booking_data as $key => $value) {
70
+ if (!preg_match('/^_/', $key)) {
71
+ $meta[$key] = array(
72
+ 'key' => get_wc_booking_data_label($key, $product),
73
  'display' => $value,
74
  );
75
  }
79
  return $meta;
80
  }
81
 
82
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_bookings', 10, 3);
83
  } // End if().
84
 
85
+ if (!function_exists('tinvwl_item_price_woocommerce_bookings')) {
86
 
87
  /**
88
  * Modify price for WooCommerce Bookings
93
  *
94
  * @return string
95
  */
96
+ function tinvwl_item_price_woocommerce_bookings($price, $wl_product, $product)
97
+ {
98
+ if (!class_exists('WC_Booking_Form') || !function_exists('is_wc_booking_product')) {
99
  return $price;
100
  }
101
+ if (is_wc_booking_product($product) && array_key_exists('meta', $wl_product)) {
102
+ $booking_form = (version_compare(WC_BOOKINGS_VERSION, '1.15.0', '<')) ? new WC_Booking_Form($product) : new WC_Bookings_Cost_Calculation();
103
+ $cost = (version_compare(WC_BOOKINGS_VERSION, '1.15.0', '<')) ? $booking_form->calculate_booking_cost($wl_product['meta']) : $booking_form->calculate_booking_cost(wc_bookings_get_posted_data($wl_product['meta'], $product), $product);
104
+ if (is_wp_error($cost)) {
105
  return $price;
106
  }
107
 
108
+ if ('incl' === get_option('woocommerce_tax_display_shop')) {
109
+ if (function_exists('wc_get_price_excluding_tax')) {
110
+ $display_price = wc_get_price_including_tax($product, array('price' => $cost));
111
  } else {
112
+ $display_price = $product->get_price_including_tax(1, $cost);
113
  }
114
  } else {
115
+ if (function_exists('wc_get_price_excluding_tax')) {
116
+ $display_price = wc_get_price_excluding_tax($product, array('price' => $cost));
117
  } else {
118
+ $display_price = $product->get_price_excluding_tax(1, $cost);
119
  }
120
  }
121
 
122
+ if (version_compare(WC_VERSION, '2.4.0', '>=')) {
123
+ $price_suffix = $product->get_price_suffix($cost, 1);
124
  } else {
125
  $price_suffix = $product->get_price_suffix();
126
  }
127
+ $price = wc_price($display_price) . $price_suffix;
128
  }
129
 
130
  return $price;
131
  }
132
 
133
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_bookings', 10, 3);
134
  } // End if().
135
 
136
+ if (!function_exists('tinvwl_item_status_woocommerce_bookings')) {
137
 
138
  /**
139
  * Modify availability for WooCommerce Bookings
145
  *
146
  * @return type
147
  */
148
+ function tinvwl_item_status_woocommerce_bookings($status, $availability, $wl_product, $product)
149
+ {
150
+ if (!class_exists('WC_Booking_Form') || !function_exists('is_wc_booking_product')) {
151
  return $status;
152
  }
153
+ if (is_wc_booking_product($product) && array_key_exists('meta', $wl_product)) {
154
+ $booking_form = (version_compare(WC_BOOKINGS_VERSION, '1.15.0', '<')) ? new WC_Booking_Form($product) : new WC_Bookings_Cost_Calculation();
155
+ $cost = (version_compare(WC_BOOKINGS_VERSION, '1.15.0', '<')) ? $booking_form->calculate_booking_cost($wl_product['meta']) : $booking_form->calculate_booking_cost(wc_bookings_get_posted_data($wl_product['meta'], $product), $product);
156
+ if (is_wp_error($cost)) {
157
  return '<p class="stock out-of-stock"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . $cost->get_error_message() . '</span></p>';
158
  }
159
  }
161
  return $status;
162
  }
163
 
164
+ add_filter('tinvwl_wishlist_item_status', 'tinvwl_item_status_woocommerce_bookings', 10, 4);
165
  }
166
 
167
 
168
+ add_filter('woocommerce_product_object_query_args', 'tinvwl_item_product_type_woocommerce_bookings');
169
 
170
+ function tinvwl_item_product_type_woocommerce_bookings($args)
171
+ {
172
 
173
+ if (!is_array($args['type'])) {
174
+ $args['type'] = [$args['type']];
175
  }
176
 
177
  $args['type'][] = 'booking';
integrations/woocommerce-composite-products.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_composite_products' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Composite Products
@@ -27,18 +49,19 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_composite_product
27
  *
28
  * @return array
29
  */
30
- function tinv_wishlist_metasupport_woocommerce_composite_products( $meta, $product_id ) {
31
- if ( array_key_exists( 'wccp_component_selection', $meta ) && is_array( $meta['wccp_component_selection'] ) ) {
 
32
  $meta = array();
33
  } // End if().
34
 
35
  return $meta;
36
  }
37
 
38
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_composite_products', 10, 2 );
39
  } // End if().
40
 
41
- if ( ! function_exists( 'tinvwl_row_woocommerce_composite_products' ) ) {
42
 
43
  /**
44
  * Add rows for sub product for WooCommerce Composite Products
@@ -46,129 +69,130 @@ if ( ! function_exists( 'tinvwl_row_woocommerce_composite_products' ) ) {
46
  * @param array $wl_product Wishlist Product.
47
  * @param \WC_Product_Composite $product Woocommerce Product.
48
  */
49
- function tinvwl_row_woocommerce_composite_products( $wl_product, $product ) {
50
- if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
 
51
  $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
52
 
53
  $components = $product->get_components();
54
- foreach ( $components as $component_id => $component ) {
55
- $composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
56
- $composited_product_quantity = isset( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) : $component->get_quantity( 'min' );
57
 
58
- $composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
59
 
60
- if ( $composited_product_id ) {
61
 
62
- $composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
63
 
64
- if ( ! $composited_product_wrapper ) {
65
  continue;
66
  }
67
 
68
  $composited_product = $composited_product_wrapper->get_product();
69
 
70
- if ( $composited_product->is_sold_individually() && $composited_product_quantity > 1 ) {
71
  $composited_product_quantity = 1;
72
  }
73
 
74
- $product_url = $composited_product->get_permalink();
75
  $product_image = $composited_product->get_image();
76
- $product_title = is_callable( array(
77
  $composited_product,
78
  'get_name'
79
- ) ) ? $composited_product->get_name() : $composited_product->get_title();
80
  $product_price = $composited_product->get_price();
81
 
82
- $component_option = $product->get_component_option( $component_id, $composited_product_id );
83
 
84
  $discount = $component_option->get_discount();
85
 
86
- if ( $discount ) {
87
- $product_price = $product_price * ( 100 - $discount ) / 100;
88
  }
89
- $product_price = wc_price( $product_price );
90
 
91
- if ( $component_option ) {
92
- if ( false === $component_option->is_priced_individually() && $composited_product->get_price() == 0 ) {
93
  $product_price = '';
94
- } elseif ( false === $component_option->get_component()->is_subtotal_visible( 'cart' ) ) {
95
  $product_price = '';
96
- } elseif ( apply_filters( 'woocommerce_add_composited_cart_item_prices', true, false, false ) ) {
97
- if ( $product_price ) {
98
  $product_price = '<span class="component_table_item_price">' . $product_price . '</span>';
99
  }
100
  }
101
  }
102
 
103
- if ( $composited_product->is_visible() ) {
104
- $product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
105
- $product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
106
  }
107
- $product_title .= tinv_wishlist_get_item_data( $composited_product, $wl_product );
108
 
109
- $availability = (array) $composited_product->get_availability();
110
- if ( ! array_key_exists( 'availability', $availability ) ) {
111
  $availability['availability'] = '';
112
  }
113
- if ( ! array_key_exists( 'class', $availability ) ) {
114
  $availability['class'] = '';
115
  }
116
- $availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
117
- $row_string = '<tr>';
118
- $row_string .= ( ( ! is_user_logged_in() || get_current_user_id() !== $wl_product['author'] ) ? ( ( ! tinv_get_option( 'table', 'colm_checkbox' ) ) ? '' : '<td colspan="1"></td>' ) : '<td colspan="' . ( ( ! tinv_get_option( 'table', 'colm_checkbox' ) ) ? '1' : '2' ) . '"></td>' ) . '&nbsp;<td class="product-thumbnail">%2$s</td><td class="product-name">%1$s:<br/>%3$s</td>';
119
- if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
120
- $row_string .= ( $product_price && ! $composited_product->is_type( 'bundle' ) ) ? '<td class="product-price">%4$s &times; %6$s</td>' : '<td class="product-price">%4$s</td>';
121
  }
122
- if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
123
  $row_string .= '<td class="product-date">&nbsp;</td>';
124
  }
125
- if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
126
  $row_string .= '<td class="product-stock">%5$s</td>';
127
  }
128
- if ( tinv_get_option( 'product_table', 'colm_quantity' ) ) {
129
  $row_string .= '<td class="product-quantity">&nbsp;</td>';
130
  }
131
- if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
132
  $row_string .= '<td class="product-action">&nbsp;</td>';
133
  }
134
  $row_string .= '</tr>';
135
 
136
- if ( $composited_product->is_type( 'bundle' ) ) {
137
  $product_price = $availability_html = $product_title = '';
138
  }
139
 
140
- echo sprintf( $row_string, is_callable( array(
141
  $component,
142
  'get_name'
143
- ) ) ? $component->get_name() : $component->get_title(), $product_image, $product_title, $product_price, $availability_html, $composited_product_quantity * $product_quantity ); // WPCS: xss ok.
144
 
145
- if ( $composited_product->is_type( 'bundle' ) ) {
146
 
147
- $wl_product_bundle = $wl_product;
148
  $wl_product_bundle['product_id'] = $composited_product->get_id();
149
 
150
  $component_meta = array();
151
 
152
- foreach ( $wl_product['meta'] as $key => $value ) {
153
- if ( substr( $key, 0, strlen( 'component_' . $component_id ) ) === 'component_' . $component_id ) {
154
 
155
- $component_meta[ substr( $key, strlen( 'component_' . $component_id . '_' ), strlen( $key ) ) ] = $value;
156
  }
157
  }
158
 
159
  $wl_product_bundle['meta'] = $component_meta;
160
 
161
- tinvwl_row_woocommerce_product_bundles( $wl_product_bundle, $composited_product, $composited_product_wrapper->get_discount() );
162
  }
163
  } // End if().
164
  } // End foreach().
165
  } // End if().
166
  }
167
 
168
- add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_composite_products', 10, 2 );
169
  } // End if().
170
 
171
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_composite_products' ) ) {
172
 
173
  /**
174
  * Modify price for WooCommerce Composite Products
@@ -179,66 +203,67 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_composite_products' ) ) {
179
  *
180
  * @return string
181
  */
182
- function tinvwl_item_price_woocommerce_composite_products( $price, $wl_product, $product ) {
183
- if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
184
- $components = $product->get_components();
185
- $_price = $product->get_price();
 
186
  $regular_price = $product->get_regular_price();
187
- foreach ( $components as $component_id => $component ) {
188
- $composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
189
- $composited_product_quantity = isset( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) : $component->get_quantity( 'min' );
190
 
191
- $composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
192
 
193
- if ( $composited_product_id ) {
194
- $composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
195
- if ( $component->is_priced_individually() ) {
196
 
197
  $composited_product = $composited_product_wrapper->get_product();
198
- if ( $composited_product->is_type( 'bundle' ) ) {
199
 
200
- $wl_product_bundle = $wl_product;
201
  $wl_product_bundle['product_id'] = $composited_product->get_id();
202
 
203
  $component_meta = array();
204
 
205
- foreach ( $wl_product['meta'] as $key => $value ) {
206
- if ( substr( $key, 0, strlen( 'component_' . $component_id ) ) === 'component_' . $component_id ) {
207
 
208
- $component_meta[ substr( $key, strlen( 'component_' . $component_id . '_' ), strlen( $key ) ) ] = $value;
209
  }
210
  }
211
 
212
  $wl_product_bundle['meta'] = $component_meta;
213
 
214
- $bundle_price = tinvwl_item_price_woocommerce_product_bundles( 0, $wl_product_bundle, $composited_product, true );
215
  $regular_price += $bundle_price;
216
 
217
- if ( $discount = $composited_product_wrapper->get_discount() ) {
218
- $bundle_price = empty( $bundle_price ) ? $bundle_price : round( (double) $bundle_price * ( 100 - $discount ) / 100, wc_cp_price_num_decimals() );
219
  }
220
  $_price += $bundle_price;
221
 
222
  continue;
223
  }
224
 
225
- $_price += $composited_product_wrapper->get_price() * $composited_product_quantity;
226
  $regular_price += $composited_product_wrapper->get_regular_price() * $composited_product_quantity;
227
  }
228
  }
229
  }
230
 
231
- $price = wc_price( $_price ) . $product->get_price_suffix();
232
 
233
  }
234
 
235
  return $price;
236
  }
237
 
238
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_composite_products', 10, 3 );
239
  } // End if().
240
 
241
- if ( ! function_exists( 'tinv_wishlist_metaprepare_woocommerce_composite_products' ) ) {
242
 
243
  /**
244
  * Prepare save meta for WooCommerce Composite Products
@@ -247,17 +272,18 @@ if ( ! function_exists( 'tinv_wishlist_metaprepare_woocommerce_composite_product
247
  *
248
  * @return array
249
  */
250
- function tinv_wishlist_metaprepare_woocommerce_composite_products( $meta ) {
 
251
 
252
- foreach ( $meta as $key => $value ) {
253
- if ( strpos( $key, 'wccp_component_' ) === 0 && ! is_array( $value ) ) {
254
 
255
- $meta[ $key ] = json_decode( $value );
256
  }
257
  }
258
 
259
  return $meta;
260
  }
261
 
262
- add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_woocommerce_composite_products' );
263
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-composite-products";
24
+
25
+ $name = "WooCommerce Composite Products";
26
+
27
+ $available = class_exists('WC_Composite_Products');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_composite_products')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Composite Products
49
  *
50
  * @return array
51
  */
52
+ function tinv_wishlist_metasupport_woocommerce_composite_products($meta, $product_id)
53
+ {
54
+ if (array_key_exists('wccp_component_selection', $meta) && is_array($meta['wccp_component_selection'])) {
55
  $meta = array();
56
  } // End if().
57
 
58
  return $meta;
59
  }
60
 
61
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_composite_products', 10, 2);
62
  } // End if().
63
 
64
+ if (!function_exists('tinvwl_row_woocommerce_composite_products')) {
65
 
66
  /**
67
  * Add rows for sub product for WooCommerce Composite Products
69
  * @param array $wl_product Wishlist Product.
70
  * @param \WC_Product_Composite $product Woocommerce Product.
71
  */
72
+ function tinvwl_row_woocommerce_composite_products($wl_product, $product)
73
+ {
74
+ if (is_object($product) && $product->is_type('composite') && array_key_exists('wccp_component_selection', $wl_product['meta'])) {
75
  $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
76
 
77
  $components = $product->get_components();
78
+ foreach ($components as $component_id => $component) {
79
+ $composited_product_id = !empty($wl_product['meta']['wccp_component_selection'][$component_id]) ? absint($wl_product['meta']['wccp_component_selection'][$component_id]) : '';
80
+ $composited_product_quantity = isset($wl_product['meta']['wccp_component_quantity'][$component_id]) ? absint($wl_product['meta']['wccp_component_quantity'][$component_id]) : $component->get_quantity('min');
81
 
82
+ $composited_variation_id = isset($wl_product['meta']['wccp_variation_id'][$component_id]) ? wc_clean($wl_product['meta']['wccp_variation_id'][$component_id]) : '';
83
 
84
+ if ($composited_product_id) {
85
 
86
+ $composited_product_wrapper = $component->get_option($composited_variation_id ? $composited_variation_id : $composited_product_id);
87
 
88
+ if (!$composited_product_wrapper) {
89
  continue;
90
  }
91
 
92
  $composited_product = $composited_product_wrapper->get_product();
93
 
94
+ if ($composited_product->is_sold_individually() && $composited_product_quantity > 1) {
95
  $composited_product_quantity = 1;
96
  }
97
 
98
+ $product_url = $composited_product->get_permalink();
99
  $product_image = $composited_product->get_image();
100
+ $product_title = is_callable(array(
101
  $composited_product,
102
  'get_name'
103
+ )) ? $composited_product->get_name() : $composited_product->get_title();
104
  $product_price = $composited_product->get_price();
105
 
106
+ $component_option = $product->get_component_option($component_id, $composited_product_id);
107
 
108
  $discount = $component_option->get_discount();
109
 
110
+ if ($discount) {
111
+ $product_price = $product_price * (100 - $discount) / 100;
112
  }
113
+ $product_price = wc_price($product_price);
114
 
115
+ if ($component_option) {
116
+ if (false === $component_option->is_priced_individually() && $composited_product->get_price() == 0) {
117
  $product_price = '';
118
+ } elseif (false === $component_option->get_component()->is_subtotal_visible('cart')) {
119
  $product_price = '';
120
+ } elseif (apply_filters('woocommerce_add_composited_cart_item_prices', true, false, false)) {
121
+ if ($product_price) {
122
  $product_price = '<span class="component_table_item_price">' . $product_price . '</span>';
123
  }
124
  }
125
  }
126
 
127
+ if ($composited_product->is_visible()) {
128
+ $product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
129
+ $product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
130
  }
131
+ $product_title .= tinv_wishlist_get_item_data($composited_product, $wl_product);
132
 
133
+ $availability = (array)$composited_product->get_availability();
134
+ if (!array_key_exists('availability', $availability)) {
135
  $availability['availability'] = '';
136
  }
137
+ if (!array_key_exists('class', $availability)) {
138
  $availability['class'] = '';
139
  }
140
+ $availability_html = empty($availability['availability']) ? '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__('In stock', 'ti-woocommerce-wishlist') . '</span></p>' : '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html($availability['availability']) . '</span></p>';
141
+ $row_string = '<tr>';
142
+ $row_string .= ((!is_user_logged_in() || get_current_user_id() !== $wl_product['author']) ? ((!tinv_get_option('table', 'colm_checkbox')) ? '' : '<td colspan="1"></td>') : '<td colspan="' . ((!tinv_get_option('table', 'colm_checkbox')) ? '1' : '2') . '"></td>') . '&nbsp;<td class="product-thumbnail">%2$s</td><td class="product-name">%1$s:<br/>%3$s</td>';
143
+ if (tinv_get_option('product_table', 'colm_price')) {
144
+ $row_string .= ($product_price && !$composited_product->is_type('bundle')) ? '<td class="product-price">%4$s &times; %6$s</td>' : '<td class="product-price">%4$s</td>';
145
  }
146
+ if (tinv_get_option('product_table', 'colm_date')) {
147
  $row_string .= '<td class="product-date">&nbsp;</td>';
148
  }
149
+ if (tinv_get_option('product_table', 'colm_stock')) {
150
  $row_string .= '<td class="product-stock">%5$s</td>';
151
  }
152
+ if (tinv_get_option('product_table', 'colm_quantity')) {
153
  $row_string .= '<td class="product-quantity">&nbsp;</td>';
154
  }
155
+ if (tinv_get_option('product_table', 'add_to_cart')) {
156
  $row_string .= '<td class="product-action">&nbsp;</td>';
157
  }
158
  $row_string .= '</tr>';
159
 
160
+ if ($composited_product->is_type('bundle')) {
161
  $product_price = $availability_html = $product_title = '';
162
  }
163
 
164
+ echo sprintf($row_string, is_callable(array(
165
  $component,
166
  'get_name'
167
+ )) ? $component->get_name() : $component->get_title(), $product_image, $product_title, $product_price, $availability_html, $composited_product_quantity * $product_quantity); // WPCS: xss ok.
168
 
169
+ if ($composited_product->is_type('bundle')) {
170
 
171
+ $wl_product_bundle = $wl_product;
172
  $wl_product_bundle['product_id'] = $composited_product->get_id();
173
 
174
  $component_meta = array();
175
 
176
+ foreach ($wl_product['meta'] as $key => $value) {
177
+ if (substr($key, 0, strlen('component_' . $component_id)) === 'component_' . $component_id) {
178
 
179
+ $component_meta[substr($key, strlen('component_' . $component_id . '_'), strlen($key))] = $value;
180
  }
181
  }
182
 
183
  $wl_product_bundle['meta'] = $component_meta;
184
 
185
+ tinvwl_row_woocommerce_product_bundles($wl_product_bundle, $composited_product, $composited_product_wrapper->get_discount());
186
  }
187
  } // End if().
188
  } // End foreach().
189
  } // End if().
190
  }
191
 
192
+ add_action('tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_composite_products', 10, 2);
193
  } // End if().
194
 
195
+ if (!function_exists('tinvwl_item_price_woocommerce_composite_products')) {
196
 
197
  /**
198
  * Modify price for WooCommerce Composite Products
203
  *
204
  * @return string
205
  */
206
+ function tinvwl_item_price_woocommerce_composite_products($price, $wl_product, $product)
207
+ {
208
+ if (is_object($product) && $product->is_type('composite') && array_key_exists('wccp_component_selection', $wl_product['meta'])) {
209
+ $components = $product->get_components();
210
+ $_price = $product->get_price();
211
  $regular_price = $product->get_regular_price();
212
+ foreach ($components as $component_id => $component) {
213
+ $composited_product_id = !empty($wl_product['meta']['wccp_component_selection'][$component_id]) ? absint($wl_product['meta']['wccp_component_selection'][$component_id]) : '';
214
+ $composited_product_quantity = isset($wl_product['meta']['wccp_component_quantity'][$component_id]) ? absint($wl_product['meta']['wccp_component_quantity'][$component_id]) : $component->get_quantity('min');
215
 
216
+ $composited_variation_id = isset($wl_product['meta']['wccp_variation_id'][$component_id]) ? wc_clean($wl_product['meta']['wccp_variation_id'][$component_id]) : '';
217
 
218
+ if ($composited_product_id) {
219
+ $composited_product_wrapper = $component->get_option($composited_variation_id ? $composited_variation_id : $composited_product_id);
220
+ if ($component->is_priced_individually()) {
221
 
222
  $composited_product = $composited_product_wrapper->get_product();
223
+ if ($composited_product->is_type('bundle')) {
224
 
225
+ $wl_product_bundle = $wl_product;
226
  $wl_product_bundle['product_id'] = $composited_product->get_id();
227
 
228
  $component_meta = array();
229
 
230
+ foreach ($wl_product['meta'] as $key => $value) {
231
+ if (substr($key, 0, strlen('component_' . $component_id)) === 'component_' . $component_id) {
232
 
233
+ $component_meta[substr($key, strlen('component_' . $component_id . '_'), strlen($key))] = $value;
234
  }
235
  }
236
 
237
  $wl_product_bundle['meta'] = $component_meta;
238
 
239
+ $bundle_price = tinvwl_item_price_woocommerce_product_bundles(0, $wl_product_bundle, $composited_product, true);
240
  $regular_price += $bundle_price;
241
 
242
+ if ($discount = $composited_product_wrapper->get_discount()) {
243
+ $bundle_price = empty($bundle_price) ? $bundle_price : round((double)$bundle_price * (100 - $discount) / 100, wc_cp_price_num_decimals());
244
  }
245
  $_price += $bundle_price;
246
 
247
  continue;
248
  }
249
 
250
+ $_price += $composited_product_wrapper->get_price() * $composited_product_quantity;
251
  $regular_price += $composited_product_wrapper->get_regular_price() * $composited_product_quantity;
252
  }
253
  }
254
  }
255
 
256
+ $price = wc_price($_price) . $product->get_price_suffix();
257
 
258
  }
259
 
260
  return $price;
261
  }
262
 
263
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_composite_products', 10, 3);
264
  } // End if().
265
 
266
+ if (!function_exists('tinv_wishlist_metaprepare_woocommerce_composite_products')) {
267
 
268
  /**
269
  * Prepare save meta for WooCommerce Composite Products
272
  *
273
  * @return array
274
  */
275
+ function tinv_wishlist_metaprepare_woocommerce_composite_products($meta)
276
+ {
277
 
278
+ foreach ($meta as $key => $value) {
279
+ if (strpos($key, 'wccp_component_') === 0 && !is_array($value)) {
280
 
281
+ $meta[$key] = json_decode($value);
282
  }
283
  }
284
 
285
  return $meta;
286
  }
287
 
288
+ add_filter('tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_woocommerce_composite_products');
289
  }
integrations/woocommerce-custom-fields.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_fields' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Modify price for WooCommerce Custom Fields.
@@ -28,26 +50,27 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_fields' ) ) {
28
  *
29
  * @return string
30
  */
31
- function tinvwl_item_price_woocommerce_custom_fields( $price, $wl_product, $product ) {
 
32
 
33
- if ( class_exists( 'WCCF' ) && isset( $wl_product['meta']['wccf']['product_field'] ) ) {
34
 
35
  $posted = array();
36
 
37
- foreach ( $wl_product['meta']['wccf']['product_field'] as $key => $value ) {
38
- $posted[ $key ] = array( 'value' => $value );
39
  }
40
 
41
- $price = wc_price( WCCF_Pricing::get_adjusted_price( $product->get_price(), $wl_product['product_id'], $wl_product['variation_id'], $posted, 1, false, false, $product, false ) );
42
  }
43
 
44
  return $price;
45
  }
46
 
47
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_fields', 10, 3 );
48
  } // End if().
49
 
50
- if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) ) {
51
 
52
  /**
53
  * Set description for meta WooCommerce Custom Fields
@@ -58,78 +81,79 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) )
58
  *
59
  * @return array
60
  */
61
- function tinv_wishlist_item_meta_woocommerce_custom_fields( $item_data, $product_id, $variation_id ) {
 
62
 
63
- if ( class_exists( 'WCCF' ) && isset( $item_data['wccf'] ) ) {
64
 
65
- $id = ( $variation_id ) ? $variation_id : $product_id;
66
- $product = wc_get_product( $id );
67
- if ( $product ) {
68
 
69
  // Get fields to save values for
70
- $fields = WCCF_Product_Field_Controller::get_filtered( null, array(
71
- 'item_id' => $product_id,
72
  'child_id' => $variation_id,
73
- ) );
74
 
75
  // Set quantity
76
- $quantity = 1;
77
- $quantity_index = null;
78
  $display_pricing = null;
79
 
80
  // Check if pricing can be displayed for this product
81
- if ( $display_pricing === null ) {
82
- $display_pricing = ! WCCF_WC_Product::skip_pricing( $product );
83
  }
84
 
85
- foreach ( $fields as $field ) {
86
 
87
  // Check how many times to iterate the same field (used for quantity-based product fields)
88
- if ( $quantity_index !== null ) {
89
- $iterations = ( $quantity_index + 1 );
90
- $i = $quantity_index;
91
  } else {
92
- $iterations = ( $field->is_quantity_based() && $quantity ) ? $quantity : 1;
93
- $i = 0;
94
  }
95
 
96
  // Start iteration of the same field
97
- for ( $i = $i; $i < $iterations; $i ++ ) {
98
 
99
  // Get field id
100
- $field_id = $field->get_id() . ( $i ? ( '_' . $i ) : '' );
101
 
102
  // Special handling for files
103
- if ( $field->field_type_is( 'file' ) ) {
104
  //just skip this field type because we can't save uploaded data.
105
  } // Handle other field values
106
  else {
107
 
108
  // Check if any data for this field was posted or is available in request query vars for GET requests
109
- if ( isset( $item_data['wccf']['display']['product_field'][ $field_id ] ) ) {
110
 
111
  // Get field value
112
- if ( isset( $item_data['wccf']['display']['product_field'][ $field_id ] ) ) {
113
- $field_value = $item_data['wccf']['display']['product_field'][ $field_id ];
114
  }
115
 
116
  // Prepare multiselect field values
117
- if ( $field->accepts_multiple_values() ) {
118
 
119
  // Ensure that value is array
120
- $value = ! RightPress_Help::is_empty( $field_value ) ? (array) $field_value : array();
121
 
122
  // Filter out hidden placeholder input value
123
- $value = array_filter( (array) $value, function ( $test_value ) {
124
- return trim( $test_value ) !== '';
125
- } );
126
  } else {
127
- $value = stripslashes( trim( $field_value ) );
128
  }
129
 
130
  $item_data[] = array(
131
- 'key' => $field->get_label(),
132
- 'display' => $field->format_display_value( array( 'value' => $value ), $display_pricing ),
133
  );
134
 
135
  }
@@ -137,13 +161,13 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) )
137
  }
138
  }
139
 
140
- unset( $item_data['wccf'] );
141
- unset( $item_data['wccf_ignore'] );
142
  }
143
  }
144
 
145
  return $item_data;
146
  }
147
 
148
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_fields', 10, 3 );
149
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-custom-fields";
24
+
25
+ $name = "WooCommerce Custom Fields";
26
+
27
+ $available = class_exists('WCCF');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_item_price_woocommerce_custom_fields')) {
43
 
44
  /**
45
  * Modify price for WooCommerce Custom Fields.
50
  *
51
  * @return string
52
  */
53
+ function tinvwl_item_price_woocommerce_custom_fields($price, $wl_product, $product)
54
+ {
55
 
56
+ if (class_exists('WCCF') && isset($wl_product['meta']['wccf']['product_field'])) {
57
 
58
  $posted = array();
59
 
60
+ foreach ($wl_product['meta']['wccf']['product_field'] as $key => $value) {
61
+ $posted[$key] = array('value' => $value);
62
  }
63
 
64
+ $price = wc_price(WCCF_Pricing::get_adjusted_price($product->get_price(), $wl_product['product_id'], $wl_product['variation_id'], $posted, 1, false, false, $product, false));
65
  }
66
 
67
  return $price;
68
  }
69
 
70
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_fields', 10, 3);
71
  } // End if().
72
 
73
+ if (!function_exists('tinv_wishlist_item_meta_woocommerce_custom_fields')) {
74
 
75
  /**
76
  * Set description for meta WooCommerce Custom Fields
81
  *
82
  * @return array
83
  */
84
+ function tinv_wishlist_item_meta_woocommerce_custom_fields($item_data, $product_id, $variation_id)
85
+ {
86
 
87
+ if (class_exists('WCCF') && isset($item_data['wccf'])) {
88
 
89
+ $id = ($variation_id) ? $variation_id : $product_id;
90
+ $product = wc_get_product($id);
91
+ if ($product) {
92
 
93
  // Get fields to save values for
94
+ $fields = WCCF_Product_Field_Controller::get_filtered(null, array(
95
+ 'item_id' => $product_id,
96
  'child_id' => $variation_id,
97
+ ));
98
 
99
  // Set quantity
100
+ $quantity = 1;
101
+ $quantity_index = null;
102
  $display_pricing = null;
103
 
104
  // Check if pricing can be displayed for this product
105
+ if ($display_pricing === null) {
106
+ $display_pricing = !WCCF_WC_Product::skip_pricing($product);
107
  }
108
 
109
+ foreach ($fields as $field) {
110
 
111
  // Check how many times to iterate the same field (used for quantity-based product fields)
112
+ if ($quantity_index !== null) {
113
+ $iterations = ($quantity_index + 1);
114
+ $i = $quantity_index;
115
  } else {
116
+ $iterations = ($field->is_quantity_based() && $quantity) ? $quantity : 1;
117
+ $i = 0;
118
  }
119
 
120
  // Start iteration of the same field
121
+ for ($i = $i; $i < $iterations; $i++) {
122
 
123
  // Get field id
124
+ $field_id = $field->get_id() . ($i ? ('_' . $i) : '');
125
 
126
  // Special handling for files
127
+ if ($field->field_type_is('file')) {
128
  //just skip this field type because we can't save uploaded data.
129
  } // Handle other field values
130
  else {
131
 
132
  // Check if any data for this field was posted or is available in request query vars for GET requests
133
+ if (isset($item_data['wccf']['display']['product_field'][$field_id])) {
134
 
135
  // Get field value
136
+ if (isset($item_data['wccf']['display']['product_field'][$field_id])) {
137
+ $field_value = $item_data['wccf']['display']['product_field'][$field_id];
138
  }
139
 
140
  // Prepare multiselect field values
141
+ if ($field->accepts_multiple_values()) {
142
 
143
  // Ensure that value is array
144
+ $value = !RightPress_Help::is_empty($field_value) ? (array)$field_value : array();
145
 
146
  // Filter out hidden placeholder input value
147
+ $value = array_filter((array)$value, function ($test_value) {
148
+ return trim($test_value) !== '';
149
+ });
150
  } else {
151
+ $value = stripslashes(trim($field_value));
152
  }
153
 
154
  $item_data[] = array(
155
+ 'key' => $field->get_label(),
156
+ 'display' => $field->format_display_value(array('value' => $value), $display_pricing),
157
  );
158
 
159
  }
161
  }
162
  }
163
 
164
+ unset($item_data['wccf']);
165
+ unset($item_data['wccf_ignore']);
166
  }
167
  }
168
 
169
  return $item_data;
170
  }
171
 
172
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_fields', 10, 3);
173
  } // End if().
integrations/woocommerce-gravityforms-product-addons.php CHANGED
@@ -13,20 +13,43 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_gf_productaddon_support' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Add supports WooCommerce - Gravity Forms Product Add-Ons
24
  */
25
- function tinvwl_gf_productaddon_support() {
26
- if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
 
27
  return false;
28
  }
29
- if ( ! function_exists( 'gf_productaddon_text_button' ) ) {
30
 
31
  /**
32
  * Change text for button add to cart
@@ -37,16 +60,17 @@ if ( ! function_exists( 'tinvwl_gf_productaddon_support' ) ) {
37
  *
38
  * @return string
39
  */
40
- function gf_productaddon_text_button( $text_add_to_cart, $wl_product, $product ) {
41
- $gravity_form_data = get_post_meta( ( ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
 
42
 
43
- return ( $gravity_form_data ) ? __( 'Select options', 'ti-woocommerce-wishlist' ) : $text_add_to_cart;
44
  }
45
 
46
- add_filter( 'tinvwl_wishlist_item_add_to_cart', 'gf_productaddon_text_button', 10, 3 );
47
  }
48
 
49
- if ( ! function_exists( 'gf_productaddon_run_action_button' ) ) {
50
 
51
  /**
52
  * Check for make redirect to url
@@ -56,16 +80,17 @@ if ( ! function_exists( 'tinvwl_gf_productaddon_support' ) ) {
56
  *
57
  * @return boolean
58
  */
59
- function gf_productaddon_run_action_button( $need, $product ) {
60
- $gravity_form_data = get_post_meta( ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ), '_gravity_form_data', true );
 
61
 
62
- return ( $gravity_form_data ) ? true : $need;
63
  }
64
 
65
- add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'gf_productaddon_run_action_button', 10, 2 );
66
  }
67
 
68
- if ( ! function_exists( 'gf_productaddon_action_button' ) ) {
69
 
70
  /**
71
  * Redirect url
@@ -75,20 +100,21 @@ if ( ! function_exists( 'tinvwl_gf_productaddon_support' ) ) {
75
  *
76
  * @return string
77
  */
78
- function gf_productaddon_action_button( $url, $product ) {
79
- $gravity_form_data = get_post_meta( ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ), '_gravity_form_data', true );
 
80
 
81
- return ( $gravity_form_data ) ? $product->get_permalink() : $url;
82
  }
83
 
84
- add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'gf_productaddon_action_button', 10, 2 );
85
  }
86
  }
87
 
88
- add_action( 'init', 'tinvwl_gf_productaddon_support' );
89
  } // End if().
90
 
91
- if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
92
 
93
  /**
94
  * Set description for meta WooCommerce - Gravity Forms Product Add-Ons
@@ -97,16 +123,17 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
97
  *
98
  * @return array
99
  */
100
- function tinv_wishlist_metasupport_wc_gf_addons( $meta ) {
101
- if ( array_key_exists( 'wc_gforms_form_id', $meta ) && class_exists( 'RGFormsModel' ) ) {
102
- $form_meta = RGFormsModel::get_form_meta( $meta['wc_gforms_form_id']['display'] );
103
- if ( array_key_exists( 'fields', $form_meta ) ) {
 
104
  $_meta = array();
105
- foreach ( $form_meta['fields'] as $field ) {
106
- $field_name = $field->get_first_input_id( array( 'id' => 0 ) );
107
- if ( array_key_exists( $field_name, $meta ) ) {
108
- $meta[ $field_name ]['key'] = $field->label;
109
- $_meta[ $field_name ] = $meta[ $field_name ];
110
  }
111
  }
112
  $meta = $_meta;
@@ -116,5 +143,5 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
116
  return $meta;
117
  }
118
 
119
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_wc_gf_addons' );
120
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-gravityforms-product-addons";
24
+
25
+ $name = "WooCommerce Gravity Forms Product Add-Ons";
26
+
27
+ $available = class_exists('woocommerce_gravityforms');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_gf_productaddon_support')) {
43
 
44
  /**
45
  * Add supports WooCommerce - Gravity Forms Product Add-Ons
46
  */
47
+ function tinvwl_gf_productaddon_support()
48
+ {
49
+ if (!class_exists('woocommerce_gravityforms')) {
50
  return false;
51
  }
52
+ if (!function_exists('gf_productaddon_text_button')) {
53
 
54
  /**
55
  * Change text for button add to cart
60
  *
61
  * @return string
62
  */
63
+ function gf_productaddon_text_button($text_add_to_cart, $wl_product, $product)
64
+ {
65
+ $gravity_form_data = get_post_meta((($product->is_type('variation') ? $product->get_parent_id() : $product->get_id())), '_gravity_form_data', true);
66
 
67
+ return ($gravity_form_data) ? __('Select options', 'ti-woocommerce-wishlist') : $text_add_to_cart;
68
  }
69
 
70
+ add_filter('tinvwl_wishlist_item_add_to_cart', 'gf_productaddon_text_button', 10, 3);
71
  }
72
 
73
+ if (!function_exists('gf_productaddon_run_action_button')) {
74
 
75
  /**
76
  * Check for make redirect to url
80
  *
81
  * @return boolean
82
  */
83
+ function gf_productaddon_run_action_button($need, $product)
84
+ {
85
+ $gravity_form_data = get_post_meta(($product->is_type('variation') ? $product->get_parent_id() : $product->get_id()), '_gravity_form_data', true);
86
 
87
+ return ($gravity_form_data) ? true : $need;
88
  }
89
 
90
+ add_filter('tinvwl_product_add_to_cart_need_redirect', 'gf_productaddon_run_action_button', 10, 2);
91
  }
92
 
93
+ if (!function_exists('gf_productaddon_action_button')) {
94
 
95
  /**
96
  * Redirect url
100
  *
101
  * @return string
102
  */
103
+ function gf_productaddon_action_button($url, $product)
104
+ {
105
+ $gravity_form_data = get_post_meta(($product->is_type('variation') ? $product->get_parent_id() : $product->get_id()), '_gravity_form_data', true);
106
 
107
+ return ($gravity_form_data) ? $product->get_permalink() : $url;
108
  }
109
 
110
+ add_filter('tinvwl_product_add_to_cart_redirect_url', 'gf_productaddon_action_button', 10, 2);
111
  }
112
  }
113
 
114
+ add_action('init', 'tinvwl_gf_productaddon_support');
115
  } // End if().
116
 
117
+ if (!function_exists('tinv_wishlist_metasupport_wc_gf_addons')) {
118
 
119
  /**
120
  * Set description for meta WooCommerce - Gravity Forms Product Add-Ons
123
  *
124
  * @return array
125
  */
126
+ function tinv_wishlist_metasupport_wc_gf_addons($meta)
127
+ {
128
+ if (array_key_exists('wc_gforms_form_id', $meta) && class_exists('RGFormsModel')) {
129
+ $form_meta = RGFormsModel::get_form_meta($meta['wc_gforms_form_id']['display']);
130
+ if (array_key_exists('fields', $form_meta)) {
131
  $_meta = array();
132
+ foreach ($form_meta['fields'] as $field) {
133
+ $field_name = $field->get_first_input_id(array('id' => 0));
134
+ if (array_key_exists($field_name, $meta)) {
135
+ $meta[$field_name]['key'] = $field->label;
136
+ $_meta[$field_name] = $meta[$field_name];
137
  }
138
  }
139
  $meta = $_meta;
143
  return $meta;
144
  }
145
 
146
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_wc_gf_addons');
147
  }
integrations/woocommerce-mix-and-match-products.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Mix and Match
@@ -27,10 +49,11 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_pro
27
  *
28
  * @return array
29
  */
30
- function tinv_wishlist_metasupport_woocommerce_mix_and_match_products( $meta, $product_id ) {
31
- if ( array_key_exists( 'mnm_quantity', $meta ) ) {
32
- $product = wc_get_product( $product_id );
33
- if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) ) {
 
34
  $meta = array();
35
  }
36
  }
@@ -38,10 +61,10 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_pro
38
  return $meta;
39
  }
40
 
41
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products', 10, 2 );
42
  } // End if().
43
 
44
- if ( ! function_exists( 'tinvwl_row_woocommerce_mix_and_match_products' ) ) {
45
 
46
  /**
47
  * Add rows for sub product for WooCommerce Mix and Match
@@ -49,67 +72,68 @@ if ( ! function_exists( 'tinvwl_row_woocommerce_mix_and_match_products' ) ) {
49
  * @param array $wl_product Wishlist Product.
50
  * @param \WC_Product $product Woocommerce Product.
51
  */
52
- function tinvwl_row_woocommerce_mix_and_match_products( $wl_product, $product ) {
53
- if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && array_key_exists( 'mnm_quantity', $wl_product['meta'] ) ) {
 
54
  $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
55
- $mnm_items = $product->get_children();
56
- if ( ! empty( $mnm_items ) ) {
57
- foreach ( $mnm_items as $id => $mnm_item ) {
58
  $item_quantity = 0;
59
- if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
60
- $item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
61
  }
62
- if ( 0 >= $item_quantity ) {
63
  continue;
64
  }
65
 
66
- $product_url = $mnm_item->get_permalink();
67
  $product_image = $mnm_item->get_image();
68
- $product_title = is_callable( array(
69
  $mnm_item,
70
  'get_name'
71
- ) ) ? $mnm_item->get_name() : $mnm_item->get_title();
72
  $product_price = $mnm_item->get_price_html();
73
- if ( $mnm_item->is_visible() ) {
74
- $product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
75
- $product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
76
  }
77
- $product_title .= tinv_wishlist_get_item_data( $mnm_item, $wl_product );
78
 
79
- $availability = (array) $mnm_item->get_availability();
80
- if ( ! array_key_exists( 'availability', $availability ) ) {
81
  $availability['availability'] = '';
82
  }
83
- if ( ! array_key_exists( 'class', $availability ) ) {
84
  $availability['class'] = '';
85
  }
86
- $availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
87
- $row_string = '<tr>';
88
- $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
89
- if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
90
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
91
  }
92
- if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
93
  $row_string .= '<td class="product-date">&nbsp;</td>';
94
  }
95
- if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
96
  $row_string .= '<td class="product-stock">%4$s</td>';
97
  }
98
- if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
99
  $row_string .= '<td class="product-action">&nbsp;</td>';
100
  }
101
  $row_string .= '</tr>';
102
 
103
- echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
104
  } // End foreach().
105
  } // End if().
106
  } // End if().
107
  }
108
 
109
- add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_mix_and_match_products', 10, 2 );
110
  } // End if().
111
 
112
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' ) ) {
113
 
114
  /**
115
  * Modify price for WooCommerce Mix and Match
@@ -120,28 +144,29 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' )
120
  *
121
  * @return string
122
  */
123
- function tinvwl_item_price_woocommerce_mix_and_match_products( $price, $wl_product, $product ) {
124
- if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && $product->is_priced_per_product() ) {
 
125
  $mnm_items = $product->get_children();
126
- if ( ! empty( $mnm_items ) ) {
127
  $_price = 0;
128
- foreach ( $mnm_items as $id => $mnm_item ) {
129
  $item_quantity = 0;
130
- if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
131
- $item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
132
  }
133
- if ( 0 >= $item_quantity ) {
134
  continue;
135
  }
136
- $_price += wc_get_price_to_display( $mnm_item, array( 'qty' => $item_quantity ) );
137
  }
138
- if ( 0 < $_price ) {
139
- if ( $product->is_on_sale() ) {
140
- $price = wc_format_sale_price( $_price + wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ), $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
141
  } else {
142
- $price = wc_price( $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
143
  }
144
- $price = apply_filters( 'woocommerce_get_price_html', $price, $product );
145
  }
146
  }
147
  }
@@ -149,10 +174,10 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' )
149
  return $price;
150
  }
151
 
152
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_mix_and_match_products', 10, 3 );
153
  } // End if().
154
 
155
- if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) ) {
156
 
157
  /**
158
  * Remove empty meta for WooCommerce Mix and Match
@@ -161,17 +186,18 @@ if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) )
161
  *
162
  * @return array
163
  */
164
- function tinvwl_add_form_woocommerce_mix_and_match_products( $form = array() ) {
165
- if ( array_key_exists( 'mnm_quantity', $form ) ) {
166
- if ( is_array( $form['mnm_quantity'] ) && ! empty( $form['mnm_quantity'] ) ) {
167
- foreach ( $form['mnm_quantity'] as $key => $value ) {
168
- $value = absint( $value );
169
- if ( empty( $value ) ) {
170
- unset( $form['mnm_quantity'][ $key ] );
 
171
  }
172
  }
173
- if ( empty( $form['mnm_quantity'] ) ) {
174
- unset( $form['mnm_quantity'] );
175
  }
176
  }
177
  }
@@ -179,5 +205,5 @@ if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) )
179
  return $form;
180
  }
181
 
182
- add_filter( 'tinvwl_addtowishlist_add_form', 'tinvwl_add_form_woocommerce_mix_and_match_products' );
183
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-mix-and-match-products";
24
+
25
+ $name = "WooCommerce Mix and Match";
26
+
27
+ $available = class_exists('WC_Mix_and_Match');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_mix_and_match_products')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Mix and Match
49
  *
50
  * @return array
51
  */
52
+ function tinv_wishlist_metasupport_woocommerce_mix_and_match_products($meta, $product_id)
53
+ {
54
+ if (array_key_exists('mnm_quantity', $meta)) {
55
+ $product = wc_get_product($product_id);
56
+ if (is_object($product) && $product->is_type('mix-and-match')) {
57
  $meta = array();
58
  }
59
  }
61
  return $meta;
62
  }
63
 
64
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products', 10, 2);
65
  } // End if().
66
 
67
+ if (!function_exists('tinvwl_row_woocommerce_mix_and_match_products')) {
68
 
69
  /**
70
  * Add rows for sub product for WooCommerce Mix and Match
72
  * @param array $wl_product Wishlist Product.
73
  * @param \WC_Product $product Woocommerce Product.
74
  */
75
+ function tinvwl_row_woocommerce_mix_and_match_products($wl_product, $product)
76
+ {
77
+ if (is_object($product) && $product->is_type('mix-and-match') && array_key_exists('mnm_quantity', $wl_product['meta'])) {
78
  $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
79
+ $mnm_items = $product->get_children();
80
+ if (!empty($mnm_items)) {
81
+ foreach ($mnm_items as $id => $mnm_item) {
82
  $item_quantity = 0;
83
+ if (array_key_exists($id, $wl_product['meta']['mnm_quantity'])) {
84
+ $item_quantity = absint($wl_product['meta']['mnm_quantity'][$id]);
85
  }
86
+ if (0 >= $item_quantity) {
87
  continue;
88
  }
89
 
90
+ $product_url = $mnm_item->get_permalink();
91
  $product_image = $mnm_item->get_image();
92
+ $product_title = is_callable(array(
93
  $mnm_item,
94
  'get_name'
95
+ )) ? $mnm_item->get_name() : $mnm_item->get_title();
96
  $product_price = $mnm_item->get_price_html();
97
+ if ($mnm_item->is_visible()) {
98
+ $product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
99
+ $product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
100
  }
101
+ $product_title .= tinv_wishlist_get_item_data($mnm_item, $wl_product);
102
 
103
+ $availability = (array)$mnm_item->get_availability();
104
+ if (!array_key_exists('availability', $availability)) {
105
  $availability['availability'] = '';
106
  }
107
+ if (!array_key_exists('class', $availability)) {
108
  $availability['class'] = '';
109
  }
110
+ $availability_html = empty($availability['availability']) ? '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__('In stock', 'ti-woocommerce-wishlist') . '</span></p>' : '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html($availability['availability']) . '</span></p>';
111
+ $row_string = '<tr>';
112
+ $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
113
+ if (tinv_get_option('product_table', 'colm_price')) {
114
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
115
  }
116
+ if (tinv_get_option('product_table', 'colm_date')) {
117
  $row_string .= '<td class="product-date">&nbsp;</td>';
118
  }
119
+ if (tinv_get_option('product_table', 'colm_stock')) {
120
  $row_string .= '<td class="product-stock">%4$s</td>';
121
  }
122
+ if (tinv_get_option('product_table', 'add_to_cart')) {
123
  $row_string .= '<td class="product-action">&nbsp;</td>';
124
  }
125
  $row_string .= '</tr>';
126
 
127
+ echo sprintf($row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity); // WPCS: xss ok.
128
  } // End foreach().
129
  } // End if().
130
  } // End if().
131
  }
132
 
133
+ add_action('tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_mix_and_match_products', 10, 2);
134
  } // End if().
135
 
136
+ if (!function_exists('tinvwl_item_price_woocommerce_mix_and_match_products')) {
137
 
138
  /**
139
  * Modify price for WooCommerce Mix and Match
144
  *
145
  * @return string
146
  */
147
+ function tinvwl_item_price_woocommerce_mix_and_match_products($price, $wl_product, $product)
148
+ {
149
+ if (is_object($product) && $product->is_type('mix-and-match') && $product->is_priced_per_product()) {
150
  $mnm_items = $product->get_children();
151
+ if (!empty($mnm_items)) {
152
  $_price = 0;
153
+ foreach ($mnm_items as $id => $mnm_item) {
154
  $item_quantity = 0;
155
+ if (array_key_exists($id, $wl_product['meta']['mnm_quantity'])) {
156
+ $item_quantity = absint($wl_product['meta']['mnm_quantity'][$id]);
157
  }
158
+ if (0 >= $item_quantity) {
159
  continue;
160
  }
161
+ $_price += wc_get_price_to_display($mnm_item, array('qty' => $item_quantity));
162
  }
163
+ if (0 < $_price) {
164
+ if ($product->is_on_sale()) {
165
+ $price = wc_format_sale_price($_price + wc_get_price_to_display($product, array('price' => $product->get_regular_price())), $_price + wc_get_price_to_display($product)) . $product->get_price_suffix();
166
  } else {
167
+ $price = wc_price($_price + wc_get_price_to_display($product)) . $product->get_price_suffix();
168
  }
169
+ $price = apply_filters('woocommerce_get_price_html', $price, $product);
170
  }
171
  }
172
  }
174
  return $price;
175
  }
176
 
177
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_mix_and_match_products', 10, 3);
178
  } // End if().
179
 
180
+ if (!function_exists('tinvwl_add_form_woocommerce_mix_and_match_products')) {
181
 
182
  /**
183
  * Remove empty meta for WooCommerce Mix and Match
186
  *
187
  * @return array
188
  */
189
+ function tinvwl_add_form_woocommerce_mix_and_match_products($form = array())
190
+ {
191
+ if (array_key_exists('mnm_quantity', $form)) {
192
+ if (is_array($form['mnm_quantity']) && !empty($form['mnm_quantity'])) {
193
+ foreach ($form['mnm_quantity'] as $key => $value) {
194
+ $value = absint($value);
195
+ if (empty($value)) {
196
+ unset($form['mnm_quantity'][$key]);
197
  }
198
  }
199
+ if (empty($form['mnm_quantity'])) {
200
+ unset($form['mnm_quantity']);
201
  }
202
  }
203
  }
205
  return $form;
206
  }
207
 
208
+ add_filter('tinvwl_addtowishlist_add_form', 'tinvwl_add_form_woocommerce_mix_and_match_products');
209
  } // End if().
integrations/woocommerce-multilingual.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Change product data if product need translate in WooCommerce Multilingual
@@ -26,38 +48,39 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare' ) ) {
26
  *
27
  * @return array
28
  */
29
- function tinvwl_wpml_addtowishlist_prepare( $post_data ) {
30
- if ( class_exists( 'woocommerce_wpml' ) ) {
 
31
 
32
  global $woocommerce_wpml, $sitepress, $wpdb;
33
 
34
  // Reload products class.
35
- if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
36
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
37
  } else {
38
  global $wpml_post_translations;
39
- if ( ! ( $woocommerce_wpml instanceof woocommerce_wpml ) || ! ( $sitepress instanceof SitePress ) || ! ( $wpml_post_translations instanceof WPML_Post_Translation ) ) {
40
  return $post_data;
41
  }
42
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
43
  }
44
 
45
- if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) ) {
46
- $post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id( $post_data['product_id'] );
47
  }
48
- if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) && array_key_exists( 'product_variation', $post_data ) && ! empty( $post_data['product_variation'] ) ) {
49
- $original_product_language = $woocommerce_wpml->products->get_original_product_language( $post_data['product_id'] );
50
- $post_data['product_variation'] = apply_filters( 'translate_object_id', $post_data['product_variation'], 'product_variation', true, $original_product_language );
51
  }
52
  }
53
 
54
  return $post_data;
55
  }
56
 
57
- add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_wpml_addtowishlist_prepare' );
58
  }
59
 
60
- if ( ! function_exists( 'tinvwl_wpml_addtowishlist_check_product' ) ) {
61
 
62
  /**
63
  * Change product data if product need translate in WooCommerce Multilingual
@@ -66,24 +89,25 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_check_product' ) ) {
66
  *
67
  * @return object $product WC_Product object
68
  */
69
- function tinvwl_wpml_addtowishlist_check_product( $product ) {
70
- if ( class_exists( 'woocommerce_wpml' ) ) {
 
71
 
72
  global $woocommerce_wpml, $sitepress, $wpdb;
73
 
74
  // Reload products class.
75
- if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
76
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
77
  } else {
78
  global $wpml_post_translations;
79
- if ( ! ( $woocommerce_wpml instanceof woocommerce_wpml ) || ! ( $sitepress instanceof SitePress ) || ! ( $wpml_post_translations instanceof WPML_Post_Translation ) ) {
80
  return $product;
81
  }
82
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
83
  }
84
 
85
- if ( $product ) {
86
- $product = wc_get_product( $woocommerce_wpml->products->get_original_product_id( $product->get_id() ) );
87
  }
88
 
89
  }
@@ -91,11 +115,11 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_check_product' ) ) {
91
  return $product;
92
  }
93
 
94
- add_filter( 'tinvwl_addtowishlist_check_product', 'tinvwl_wpml_addtowishlist_check_product' );
95
  }
96
 
97
 
98
- if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare' ) ) {
99
 
100
  /**
101
  * Change product data if product need translate in WooCommerce Multilingual
@@ -104,39 +128,40 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare' ) ) {
104
  *
105
  * @return array
106
  */
107
- function tinvwl_wpml_addtowishlist_out_prepare( $attr ) {
108
- if ( class_exists( 'woocommerce_wpml' ) ) {
 
109
 
110
  global $woocommerce_wpml, $sitepress, $wpdb;
111
 
112
  // Reload products class.
113
- if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
114
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
115
  } else {
116
  global $wpml_post_translations;
117
- if ( ! ( $woocommerce_wpml instanceof woocommerce_wpml ) || ! ( $sitepress instanceof SitePress ) || ! ( $wpml_post_translations instanceof WPML_Post_Translation ) ) {
118
  return $attr;
119
  }
120
 
121
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
122
  }
123
 
124
- if ( array_key_exists( 'product_id', $attr ) && ! empty( $attr['product_id'] ) ) {
125
- $attr['product_id'] = $woocommerce_wpml->products->get_original_product_id( $attr['product_id'] );
126
  }
127
- if ( array_key_exists( 'product_id', $attr ) && ! empty( $attr['product_id'] ) && array_key_exists( 'variation_id', $attr ) && ! empty( $attr['variation_id'] ) ) {
128
- $original_product_language = $woocommerce_wpml->products->get_original_product_language( $attr['product_id'] );
129
- $attr['variation_id'] = apply_filters( 'translate_object_id', $attr['variation_id'], 'product_variation', true, $original_product_language );
130
  }
131
  }
132
 
133
  return $attr;
134
  }
135
 
136
- add_filter( 'tinvwl_addtowishlist_out_prepare_attr', 'tinvwl_wpml_addtowishlist_out_prepare' );
137
  }
138
 
139
- if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare_product' ) ) {
140
 
141
  /**
142
  * Change product if product need translate in WooCommerce Multilingual
@@ -145,44 +170,45 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare_product' ) ) {
145
  *
146
  * @return \WC_Product
147
  */
148
- function tinvwl_wpml_addtowishlist_out_prepare_product( $product ) {
149
- if ( class_exists( 'woocommerce_wpml' ) && is_object( $product ) ) {
 
150
 
151
  global $woocommerce_wpml, $sitepress, $wpdb;
152
 
153
  // Reload products class.
154
- if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
155
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
156
  } else {
157
  global $wpml_post_translations;
158
- if ( ! ( $woocommerce_wpml instanceof woocommerce_wpml ) || ! ( $sitepress instanceof SitePress ) || ! ( $wpml_post_translations instanceof WPML_Post_Translation ) ) {
159
  return $product;
160
  }
161
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
162
  }
163
 
164
- $product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
165
- $variation_id = $product->is_type( 'variation' ) ? $product->get_id() : 0;
166
 
167
- if ( ! empty( $product_id ) ) {
168
- $product_id = $woocommerce_wpml->products->get_original_product_id( $product_id );
169
  }
170
- if ( ! empty( $product_id ) && ! empty( $variation_id ) ) {
171
- $original_product_language = $woocommerce_wpml->products->get_original_product_language( $product_id );
172
- $variation_id = apply_filters( 'translate_object_id', $variation_id, 'product_variation', true, $original_product_language );
173
  }
174
- if ( ! empty( $product_id ) ) {
175
- $product = wc_get_product( $variation_id ? $variation_id : $product_id );
176
  }
177
  }
178
 
179
  return $product;
180
  }
181
 
182
- add_filter( 'tinvwl_addtowishlist_out_prepare_product', 'tinvwl_wpml_addtowishlist_out_prepare_product' );
183
  }
184
 
185
- if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare_form' ) ) {
186
 
187
  /**
188
  * Change product form data if product need translate in WooCommerce Multilingual
@@ -191,33 +217,34 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare_form' ) ) {
191
  *
192
  * @return array
193
  */
194
- function tinvwl_wpml_addtowishlist_prepare_form( $post_data ) {
195
- if ( class_exists( 'woocommerce_wpml' ) && is_array( $post_data ) ) {
 
196
 
197
  global $woocommerce_wpml, $sitepress, $wpdb;
198
 
199
  // Reload products class.
200
- if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
201
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
202
  } else {
203
  global $wpml_post_translations;
204
- if ( ! ( $woocommerce_wpml instanceof woocommerce_wpml ) || ! ( $sitepress instanceof SitePress ) || ! ( $wpml_post_translations instanceof WPML_Post_Translation ) ) {
205
  return $post_data;
206
  }
207
- $woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
208
  }
209
 
210
- if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) ) {
211
- $post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id( $post_data['product_id'] );
212
  }
213
- if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) && array_key_exists( 'variation_id', $post_data ) && ! empty( $post_data['variation_id'] ) ) {
214
- $original_product_language = $woocommerce_wpml->products->get_original_product_language( $post_data['product_id'] );
215
- $post_data['variation_id'] = apply_filters( 'translate_object_id', $post_data['variation_id'], 'product_variation', true, $original_product_language );
216
  }
217
  }
218
 
219
  return $post_data;
220
  }
221
 
222
- add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_wpml_addtowishlist_prepare_form' );
223
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-multilingual";
24
+
25
+ $name = "WooCommerce Multilingual";
26
+
27
+ $available = class_exists('woocommerce_wpml');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_wpml_addtowishlist_prepare')) {
43
 
44
  /**
45
  * Change product data if product need translate in WooCommerce Multilingual
48
  *
49
  * @return array
50
  */
51
+ function tinvwl_wpml_addtowishlist_prepare($post_data)
52
+ {
53
+ if (class_exists('woocommerce_wpml')) {
54
 
55
  global $woocommerce_wpml, $sitepress, $wpdb;
56
 
57
  // Reload products class.
58
+ if (version_compare(WCML_VERSION, '4.4.0', '<')) {
59
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpdb);
60
  } else {
61
  global $wpml_post_translations;
62
+ if (!($woocommerce_wpml instanceof woocommerce_wpml) || !($sitepress instanceof SitePress) || !($wpml_post_translations instanceof WPML_Post_Translation)) {
63
  return $post_data;
64
  }
65
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb);
66
  }
67
 
68
+ if (array_key_exists('product_id', $post_data) && !empty($post_data['product_id'])) {
69
+ $post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id($post_data['product_id']);
70
  }
71
+ if (array_key_exists('product_id', $post_data) && !empty($post_data['product_id']) && array_key_exists('product_variation', $post_data) && !empty($post_data['product_variation'])) {
72
+ $original_product_language = $woocommerce_wpml->products->get_original_product_language($post_data['product_id']);
73
+ $post_data['product_variation'] = apply_filters('translate_object_id', $post_data['product_variation'], 'product_variation', true, $original_product_language);
74
  }
75
  }
76
 
77
  return $post_data;
78
  }
79
 
80
+ add_filter('tinvwl_addtowishlist_prepare', 'tinvwl_wpml_addtowishlist_prepare');
81
  }
82
 
83
+ if (!function_exists('tinvwl_wpml_addtowishlist_check_product')) {
84
 
85
  /**
86
  * Change product data if product need translate in WooCommerce Multilingual
89
  *
90
  * @return object $product WC_Product object
91
  */
92
+ function tinvwl_wpml_addtowishlist_check_product($product)
93
+ {
94
+ if (class_exists('woocommerce_wpml')) {
95
 
96
  global $woocommerce_wpml, $sitepress, $wpdb;
97
 
98
  // Reload products class.
99
+ if (version_compare(WCML_VERSION, '4.4.0', '<')) {
100
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpdb);
101
  } else {
102
  global $wpml_post_translations;
103
+ if (!($woocommerce_wpml instanceof woocommerce_wpml) || !($sitepress instanceof SitePress) || !($wpml_post_translations instanceof WPML_Post_Translation)) {
104
  return $product;
105
  }
106
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb);
107
  }
108
 
109
+ if ($product) {
110
+ $product = wc_get_product($woocommerce_wpml->products->get_original_product_id($product->get_id()));
111
  }
112
 
113
  }
115
  return $product;
116
  }
117
 
118
+ add_filter('tinvwl_addtowishlist_check_product', 'tinvwl_wpml_addtowishlist_check_product');
119
  }
120
 
121
 
122
+ if (!function_exists('tinvwl_wpml_addtowishlist_out_prepare')) {
123
 
124
  /**
125
  * Change product data if product need translate in WooCommerce Multilingual
128
  *
129
  * @return array
130
  */
131
+ function tinvwl_wpml_addtowishlist_out_prepare($attr)
132
+ {
133
+ if (class_exists('woocommerce_wpml')) {
134
 
135
  global $woocommerce_wpml, $sitepress, $wpdb;
136
 
137
  // Reload products class.
138
+ if (version_compare(WCML_VERSION, '4.4.0', '<')) {
139
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpdb);
140
  } else {
141
  global $wpml_post_translations;
142
+ if (!($woocommerce_wpml instanceof woocommerce_wpml) || !($sitepress instanceof SitePress) || !($wpml_post_translations instanceof WPML_Post_Translation)) {
143
  return $attr;
144
  }
145
 
146
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb);
147
  }
148
 
149
+ if (array_key_exists('product_id', $attr) && !empty($attr['product_id'])) {
150
+ $attr['product_id'] = $woocommerce_wpml->products->get_original_product_id($attr['product_id']);
151
  }
152
+ if (array_key_exists('product_id', $attr) && !empty($attr['product_id']) && array_key_exists('variation_id', $attr) && !empty($attr['variation_id'])) {
153
+ $original_product_language = $woocommerce_wpml->products->get_original_product_language($attr['product_id']);
154
+ $attr['variation_id'] = apply_filters('translate_object_id', $attr['variation_id'], 'product_variation', true, $original_product_language);
155
  }
156
  }
157
 
158
  return $attr;
159
  }
160
 
161
+ add_filter('tinvwl_addtowishlist_out_prepare_attr', 'tinvwl_wpml_addtowishlist_out_prepare');
162
  }
163
 
164
+ if (!function_exists('tinvwl_wpml_addtowishlist_out_prepare_product')) {
165
 
166
  /**
167
  * Change product if product need translate in WooCommerce Multilingual
170
  *
171
  * @return \WC_Product
172
  */
173
+ function tinvwl_wpml_addtowishlist_out_prepare_product($product)
174
+ {
175
+ if (class_exists('woocommerce_wpml') && is_object($product)) {
176
 
177
  global $woocommerce_wpml, $sitepress, $wpdb;
178
 
179
  // Reload products class.
180
+ if (version_compare(WCML_VERSION, '4.4.0', '<')) {
181
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpdb);
182
  } else {
183
  global $wpml_post_translations;
184
+ if (!($woocommerce_wpml instanceof woocommerce_wpml) || !($sitepress instanceof SitePress) || !($wpml_post_translations instanceof WPML_Post_Translation)) {
185
  return $product;
186
  }
187
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb);
188
  }
189
 
190
+ $product_id = $product->is_type('variation') ? $product->get_parent_id() : $product->get_id();
191
+ $variation_id = $product->is_type('variation') ? $product->get_id() : 0;
192
 
193
+ if (!empty($product_id)) {
194
+ $product_id = $woocommerce_wpml->products->get_original_product_id($product_id);
195
  }
196
+ if (!empty($product_id) && !empty($variation_id)) {
197
+ $original_product_language = $woocommerce_wpml->products->get_original_product_language($product_id);
198
+ $variation_id = apply_filters('translate_object_id', $variation_id, 'product_variation', true, $original_product_language);
199
  }
200
+ if (!empty($product_id)) {
201
+ $product = wc_get_product($variation_id ? $variation_id : $product_id);
202
  }
203
  }
204
 
205
  return $product;
206
  }
207
 
208
+ add_filter('tinvwl_addtowishlist_out_prepare_product', 'tinvwl_wpml_addtowishlist_out_prepare_product');
209
  }
210
 
211
+ if (!function_exists('tinvwl_wpml_addtowishlist_prepare_form')) {
212
 
213
  /**
214
  * Change product form data if product need translate in WooCommerce Multilingual
217
  *
218
  * @return array
219
  */
220
+ function tinvwl_wpml_addtowishlist_prepare_form($post_data)
221
+ {
222
+ if (class_exists('woocommerce_wpml') && is_array($post_data)) {
223
 
224
  global $woocommerce_wpml, $sitepress, $wpdb;
225
 
226
  // Reload products class.
227
+ if (version_compare(WCML_VERSION, '4.4.0', '<')) {
228
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpdb);
229
  } else {
230
  global $wpml_post_translations;
231
+ if (!($woocommerce_wpml instanceof woocommerce_wpml) || !($sitepress instanceof SitePress) || !($wpml_post_translations instanceof WPML_Post_Translation)) {
232
  return $post_data;
233
  }
234
+ $woocommerce_wpml->products = new WCML_Products($woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb);
235
  }
236
 
237
+ if (array_key_exists('product_id', $post_data) && !empty($post_data['product_id'])) {
238
+ $post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id($post_data['product_id']);
239
  }
240
+ if (array_key_exists('product_id', $post_data) && !empty($post_data['product_id']) && array_key_exists('variation_id', $post_data) && !empty($post_data['variation_id'])) {
241
+ $original_product_language = $woocommerce_wpml->products->get_original_product_language($post_data['product_id']);
242
+ $post_data['variation_id'] = apply_filters('translate_object_id', $post_data['variation_id'], 'product_variation', true, $original_product_language);
243
  }
244
  }
245
 
246
  return $post_data;
247
  }
248
 
249
+ add_filter('tinvwl_addtowishlist_prepare_form', 'tinvwl_wpml_addtowishlist_prepare_form');
250
  }
integrations/woocommerce-product-addon.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined('ABSPATH')) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists('tinv_wishlist_metasupport_woocommerce_product_add_on')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Product Add-on
@@ -39,7 +61,7 @@ if ( ! function_exists('tinv_wishlist_metasupport_woocommerce_product_add_on'))
39
  add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_add_on', 10, 2);
40
  } // End if().
41
 
42
- if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Product Add-on
@@ -54,7 +76,7 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
54
  {
55
  if (isset($wl_product['meta']) && isset($wl_product['meta']['ppom']) && class_exists('NM_PersonalizedProduct')) {
56
 
57
- $ppom = json_decode($wl_product['meta']['ppom']);
58
  $product_meta = $ppom->fields ? $ppom->fields : '';
59
 
60
  $item_meta = array();
@@ -74,7 +96,7 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
74
  continue;
75
  }
76
 
77
- $field_type = $field_meta['type'];
78
  $field_title = $field_meta['title'];
79
 
80
 
@@ -82,12 +104,12 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
82
  case 'quantities':
83
  $total_qty = 0;
84
  foreach ($value as $label => $qty) {
85
- if ( ! empty($qty)) {
86
  $item_meta[] = array(
87
- 'key' => $label,
88
  'display' => $qty,
89
  );
90
- $total_qty += $qty;
91
  }
92
  }
93
  break;
@@ -95,11 +117,11 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
95
  case 'file':
96
  $file_thumbs_html = '';
97
  foreach ($value as $file_id => $file_uploaded) {
98
- $file_name = $file_uploaded['org'];
99
  $file_thumbs_html .= ppom_show_file_thumb($file_name);
100
  }
101
  $item_meta[] = array(
102
- 'key' => $field_title,
103
  'display' => $file_thumbs_html,
104
  );
105
 
@@ -109,11 +131,11 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
109
  $file_thumbs_html = '';
110
  foreach ($value as $file_id => $file_cropped) {
111
 
112
- $file_name = $file_cropped['org'];
113
  $file_thumbs_html .= ppom_show_file_thumb($file_name, true);
114
  }
115
  $item_meta[] = array(
116
- 'key' => $field_title,
117
  'display' => $file_thumbs_html,
118
  );
119
  break;
@@ -122,11 +144,11 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
122
  if ($value) {
123
  foreach ($value as $id => $images_meta) {
124
  $images_meta = json_decode(stripslashes($images_meta), true);
125
- $image_url = stripslashes($images_meta['link']);
126
- $image_html = '<img class="img-thumbnail" style="width:' . esc_attr(ppom_get_thumbs_size()) . '" src="' . esc_url($image_url) . '" title="' . esc_attr($images_meta['title']) . '">';
127
- $meta_key = $field_title . '(' . $images_meta['title'] . ')';
128
  $item_meta[] = array(
129
- 'key' => $meta_key,
130
  'display' => $image_html,
131
  );
132
  }
@@ -137,12 +159,12 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
137
  if ($value) {
138
  $ppom_file_count = 1;
139
  foreach ($value as $id => $audio_meta) {
140
- $audio_meta = json_decode(stripslashes($audio_meta), true);
141
- $audio_url = stripslashes($audio_meta['link']);
142
- $audio_html = '<a href="' . esc_url($audio_url) . '" title="' . esc_attr($audio_meta['title']) . '">' . $audio_meta['title'] . '</a>';
143
- $meta_key = $field_title . ': ' . $ppom_file_count++;
144
  $item_meta[] = array(
145
- 'key' => $meta_key,
146
  'display' => $audio_html,
147
  );
148
  }
@@ -151,15 +173,15 @@ if ( ! function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
151
 
152
  case 'bulkquantity':
153
  $item_meta[] = array(
154
- 'key' => $key,
155
  'display' => $value['option'] . ' (' . $value['qty'] . ')',
156
  );
157
  break;
158
 
159
  default:
160
- $value = is_object($value) ? implode(",", (array)$value) : $value;
161
  $item_meta[] = array(
162
- 'key' => $field_title,
163
  'display' => stripcslashes($value),
164
  );
165
  break;
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-product-addon";
24
+
25
+ $name = "PPOM for WooCommerce";
26
+
27
+ $available = defined('PPOM_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_product_add_on')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Product Add-on
61
  add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_add_on', 10, 2);
62
  } // End if().
63
 
64
+ if (!function_exists('tinv_wishlist_item_meta_woocommerce_product_add_on')) {
65
 
66
  /**
67
  * Set description for meta WooCommerce Product Add-on
76
  {
77
  if (isset($wl_product['meta']) && isset($wl_product['meta']['ppom']) && class_exists('NM_PersonalizedProduct')) {
78
 
79
+ $ppom = json_decode($wl_product['meta']['ppom']);
80
  $product_meta = $ppom->fields ? $ppom->fields : '';
81
 
82
  $item_meta = array();
96
  continue;
97
  }
98
 
99
+ $field_type = $field_meta['type'];
100
  $field_title = $field_meta['title'];
101
 
102
 
104
  case 'quantities':
105
  $total_qty = 0;
106
  foreach ($value as $label => $qty) {
107
+ if (!empty($qty)) {
108
  $item_meta[] = array(
109
+ 'key' => $label,
110
  'display' => $qty,
111
  );
112
+ $total_qty += $qty;
113
  }
114
  }
115
  break;
117
  case 'file':
118
  $file_thumbs_html = '';
119
  foreach ($value as $file_id => $file_uploaded) {
120
+ $file_name = $file_uploaded['org'];
121
  $file_thumbs_html .= ppom_show_file_thumb($file_name);
122
  }
123
  $item_meta[] = array(
124
+ 'key' => $field_title,
125
  'display' => $file_thumbs_html,
126
  );
127
 
131
  $file_thumbs_html = '';
132
  foreach ($value as $file_id => $file_cropped) {
133
 
134
+ $file_name = $file_cropped['org'];
135
  $file_thumbs_html .= ppom_show_file_thumb($file_name, true);
136
  }
137
  $item_meta[] = array(
138
+ 'key' => $field_title,
139
  'display' => $file_thumbs_html,
140
  );
141
  break;
144
  if ($value) {
145
  foreach ($value as $id => $images_meta) {
146
  $images_meta = json_decode(stripslashes($images_meta), true);
147
+ $image_url = stripslashes($images_meta['link']);
148
+ $image_html = '<img class="img-thumbnail" style="width:' . esc_attr(ppom_get_thumbs_size()) . '" src="' . esc_url($image_url) . '" title="' . esc_attr($images_meta['title']) . '">';
149
+ $meta_key = $field_title . '(' . $images_meta['title'] . ')';
150
  $item_meta[] = array(
151
+ 'key' => $meta_key,
152
  'display' => $image_html,
153
  );
154
  }
159
  if ($value) {
160
  $ppom_file_count = 1;
161
  foreach ($value as $id => $audio_meta) {
162
+ $audio_meta = json_decode(stripslashes($audio_meta), true);
163
+ $audio_url = stripslashes($audio_meta['link']);
164
+ $audio_html = '<a href="' . esc_url($audio_url) . '" title="' . esc_attr($audio_meta['title']) . '">' . $audio_meta['title'] . '</a>';
165
+ $meta_key = $field_title . ': ' . $ppom_file_count++;
166
  $item_meta[] = array(
167
+ 'key' => $meta_key,
168
  'display' => $audio_html,
169
  );
170
  }
173
 
174
  case 'bulkquantity':
175
  $item_meta[] = array(
176
+ 'key' => $key,
177
  'display' => $value['option'] . ' (' . $value['qty'] . ')',
178
  );
179
  break;
180
 
181
  default:
182
+ $value = is_object($value) ? implode(",", (array)$value) : $value;
183
  $item_meta[] = array(
184
+ 'key' => $field_title,
185
  'display' => stripcslashes($value),
186
  );
187
  break;
integrations/woocommerce-product-addons.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Product Addons
@@ -28,55 +50,56 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
28
  *
29
  * @return array
30
  */
31
- function tinv_wishlist_item_meta_woocommerce_product_addons( $item_data, $product_id, $variation_id ) {
 
32
 
33
- if ( class_exists( 'WC_Product_Addons' ) ) {
34
 
35
- $id = ( $variation_id ) ? $variation_id : $product_id;
36
 
37
- if ( function_exists( 'get_product_addons' ) ) {
38
- $product_addons = get_product_addons( $id );
39
  } else {
40
- $product_addons = WC_Product_Addons_Helper::get_product_addons( $id );
41
  }
42
 
43
- if ( $product_addons ) {
44
 
45
  $field = null;
46
 
47
- foreach ( $product_addons as $addon ) {
48
- foreach ( $addon['options'] as $option ) {
49
  $original_data = 'addon-' . $addon['field_name'];
50
 
51
- $value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ]['display'] : '';
52
 
53
- if ( $value == '' ) {
54
  continue;
55
  }
56
 
57
- if ( is_array( $value ) ) {
58
- $value = array_map( 'stripslashes', $value );
59
  } else {
60
- $value = stripslashes( $value );
61
  }
62
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
63
- switch ( $addon['type'] ) {
64
  case 'checkbox':
65
- $value = json_decode( $value, true );
66
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
67
- $field = new WC_Product_Addons_Field_List( $addon, $value );
68
  break;
69
  case 'multiple_choice':
70
- switch ( $addon['display'] ) {
71
  case 'radiobutton':
72
- $value = json_decode( $value, true );
73
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
74
- $field = new WC_Product_Addons_Field_List( $addon, $value );
75
  break;
76
  case 'images':
77
  case 'select':
78
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php' );
79
- $field = new WC_Product_Addons_Field_Select( $addon, $value );
80
  break;
81
  }
82
  break;
@@ -84,14 +107,14 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
84
  case 'custom_textarea':
85
  case 'custom_price':
86
  case 'input_multiplier':
87
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php' );
88
- $field = new WC_Product_Addons_Field_Custom( $addon, $value );
89
  break;
90
  case 'file_upload':
91
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
92
- $field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
93
- if ( $field && isset( $field->value ) ) {
94
- $field->value = basename( $field->value );
95
  }
96
  break;
97
  default:
@@ -99,18 +122,18 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
99
  break;
100
  }
101
 
102
- if ( $field ) {
103
  $data = $field->get_cart_item_data();
104
- unset( $item_data[ $original_data ] );
105
- foreach ( $data as $opt ) {
106
  $name = $opt['name'];
107
 
108
- if ( $opt['price'] && apply_filters( 'woocommerce_addons_add_price_to_name', '__return_true' ) ) {
109
- $name .= ' (' . wc_price( WC_Product_Addons_Helper::get_product_addon_price_for_display( $opt['price'] ) ) . ')';
110
  }
111
 
112
  $item_data[] = array(
113
- 'key' => $name,
114
  'display' => $opt['value'],
115
  );
116
  }
@@ -123,10 +146,10 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
123
  return $item_data;
124
  }
125
 
126
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_product_addons', 10, 3 );
127
  } // End if().
128
 
129
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
130
 
131
  /**
132
  * Modify price for WooCommerce Product Addons.
@@ -137,53 +160,54 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
137
  *
138
  * @return string
139
  */
140
- function tinvwl_item_price_woocommerce_product_addons( $price, $wl_product, $product ) {
 
141
 
142
- if ( class_exists( 'WC_Product_Addons' ) ) {
143
 
144
- if ( function_exists( 'get_product_addons' ) ) {
145
- $product_addons = get_product_addons( $product->get_id() );
146
  } else {
147
- $product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
148
  }
149
 
150
- if ( $product_addons ) {
151
 
152
  $price = 0;
153
  $field = null;
154
 
155
- foreach ( $product_addons as $addon ) {
156
 
157
  $original_data = 'addon-' . $addon['field_name'];
158
 
159
- $value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
160
- if ( $value == '' ) {
161
  continue;
162
  }
163
 
164
- if ( is_array( $value ) ) {
165
- $value = array_map( 'stripslashes', $value );
166
  } else {
167
- $value = stripslashes( $value );
168
  }
169
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
170
- switch ( $addon['type'] ) {
171
  case 'checkbox':
172
- $value = json_decode( $value, true );
173
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
174
- $field = new WC_Product_Addons_Field_List( $addon, $value );
175
  break;
176
  case 'multiple_choice':
177
- switch ( $addon['display'] ) {
178
  case 'radiobutton':
179
- $value = json_decode( $value, true );
180
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
181
- $field = new WC_Product_Addons_Field_List( $addon, $value );
182
  break;
183
  case 'images':
184
  case 'select':
185
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php' );
186
- $field = new WC_Product_Addons_Field_Select( $addon, $value );
187
  break;
188
  }
189
  break;
@@ -191,53 +215,54 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
191
  case 'custom_textarea':
192
  case 'custom_price':
193
  case 'input_multiplier':
194
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php' );
195
- $field = new WC_Product_Addons_Field_Custom( $addon, $value );
196
  break;
197
  case 'file_upload':
198
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
199
- $field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
200
  break;
201
  default:
202
  // Continue to the next field in case the type is not recognized (instead of causing a fatal error)
203
  break;
204
  }
205
 
206
- if ( $field ) {
207
  $data = $field->get_cart_item_data();
208
- foreach ( $data as $option ) {
209
- if ( $option['price'] ) {
210
- $price += (float) $option['price'];
211
  }
212
  }
213
  }
214
 
215
  }
216
 
217
- $price = wc_price( (float) $product->get_price() + (float) $price );
218
  }
219
  }
220
 
221
  return $price;
222
  }
223
 
224
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_addons', 10, 3 );
225
  } // End if().
226
 
227
- add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_product_addons', 10, 3 );
228
 
229
- function tinvwl_meta_woocommerce_product_addons( $meta, $post, $files ) {
 
230
 
231
- if ( class_exists( 'WC_Product_Addons' ) && ! empty( $files ) ) {
232
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
233
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
234
- $field = new WC_Product_Addons_Field_File_Upload( array() );
235
- foreach ( $files as $name => $file ) {
236
 
237
- if ( array_key_exists( $name, $meta ) ) {
238
- $upload = $field->handle_upload( $file );
239
- if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
240
- $meta[ $name ] = wc_clean( $upload['url'] );
241
  }
242
  }
243
  }
@@ -246,23 +271,24 @@ function tinvwl_meta_woocommerce_product_addons( $meta, $post, $files ) {
246
  return $meta;
247
  }
248
 
249
- add_filter( 'tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_product_addons' );
250
 
251
- function tinvwl_cart_meta_woocommerce_product_addons( $meta ) {
 
252
 
253
- if ( class_exists( 'WC_Product_Addons' ) && ! empty( $files ) ) {
254
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
255
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
256
- $field = new WC_Product_Addons_Field_File_Upload( array() );
257
 
258
  $files = $_FILES;
259
 
260
- foreach ( $files as $name => $file ) {
261
 
262
- if ( ! array_key_exists( $name, $meta ) ) {
263
- $upload = $field->handle_upload( $file );
264
- if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
265
- $meta[ $name ] = wc_clean( $upload['url'] );
266
  }
267
  }
268
  }
@@ -272,50 +298,51 @@ function tinvwl_cart_meta_woocommerce_product_addons( $meta ) {
272
  }
273
 
274
 
275
- add_filter( 'tinvwl_addproduct_tocart', 'tinvwl_add_to_cart_meta_woocommerce_product_addons' );
276
 
277
- function tinvwl_add_to_cart_meta_woocommerce_product_addons( $wl_product ) {
278
- if ( class_exists( 'WC_Product_Addons' ) ) {
 
279
 
280
- $id = ( $wl_product['variation_id'] ) ? $wl_product['variation_id'] : $wl_product['product_id'];
281
 
282
- if ( function_exists( 'get_product_addons' ) ) {
283
- $product_addons = get_product_addons( $id );
284
  } else {
285
- $product_addons = WC_Product_Addons_Helper::get_product_addons( $id );
286
  }
287
 
288
- if ( $product_addons ) {
289
 
290
  $field = null;
291
 
292
- foreach ( $product_addons as $addon ) {
293
- foreach ( $addon['options'] as $option ) {
294
  $original_data = 'addon-' . $addon['field_name'];
295
 
296
- $value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
297
 
298
- if ( $value == '' ) {
299
  continue;
300
  }
301
 
302
- if ( is_array( $value ) ) {
303
- $value = array_map( 'stripslashes', $value );
304
  } else {
305
- $value = stripslashes( $value );
306
  }
307
- include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
308
- switch ( $addon['type'] ) {
309
  case 'checkbox':
310
- if ( ! is_array( $value ) ) {
311
- $wl_product['meta'][ $original_data ] = json_decode( $value, true );
312
  }
313
  break;
314
  case 'multiple_choice':
315
- switch ( $addon['display'] ) {
316
  case 'radiobutton':
317
- if ( ! is_array( $value ) ) {
318
- $wl_product['meta'][ $original_data ] = json_decode( $value, true );
319
  }
320
  break;
321
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-product-addons";
24
+
25
+ $name = "WooCommerce Product Add-ons";
26
+
27
+ $available = class_exists('WC_Product_Addons');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_item_meta_woocommerce_product_addons')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Product Addons
50
  *
51
  * @return array
52
  */
53
+ function tinv_wishlist_item_meta_woocommerce_product_addons($item_data, $product_id, $variation_id)
54
+ {
55
 
56
+ if (class_exists('WC_Product_Addons')) {
57
 
58
+ $id = ($variation_id) ? $variation_id : $product_id;
59
 
60
+ if (function_exists('get_product_addons')) {
61
+ $product_addons = get_product_addons($id);
62
  } else {
63
+ $product_addons = WC_Product_Addons_Helper::get_product_addons($id);
64
  }
65
 
66
+ if ($product_addons) {
67
 
68
  $field = null;
69
 
70
+ foreach ($product_addons as $addon) {
71
+ foreach ($addon['options'] as $option) {
72
  $original_data = 'addon-' . $addon['field_name'];
73
 
74
+ $value = isset($item_data[$original_data]) ? $item_data[$original_data]['display'] : '';
75
 
76
+ if ($value == '') {
77
  continue;
78
  }
79
 
80
+ if (is_array($value)) {
81
+ $value = array_map('stripslashes', $value);
82
  } else {
83
+ $value = stripslashes($value);
84
  }
85
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php');
86
+ switch ($addon['type']) {
87
  case 'checkbox':
88
+ $value = json_decode($value, true);
89
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php');
90
+ $field = new WC_Product_Addons_Field_List($addon, $value);
91
  break;
92
  case 'multiple_choice':
93
+ switch ($addon['display']) {
94
  case 'radiobutton':
95
+ $value = json_decode($value, true);
96
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php');
97
+ $field = new WC_Product_Addons_Field_List($addon, $value);
98
  break;
99
  case 'images':
100
  case 'select':
101
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php');
102
+ $field = new WC_Product_Addons_Field_Select($addon, $value);
103
  break;
104
  }
105
  break;
107
  case 'custom_textarea':
108
  case 'custom_price':
109
  case 'input_multiplier':
110
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php');
111
+ $field = new WC_Product_Addons_Field_Custom($addon, $value);
112
  break;
113
  case 'file_upload':
114
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php');
115
+ $field = new WC_Product_Addons_Field_File_Upload($addon, $value);
116
+ if ($field && isset($field->value)) {
117
+ $field->value = basename($field->value);
118
  }
119
  break;
120
  default:
122
  break;
123
  }
124
 
125
+ if ($field) {
126
  $data = $field->get_cart_item_data();
127
+ unset($item_data[$original_data]);
128
+ foreach ($data as $opt) {
129
  $name = $opt['name'];
130
 
131
+ if ($opt['price'] && apply_filters('woocommerce_addons_add_price_to_name', '__return_true')) {
132
+ $name .= ' (' . wc_price(WC_Product_Addons_Helper::get_product_addon_price_for_display($opt['price'])) . ')';
133
  }
134
 
135
  $item_data[] = array(
136
+ 'key' => $name,
137
  'display' => $opt['value'],
138
  );
139
  }
146
  return $item_data;
147
  }
148
 
149
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_product_addons', 10, 3);
150
  } // End if().
151
 
152
+ if (!function_exists('tinvwl_item_price_woocommerce_product_addons')) {
153
 
154
  /**
155
  * Modify price for WooCommerce Product Addons.
160
  *
161
  * @return string
162
  */
163
+ function tinvwl_item_price_woocommerce_product_addons($price, $wl_product, $product)
164
+ {
165
 
166
+ if (class_exists('WC_Product_Addons')) {
167
 
168
+ if (function_exists('get_product_addons')) {
169
+ $product_addons = get_product_addons($product->get_id());
170
  } else {
171
+ $product_addons = WC_Product_Addons_Helper::get_product_addons($product->get_id());
172
  }
173
 
174
+ if ($product_addons) {
175
 
176
  $price = 0;
177
  $field = null;
178
 
179
+ foreach ($product_addons as $addon) {
180
 
181
  $original_data = 'addon-' . $addon['field_name'];
182
 
183
+ $value = isset($wl_product['meta'][$original_data]) ? $wl_product['meta'][$original_data] : '';
184
+ if ($value == '') {
185
  continue;
186
  }
187
 
188
+ if (is_array($value)) {
189
+ $value = array_map('stripslashes', $value);
190
  } else {
191
+ $value = stripslashes($value);
192
  }
193
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php');
194
+ switch ($addon['type']) {
195
  case 'checkbox':
196
+ $value = json_decode($value, true);
197
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php');
198
+ $field = new WC_Product_Addons_Field_List($addon, $value);
199
  break;
200
  case 'multiple_choice':
201
+ switch ($addon['display']) {
202
  case 'radiobutton':
203
+ $value = json_decode($value, true);
204
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php');
205
+ $field = new WC_Product_Addons_Field_List($addon, $value);
206
  break;
207
  case 'images':
208
  case 'select':
209
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php');
210
+ $field = new WC_Product_Addons_Field_Select($addon, $value);
211
  break;
212
  }
213
  break;
215
  case 'custom_textarea':
216
  case 'custom_price':
217
  case 'input_multiplier':
218
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php');
219
+ $field = new WC_Product_Addons_Field_Custom($addon, $value);
220
  break;
221
  case 'file_upload':
222
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php');
223
+ $field = new WC_Product_Addons_Field_File_Upload($addon, $value);
224
  break;
225
  default:
226
  // Continue to the next field in case the type is not recognized (instead of causing a fatal error)
227
  break;
228
  }
229
 
230
+ if ($field) {
231
  $data = $field->get_cart_item_data();
232
+ foreach ($data as $option) {
233
+ if ($option['price']) {
234
+ $price += (float)$option['price'];
235
  }
236
  }
237
  }
238
 
239
  }
240
 
241
+ $price = wc_price((float)$product->get_price() + (float)$price);
242
  }
243
  }
244
 
245
  return $price;
246
  }
247
 
248
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_addons', 10, 3);
249
  } // End if().
250
 
251
+ add_filter('tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_product_addons', 10, 3);
252
 
253
+ function tinvwl_meta_woocommerce_product_addons($meta, $post, $files)
254
+ {
255
 
256
+ if (class_exists('WC_Product_Addons') && !empty($files)) {
257
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php');
258
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php');
259
+ $field = new WC_Product_Addons_Field_File_Upload(array());
260
+ foreach ($files as $name => $file) {
261
 
262
+ if (array_key_exists($name, $meta)) {
263
+ $upload = $field->handle_upload($file);
264
+ if (empty($upload['error']) && !empty($upload['file'])) {
265
+ $meta[$name] = wc_clean($upload['url']);
266
  }
267
  }
268
  }
271
  return $meta;
272
  }
273
 
274
+ add_filter('tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_product_addons');
275
 
276
+ function tinvwl_cart_meta_woocommerce_product_addons($meta)
277
+ {
278
 
279
+ if (class_exists('WC_Product_Addons') && !empty($files)) {
280
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php');
281
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php');
282
+ $field = new WC_Product_Addons_Field_File_Upload(array());
283
 
284
  $files = $_FILES;
285
 
286
+ foreach ($files as $name => $file) {
287
 
288
+ if (!array_key_exists($name, $meta)) {
289
+ $upload = $field->handle_upload($file);
290
+ if (empty($upload['error']) && !empty($upload['file'])) {
291
+ $meta[$name] = wc_clean($upload['url']);
292
  }
293
  }
294
  }
298
  }
299
 
300
 
301
+ add_filter('tinvwl_addproduct_tocart', 'tinvwl_add_to_cart_meta_woocommerce_product_addons');
302
 
303
+ function tinvwl_add_to_cart_meta_woocommerce_product_addons($wl_product)
304
+ {
305
+ if (class_exists('WC_Product_Addons')) {
306
 
307
+ $id = ($wl_product['variation_id']) ? $wl_product['variation_id'] : $wl_product['product_id'];
308
 
309
+ if (function_exists('get_product_addons')) {
310
+ $product_addons = get_product_addons($id);
311
  } else {
312
+ $product_addons = WC_Product_Addons_Helper::get_product_addons($id);
313
  }
314
 
315
+ if ($product_addons) {
316
 
317
  $field = null;
318
 
319
+ foreach ($product_addons as $addon) {
320
+ foreach ($addon['options'] as $option) {
321
  $original_data = 'addon-' . $addon['field_name'];
322
 
323
+ $value = isset($wl_product['meta'][$original_data]) ? $wl_product['meta'][$original_data] : '';
324
 
325
+ if ($value == '') {
326
  continue;
327
  }
328
 
329
+ if (is_array($value)) {
330
+ $value = array_map('stripslashes', $value);
331
  } else {
332
+ $value = stripslashes($value);
333
  }
334
+ include_once(WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php');
335
+ switch ($addon['type']) {
336
  case 'checkbox':
337
+ if (!is_array($value)) {
338
+ $wl_product['meta'][$original_data] = json_decode($value, true);
339
  }
340
  break;
341
  case 'multiple_choice':
342
+ switch ($addon['display']) {
343
  case 'radiobutton':
344
+ if (!is_array($value)) {
345
+ $wl_product['meta'][$original_data] = json_decode($value, true);
346
  }
347
  break;
348
  }
integrations/woocommerce-product-bundles.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_bundles' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Product Bundles
@@ -27,20 +49,21 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_bundles'
27
  *
28
  * @return array
29
  */
30
- function tinv_wishlist_metasupport_woocommerce_product_bundles( $meta, $product_id ) {
31
- $product = wc_get_product( $product_id );
 
32
 
33
- if ( is_object( $product ) && $product->is_type( 'bundle' ) && empty( $meta['bkap_price_charged'] ) ) {
34
  $meta = array();
35
  }
36
 
37
  return $meta;
38
  }
39
 
40
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_bundles', 10, 2 );
41
  } // End if().
42
 
43
- if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
44
 
45
  /**
46
  * Add rows for sub product for WooCommerce Product Bundles
@@ -49,94 +72,95 @@ if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
49
  * @param \WC_Product $product Woocommerce Product.
50
  * @param int $discount_extra possible discount on bundle row.
51
  */
52
- function tinvwl_row_woocommerce_product_bundles( $wl_product, $product, $discount_extra = 0 ) {
53
- if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
 
54
 
55
- $product_id = WC_PB_Core_Compatibility::get_id( $product );
56
  $bundled_items = $product->get_bundled_items();
57
- if ( ! empty( $bundled_items ) ) {
58
- foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
59
 
60
- $bundled_item_variation_id_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_variation_id_' . $bundled_item_id;
61
- $bundled_variation_id = absint( isset( $wl_product['meta'][ $bundled_item_variation_id_request_key ] ) ? $wl_product['meta'][ $bundled_item_variation_id_request_key ] : 0 );
62
- if ( ! empty( $bundled_variation_id ) ) {
63
- $bundled_item->product = wc_get_product( $bundled_variation_id );
64
  }
65
 
66
  $is_optional = $bundled_item->is_optional();
67
 
68
- $bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
69
- $bundled_product_qty = isset( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) ? absint( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) : $bundled_item->get_quantity();
70
 
71
- if ( $is_optional ) {
72
 
73
  /** Documented in method 'get_posted_bundle_configuration'. */
74
- $bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
75
 
76
- if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
77
  $bundled_product_qty = 0;
78
  }
79
  }
80
- if ( 0 === $bundled_product_qty || 'visible' != $bundled_item->cart_visibility ) {
81
  continue;
82
  }
83
 
84
- $product_url = $bundled_item->product->get_permalink();
85
  $product_image = $bundled_item->product->get_image();
86
- $product_title = $bundled_item->has_title_override() ? is_callable( array(
87
  $bundled_item,
88
  'get_name'
89
- ) ) ? $bundled_item->get_name() : $bundled_item->get_title() : $bundled_item->get_raw_title();
90
 
91
- $product_price = $bundled_item->product->get_price_html();
92
  $product_price_raw = $bundled_item->product->get_regular_price();
93
- $discount = $bundled_item->get_discount();
94
- $discount = empty( $discount ) ? $discount_extra : ( 100 - $discount ) / $discount_extra + $discount;
95
- $product_price = empty( $discount ) ? $product_price : wc_price( WC_PB_Product_Prices::get_discounted_price( $product_price_raw, $discount ) );
96
 
97
- if ( $bundled_item->product->is_visible() ) {
98
- $product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
99
- $product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
100
  }
101
- $product_title .= tinv_wishlist_get_item_data( $bundled_item->product, $wl_product );
102
 
103
- $availability = (array) $bundled_item->product->get_availability();
104
- if ( ! array_key_exists( 'availability', $availability ) ) {
105
  $availability['availability'] = '';
106
  }
107
- if ( ! array_key_exists( 'class', $availability ) ) {
108
  $availability['class'] = '';
109
  }
110
- $availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
111
- $row_string = '<tr>';
112
- $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
113
- if ( tinv_get_option( 'product_table', 'colm_price' ) && $bundled_item->is_priced_individually() ) {
114
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
115
- } elseif ( ! $bundled_item->is_priced_individually() ) {
116
  $row_string .= '<td class="product-price"></td>';
117
  }
118
- if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
119
  $row_string .= '<td class="product-date">&nbsp;</td>';
120
  }
121
- if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
122
  $row_string .= '<td class="product-stock">%4$s</td>';
123
  }
124
 
125
- if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
126
  $row_string .= '<td class="product-action">&nbsp;</td>';
127
  }
128
  $row_string .= '</tr>';
129
 
130
- echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty ); // WPCS: xss ok.
131
  } // End foreach().
132
  } // End if().
133
  } // End if().
134
  }
135
 
136
- add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_product_bundles', 10, 2 );
137
  } // End if().
138
 
139
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
140
 
141
  /**
142
  * Modify price for WooCommerce Product Bundles
@@ -147,57 +171,58 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
147
  *
148
  * @return string
149
  */
150
- function tinvwl_item_price_woocommerce_product_bundles( $price, $wl_product, $product, $raw = false ) {
151
- if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
 
152
 
153
- $bundle_price = $product->get_price();
154
- $product_id = WC_PB_Core_Compatibility::get_id( $product );
155
  $bundled_items = $product->get_bundled_items();
156
 
157
- if ( ! empty( $bundled_items ) ) {
158
 
159
  $bundled_items_price = 0.0;
160
 
161
- foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
162
 
163
- $bundled_item_variation_id_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_variation_id_' . $bundled_item_id;
164
- $bundled_variation_id = absint( isset( $wl_product['meta'][ $bundled_item_variation_id_request_key ] ) ? $wl_product['meta'][ $bundled_item_variation_id_request_key ] : 0 );
165
- if ( ! empty( $bundled_variation_id ) ) {
166
- $_bundled_product = wc_get_product( $bundled_variation_id );
167
  } else {
168
  $_bundled_product = $bundled_item->product;
169
  }
170
 
171
  $is_optional = $bundled_item->is_optional();
172
 
173
- $bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
174
- $bundled_product_qty = isset( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) ? absint( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) : $bundled_item->get_quantity();
175
 
176
- if ( $is_optional ) {
177
 
178
  /** Documented in method 'get_posted_bundle_configuration'. */
179
- $bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
180
 
181
- if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
182
  $bundled_product_qty = 0;
183
  }
184
  }
185
 
186
- if ( $bundled_item->is_priced_individually() ) {
187
  $product_price = $_bundled_product->get_regular_price();
188
 
189
- $discount = $bundled_item->get_discount();
190
- $product_price = empty( $discount ) ? $product_price : WC_PB_Product_Prices::get_discounted_price( $product_price, $discount );
191
 
192
- $bundled_item_price = (double) $product_price * (int) $bundled_product_qty;
193
 
194
- $bundled_items_price += (double) $bundled_item_price;
195
  }
196
 
197
  } // End foreach().
198
- $price = (double) $bundle_price + $bundled_items_price;
199
- if ( ! $raw ) {
200
- $price = apply_filters( 'woocommerce_get_price_html', wc_price( $price ), $product );
201
  }
202
  } // End if().
203
  } // End if().
@@ -205,5 +230,5 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
205
  return $price;
206
  }
207
 
208
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_bundles', 10, 3 );
209
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-product-bundles";
24
+
25
+ $name = "WooCommerce Product Bundles";
26
+
27
+ $available = class_exists('WC_Bundles');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_product_bundles')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Product Bundles
49
  *
50
  * @return array
51
  */
52
+ function tinv_wishlist_metasupport_woocommerce_product_bundles($meta, $product_id)
53
+ {
54
+ $product = wc_get_product($product_id);
55
 
56
+ if (is_object($product) && $product->is_type('bundle') && empty($meta['bkap_price_charged'])) {
57
  $meta = array();
58
  }
59
 
60
  return $meta;
61
  }
62
 
63
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_bundles', 10, 2);
64
  } // End if().
65
 
66
+ if (!function_exists('tinvwl_row_woocommerce_product_bundles')) {
67
 
68
  /**
69
  * Add rows for sub product for WooCommerce Product Bundles
72
  * @param \WC_Product $product Woocommerce Product.
73
  * @param int $discount_extra possible discount on bundle row.
74
  */
75
+ function tinvwl_row_woocommerce_product_bundles($wl_product, $product, $discount_extra = 0)
76
+ {
77
+ if (is_object($product) && $product->is_type('bundle')) {
78
 
79
+ $product_id = WC_PB_Core_Compatibility::get_id($product);
80
  $bundled_items = $product->get_bundled_items();
81
+ if (!empty($bundled_items)) {
82
+ foreach ($bundled_items as $bundled_item_id => $bundled_item) {
83
 
84
+ $bundled_item_variation_id_request_key = apply_filters('woocommerce_product_bundle_field_prefix', '', $product_id) . 'bundle_variation_id_' . $bundled_item_id;
85
+ $bundled_variation_id = absint(isset($wl_product['meta'][$bundled_item_variation_id_request_key]) ? $wl_product['meta'][$bundled_item_variation_id_request_key] : 0);
86
+ if (!empty($bundled_variation_id)) {
87
+ $bundled_item->product = wc_get_product($bundled_variation_id);
88
  }
89
 
90
  $is_optional = $bundled_item->is_optional();
91
 
92
+ $bundled_item_quantity_request_key = apply_filters('woocommerce_product_bundle_field_prefix', '', $product_id) . 'bundle_quantity_' . $bundled_item_id;
93
+ $bundled_product_qty = isset($wl_product['meta'][$bundled_item_quantity_request_key]) ? absint($wl_product['meta'][$bundled_item_quantity_request_key]) : $bundled_item->get_quantity();
94
 
95
+ if ($is_optional) {
96
 
97
  /** Documented in method 'get_posted_bundle_configuration'. */
98
+ $bundled_item_selected_request_key = apply_filters('woocommerce_product_bundle_field_prefix', '', $product_id) . 'bundle_selected_optional_' . $bundled_item_id;
99
 
100
+ if (!array_key_exists($bundled_item_selected_request_key, $wl_product['meta'])) {
101
  $bundled_product_qty = 0;
102
  }
103
  }
104
+ if (0 === $bundled_product_qty || 'visible' != $bundled_item->cart_visibility) {
105
  continue;
106
  }
107
 
108
+ $product_url = $bundled_item->product->get_permalink();
109
  $product_image = $bundled_item->product->get_image();
110
+ $product_title = $bundled_item->has_title_override() ? is_callable(array(
111
  $bundled_item,
112
  'get_name'
113
+ )) ? $bundled_item->get_name() : $bundled_item->get_title() : $bundled_item->get_raw_title();
114
 
115
+ $product_price = $bundled_item->product->get_price_html();
116
  $product_price_raw = $bundled_item->product->get_regular_price();
117
+ $discount = $bundled_item->get_discount();
118
+ $discount = empty($discount) ? $discount_extra : (100 - $discount) / $discount_extra + $discount;
119
+ $product_price = empty($discount) ? $product_price : wc_price(WC_PB_Product_Prices::get_discounted_price($product_price_raw, $discount));
120
 
121
+ if ($bundled_item->product->is_visible()) {
122
+ $product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
123
+ $product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
124
  }
125
+ $product_title .= tinv_wishlist_get_item_data($bundled_item->product, $wl_product);
126
 
127
+ $availability = (array)$bundled_item->product->get_availability();
128
+ if (!array_key_exists('availability', $availability)) {
129
  $availability['availability'] = '';
130
  }
131
+ if (!array_key_exists('class', $availability)) {
132
  $availability['class'] = '';
133
  }
134
+ $availability_html = empty($availability['availability']) ? '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__('In stock', 'ti-woocommerce-wishlist') . '</span></p>' : '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html($availability['availability']) . '</span></p>';
135
+ $row_string = '<tr>';
136
+ $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
137
+ if (tinv_get_option('product_table', 'colm_price') && $bundled_item->is_priced_individually()) {
138
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
139
+ } elseif (!$bundled_item->is_priced_individually()) {
140
  $row_string .= '<td class="product-price"></td>';
141
  }
142
+ if (tinv_get_option('product_table', 'colm_date')) {
143
  $row_string .= '<td class="product-date">&nbsp;</td>';
144
  }
145
+ if (tinv_get_option('product_table', 'colm_stock')) {
146
  $row_string .= '<td class="product-stock">%4$s</td>';
147
  }
148
 
149
+ if (tinv_get_option('product_table', 'add_to_cart')) {
150
  $row_string .= '<td class="product-action">&nbsp;</td>';
151
  }
152
  $row_string .= '</tr>';
153
 
154
+ echo sprintf($row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty); // WPCS: xss ok.
155
  } // End foreach().
156
  } // End if().
157
  } // End if().
158
  }
159
 
160
+ add_action('tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_product_bundles', 10, 2);
161
  } // End if().
162
 
163
+ if (!function_exists('tinvwl_item_price_woocommerce_product_bundles')) {
164
 
165
  /**
166
  * Modify price for WooCommerce Product Bundles
171
  *
172
  * @return string
173
  */
174
+ function tinvwl_item_price_woocommerce_product_bundles($price, $wl_product, $product, $raw = false)
175
+ {
176
+ if (is_object($product) && $product->is_type('bundle')) {
177
 
178
+ $bundle_price = $product->get_price();
179
+ $product_id = WC_PB_Core_Compatibility::get_id($product);
180
  $bundled_items = $product->get_bundled_items();
181
 
182
+ if (!empty($bundled_items)) {
183
 
184
  $bundled_items_price = 0.0;
185
 
186
+ foreach ($bundled_items as $bundled_item_id => $bundled_item) {
187
 
188
+ $bundled_item_variation_id_request_key = apply_filters('woocommerce_product_bundle_field_prefix', '', $product_id) . 'bundle_variation_id_' . $bundled_item_id;
189
+ $bundled_variation_id = absint(isset($wl_product['meta'][$bundled_item_variation_id_request_key]) ? $wl_product['meta'][$bundled_item_variation_id_request_key] : 0);
190
+ if (!empty($bundled_variation_id)) {
191
+ $_bundled_product = wc_get_product($bundled_variation_id);
192
  } else {
193
  $_bundled_product = $bundled_item->product;
194
  }
195
 
196
  $is_optional = $bundled_item->is_optional();
197
 
198
+ $bundled_item_quantity_request_key = apply_filters('woocommerce_product_bundle_field_prefix', '', $product_id) . 'bundle_quantity_' . $bundled_item_id;
199
+ $bundled_product_qty = isset($wl_product['meta'][$bundled_item_quantity_request_key]) ? absint($wl_product['meta'][$bundled_item_quantity_request_key]) : $bundled_item->get_quantity();
200
 
201
+ if ($is_optional) {
202
 
203
  /** Documented in method 'get_posted_bundle_configuration'. */
204
+ $bundled_item_selected_request_key = apply_filters('woocommerce_product_bundle_field_prefix', '', $product_id) . 'bundle_selected_optional_' . $bundled_item_id;
205
 
206
+ if (!array_key_exists($bundled_item_selected_request_key, $wl_product['meta'])) {
207
  $bundled_product_qty = 0;
208
  }
209
  }
210
 
211
+ if ($bundled_item->is_priced_individually()) {
212
  $product_price = $_bundled_product->get_regular_price();
213
 
214
+ $discount = $bundled_item->get_discount();
215
+ $product_price = empty($discount) ? $product_price : WC_PB_Product_Prices::get_discounted_price($product_price, $discount);
216
 
217
+ $bundled_item_price = (double)$product_price * (int)$bundled_product_qty;
218
 
219
+ $bundled_items_price += (double)$bundled_item_price;
220
  }
221
 
222
  } // End foreach().
223
+ $price = (double)$bundle_price + $bundled_items_price;
224
+ if (!$raw) {
225
+ $price = apply_filters('woocommerce_get_price_html', wc_price($price), $product);
226
  }
227
  } // End if().
228
  } // End if().
230
  return $price;
231
  }
232
 
233
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_bundles', 10, 3);
234
  } // End if().
integrations/woocommerce-product-table.php CHANGED
@@ -13,11 +13,29 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! class_exists( 'Abstract_Product_Table_Data' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  return;
22
  }
23
 
@@ -26,14 +44,16 @@ if ( ! class_exists( 'Abstract_Product_Table_Data' ) ) {
26
  *
27
  * @license GPL-3.0
28
  */
29
- class TINVWL_Product_Table_Data_Wishlist extends Abstract_Product_Table_Data {
 
30
 
31
- public function get_data() {
32
- return apply_filters( 'wc_product_table_data_wishlist', do_shortcode( '[ti_wishlists_addtowishlist loop="yes"]' ), $this->product );
 
33
  }
34
 
35
  }
36
 
37
- add_filter( 'wc_product_table_custom_table_data_wishlist', function ( $data_obj, $product, $args ) {
38
- return new TINVWL_Product_Table_Data_Wishlist( $product );
39
- }, 10, 3 );
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-product-table";
24
+
25
+ $name = "WooCommerce Product Table";
26
+
27
+ $available = class_exists('Barn2\Plugin\WC_Product_Table');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
  return;
40
  }
41
 
44
  *
45
  * @license GPL-3.0
46
  */
47
+ class TINVWL_Product_Table_Data_Wishlist extends Abstract_Product_Table_Data
48
+ {
49
 
50
+ public function get_data()
51
+ {
52
+ return apply_filters('wc_product_table_data_wishlist', do_shortcode('[ti_wishlists_addtowishlist loop="yes"]'), $this->product);
53
  }
54
 
55
  }
56
 
57
+ add_filter('wc_product_table_custom_table_data_wishlist', function ($data_obj, $product, $args) {
58
+ return new TINVWL_Product_Table_Data_Wishlist($product);
59
+ }, 10, 3);
integrations/woocommerce-rental-and-booking.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_woocommerce_rental_and_booking_product_type' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Force product type selection.
@@ -26,19 +48,20 @@ if ( ! function_exists( 'tinvwl_woocommerce_rental_and_booking_product_type' ) )
26
  *
27
  * @return array
28
  */
29
- function tinvwl_woocommerce_rental_and_booking_product_type( $product_types ) {
 
30
 
31
- if ( class_exists( 'RedQ_Rental_And_Bookings' ) ) {
32
- $product_types['redq_rental'] = __( 'Rental Product', 'redq-rental' );
33
  }
34
 
35
  return $product_types;
36
  }
37
 
38
- add_filter( 'product_type_selector', 'tinvwl_woocommerce_rental_and_booking_product_type' );
39
  }
40
 
41
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_rental_and_booking' ) ) {
42
 
43
  /**
44
  * Set description for meta WooCommerce Rental & Bookings System
@@ -49,21 +72,22 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_rental_and_bookin
49
  *
50
  * @return array
51
  */
52
- function tinv_wishlist_metasupport_woocommerce_rental_and_booking( $meta, $product_id, $variation_id ) {
53
- if ( ! class_exists( 'RedQ_Rental_And_Bookings' ) ) {
 
54
  return $meta;
55
  }
56
 
57
- $product_type = wc_get_product( $product_id )->get_type();
58
 
59
- if ( isset( $product_type ) && $product_type === 'redq_rental' ) {
60
 
61
  $custom_data = array();
62
 
63
- $options_data = array();
64
  $options_data['quote_id'] = '';
65
 
66
- $get_labels = redq_rental_get_settings( $product_id, 'labels', array(
67
  'pickup_location',
68
  'return_location',
69
  'pickup_date',
@@ -72,178 +96,178 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_rental_and_bookin
72
  'categories',
73
  'person',
74
  'deposites'
75
- ) );
76
- $labels = $get_labels['labels'];
77
- $get_displays = redq_rental_get_settings( $product_id, 'display' );
78
- $displays = $get_displays['display'];
79
 
80
- $get_conditions = redq_rental_get_settings( $product_id, 'conditions' );
81
  $conditional_data = $get_conditions['conditions'];
82
 
83
- $get_general = redq_rental_get_settings( $product_id, 'general' );
84
  $general_data = $get_general['general'];
85
 
86
- if ( isset( $meta['quote_id'] ) ) {
87
  $custom_data[] = array(
88
- 'key' => $options_data['quote_id'] ? $options_data['quote_id'] : __( 'Quote Request', 'redq-rental' ),
89
  'display' => '#' . $meta['quote_id']['display'],
90
 
91
  );
92
  }
93
 
94
- if ( isset( $meta['pickup_location'] ) ) {
95
  $custom_data[] = array(
96
- 'key' => $labels['pickup_location'],
97
  'display' => $meta['pickup_location']['display']['address'],
98
 
99
  );
100
  }
101
 
102
- if ( isset( $meta['pickup_location'] ) && ! empty( $meta['pickup_location']['cost'] ) ) {
103
  $custom_data[] = array(
104
- 'key' => $labels['pickup_location'] . __( ' Cost', 'redq-rental' ),
105
- 'display' => wc_price( $meta['pickup_location']['display']['cost'] ),
106
 
107
  );
108
  }
109
 
110
- if ( isset( $meta['dropoff_location'] ) ) {
111
  $custom_data[] = array(
112
- 'key' => $labels['return_location'],
113
  'display' => $meta['dropoff_location']['display']['address'],
114
 
115
  );
116
  }
117
 
118
- if ( isset( $meta['dropoff_location'] ) && ! empty( $meta['dropoff_location']['cost'] ) ) {
119
  $custom_data[] = array(
120
- 'key' => $labels['return_location'] . __( ' Cost', 'redq-rental' ),
121
- 'display' => wc_price( $meta['dropoff_location']['display']['cost'] ),
122
 
123
  );
124
  }
125
 
126
- if ( isset( $meta['location_cost'] ) ) {
127
  $custom_data[] = array(
128
- 'key' => esc_html__( 'Location Cost', 'redq-rental' ),
129
- 'display' => wc_price( $meta['location_cost']['display'] ),
130
 
131
  );
132
  }
133
 
134
- if ( isset( $meta['payable_cat'] ) ) {
135
  $cat_name = '';
136
- foreach ( $meta['payable_cat']['display'] as $key => $value ) {
137
- if ( $value['multiply'] === 'per_day' ) {
138
- $cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price( $value['cost'] ) . ' - ' . __( 'Per Day', 'redq-rental' ) . ' )' . ' , <br> ';
139
  } else {
140
- $cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price( $value['cost'] ) . ' - ' . __( 'One Time', 'redq-rental' ) . ' )' . ' , <br> ';
141
  }
142
  }
143
  $custom_data[] = array(
144
- 'key' => $labels['categories'],
145
  'display' => $cat_name,
146
 
147
  );
148
  }
149
 
150
- if ( isset( $meta['payable_resource'] ) ) {
151
  $resource_name = '';
152
- foreach ( $meta['payable_resource']['display'] as $key => $value ) {
153
- if ( $value['cost_multiply'] === 'per_day' ) {
154
- $resource_name .= $value['resource_name'] . ' ( ' . wc_price( $value['resource_cost'] ) . ' - ' . __( 'Per Day', 'redq-rental' ) . ' )' . ' , <br> ';
155
  } else {
156
- $resource_name .= $value['resource_name'] . ' ( ' . wc_price( $value['resource_cost'] ) . ' - ' . __( 'One Time', 'redq-rental' ) . ' )' . ' , <br> ';
157
  }
158
  }
159
  $custom_data[] = array(
160
- 'key' => $labels['resource'],
161
  'display' => $resource_name,
162
 
163
  );
164
  }
165
 
166
- if ( isset( $meta['payable_security_deposites'] ) ) {
167
  $security_deposite_name = '';
168
- foreach ( $meta['payable_security_deposites']['display'] as $key => $value ) {
169
- if ( $value['cost_multiply'] === 'per_day' ) {
170
- $security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price( $value['security_deposite_cost'] ) . ' - ' . __( 'Per Day', 'redq-rental' ) . ' )' . ' , <br> ';
171
  } else {
172
- $security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price( $value['security_deposite_cost'] ) . ' - ' . __( 'One Time', 'redq-rental' ) . ' )' . ' , <br> ';
173
  }
174
  }
175
  $custom_data[] = array(
176
- 'key' => $labels['deposite'],
177
  'display' => $security_deposite_name,
178
 
179
  );
180
  }
181
 
182
- if ( isset( $meta['adults_info'] ) ) {
183
  $custom_data[] = array(
184
- 'key' => $labels['adults'],
185
  'display' => $meta['adults_info']['display']['person_count'],
186
 
187
  );
188
  }
189
 
190
- if ( isset( $meta['childs_info'] ) ) {
191
  $custom_data[] = array(
192
- 'key' => $labels['childs'],
193
  'display' => $meta['childs_info']['display']['person_count'],
194
 
195
  );
196
  }
197
 
198
 
199
- if ( isset( $meta['pickup_date'] ) && $displays['pickup_date'] === 'open' ) {
200
 
201
- $pickup_date_time = convert_to_output_format( $meta['pickup_date']['display'], $conditional_data['date_format'] );
202
 
203
- if ( isset( $meta['pickup_time'] ) ) {
204
- $pickup_date_time = $pickup_date_time . ' ' . esc_html__( 'at', 'redq-rental' ) . ' ' . $meta['pickup_time']['display'];
205
  }
206
  $custom_data[] = array(
207
- 'key' => $labels['pickup_datetime'],
208
  'display' => $pickup_date_time,
209
 
210
  );
211
  }
212
 
213
- if ( isset( $meta['dropoff_date'] ) && $displays['return_date'] === 'open' ) {
214
 
215
- $return_date_time = convert_to_output_format( $meta['dropoff_date']['display'], $conditional_data['date_format'] );
216
 
217
- if ( isset( $meta['dropoff_time'] ) ) {
218
- $return_date_time = $return_date_time . ' ' . esc_html__( 'at', 'redq-rental' ) . ' ' . $meta['dropoff_time']['display'];
219
  }
220
 
221
  $custom_data[] = array(
222
- 'key' => $labels['return_datetime'],
223
  'display' => $return_date_time,
224
 
225
  );
226
  }
227
 
228
- if ( isset( $meta['rental_days_and_costs'] ) ) {
229
- if ( $meta['rental_days_and_costs']['display']['days'] > 0 ) {
230
  $custom_data[] = array(
231
- 'key' => $general_data['total_days'] ? $general_data['total_days'] : esc_html__( 'Total Days', 'redq-rental' ),
232
  'display' => $meta['rental_days_and_costs']['display']['days'],
233
 
234
  );
235
  } else {
236
  $custom_data[] = array(
237
- 'key' => $general_data['total_hours'] ? $general_data['total_hours'] : esc_html__( 'Total Hours', 'redq-rental' ),
238
  'display' => $meta['rental_days_and_costs']['display']['hours'],
239
 
240
  );
241
  }
242
 
243
- if ( ! empty( $meta['rental_days_and_costs']['due_payment'] ) ) {
244
  $custom_data[] = array(
245
- 'key' => $general_data['payment_due'] ? $general_data['payment_due'] : esc_html__( 'Due Payment', 'redq-rental' ),
246
- 'display' => wc_price( $meta['rental_days_and_costs']['display']['due_payment'] ),
247
 
248
  );
249
  }
@@ -255,10 +279,10 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_rental_and_bookin
255
  return $meta;
256
  }
257
 
258
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_rental_and_booking', 20, 3 );
259
  } // End if().
260
 
261
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_rental_and_booking' ) ) {
262
 
263
  /**
264
  * Modify price for WooCommerce Rental & Bookings System
@@ -269,21 +293,22 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_rental_and_booking' ) ) {
269
  *
270
  * @return string
271
  */
272
- function tinvwl_item_price_woocommerce_rental_and_booking( $price, $wl_product, $product ) {
273
- if ( ! class_exists( 'RedQ_Rental_And_Bookings' ) ) {
 
274
  return $price;
275
  }
276
 
277
  $product_type = $product->get_type();
278
 
279
- if ( isset( $product_type ) && $product_type === 'redq_rental' ) {
280
  $meta = $wl_product['meta'];
281
 
282
- if ( ! empty( $meta['quote_price'] ) ) {
283
 
284
  $price = $meta['quote_price'];
285
 
286
- return wc_price( $price );
287
  }
288
  }
289
 
@@ -291,5 +316,5 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_rental_and_booking' ) ) {
291
  return $price;
292
  }
293
 
294
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_rental_and_booking', 20, 3 );
295
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-rental-and-booking";
24
+
25
+ $name = "WooCommerce Rental & Bookings System";
26
+
27
+ $available = class_exists('RedQ_Rental_And_Bookings');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_woocommerce_rental_and_booking_product_type')) {
43
 
44
  /**
45
  * Force product type selection.
48
  *
49
  * @return array
50
  */
51
+ function tinvwl_woocommerce_rental_and_booking_product_type($product_types)
52
+ {
53
 
54
+ if (class_exists('RedQ_Rental_And_Bookings')) {
55
+ $product_types['redq_rental'] = __('Rental Product', 'redq-rental');
56
  }
57
 
58
  return $product_types;
59
  }
60
 
61
+ add_filter('product_type_selector', 'tinvwl_woocommerce_rental_and_booking_product_type');
62
  }
63
 
64
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_rental_and_booking')) {
65
 
66
  /**
67
  * Set description for meta WooCommerce Rental & Bookings System
72
  *
73
  * @return array
74
  */
75
+ function tinv_wishlist_metasupport_woocommerce_rental_and_booking($meta, $product_id, $variation_id)
76
+ {
77
+ if (!class_exists('RedQ_Rental_And_Bookings')) {
78
  return $meta;
79
  }
80
 
81
+ $product_type = wc_get_product($product_id)->get_type();
82
 
83
+ if (isset($product_type) && $product_type === 'redq_rental') {
84
 
85
  $custom_data = array();
86
 
87
+ $options_data = array();
88
  $options_data['quote_id'] = '';
89
 
90
+ $get_labels = redq_rental_get_settings($product_id, 'labels', array(
91
  'pickup_location',
92
  'return_location',
93
  'pickup_date',
96
  'categories',
97
  'person',
98
  'deposites'
99
+ ));
100
+ $labels = $get_labels['labels'];
101
+ $get_displays = redq_rental_get_settings($product_id, 'display');
102
+ $displays = $get_displays['display'];
103
 
104
+ $get_conditions = redq_rental_get_settings($product_id, 'conditions');
105
  $conditional_data = $get_conditions['conditions'];
106
 
107
+ $get_general = redq_rental_get_settings($product_id, 'general');
108
  $general_data = $get_general['general'];
109
 
110
+ if (isset($meta['quote_id'])) {
111
  $custom_data[] = array(
112
+ 'key' => $options_data['quote_id'] ? $options_data['quote_id'] : __('Quote Request', 'redq-rental'),
113
  'display' => '#' . $meta['quote_id']['display'],
114
 
115
  );
116
  }
117
 
118
+ if (isset($meta['pickup_location'])) {
119
  $custom_data[] = array(
120
+ 'key' => $labels['pickup_location'],
121
  'display' => $meta['pickup_location']['display']['address'],
122
 
123
  );
124
  }
125
 
126
+ if (isset($meta['pickup_location']) && !empty($meta['pickup_location']['cost'])) {
127
  $custom_data[] = array(
128
+ 'key' => $labels['pickup_location'] . __(' Cost', 'redq-rental'),
129
+ 'display' => wc_price($meta['pickup_location']['display']['cost']),
130
 
131
  );
132
  }
133
 
134
+ if (isset($meta['dropoff_location'])) {
135
  $custom_data[] = array(
136
+ 'key' => $labels['return_location'],
137
  'display' => $meta['dropoff_location']['display']['address'],
138
 
139
  );
140
  }
141
 
142
+ if (isset($meta['dropoff_location']) && !empty($meta['dropoff_location']['cost'])) {
143
  $custom_data[] = array(
144
+ 'key' => $labels['return_location'] . __(' Cost', 'redq-rental'),
145
+ 'display' => wc_price($meta['dropoff_location']['display']['cost']),
146
 
147
  );
148
  }
149
 
150
+ if (isset($meta['location_cost'])) {
151
  $custom_data[] = array(
152
+ 'key' => esc_html__('Location Cost', 'redq-rental'),
153
+ 'display' => wc_price($meta['location_cost']['display']),
154
 
155
  );
156
  }
157
 
158
+ if (isset($meta['payable_cat'])) {
159
  $cat_name = '';
160
+ foreach ($meta['payable_cat']['display'] as $key => $value) {
161
+ if ($value['multiply'] === 'per_day') {
162
+ $cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price($value['cost']) . ' - ' . __('Per Day', 'redq-rental') . ' )' . ' , <br> ';
163
  } else {
164
+ $cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price($value['cost']) . ' - ' . __('One Time', 'redq-rental') . ' )' . ' , <br> ';
165
  }
166
  }
167
  $custom_data[] = array(
168
+ 'key' => $labels['categories'],
169
  'display' => $cat_name,
170
 
171
  );
172
  }
173
 
174
+ if (isset($meta['payable_resource'])) {
175
  $resource_name = '';
176
+ foreach ($meta['payable_resource']['display'] as $key => $value) {
177
+ if ($value['cost_multiply'] === 'per_day') {
178
+ $resource_name .= $value['resource_name'] . ' ( ' . wc_price($value['resource_cost']) . ' - ' . __('Per Day', 'redq-rental') . ' )' . ' , <br> ';
179
  } else {
180
+ $resource_name .= $value['resource_name'] . ' ( ' . wc_price($value['resource_cost']) . ' - ' . __('One Time', 'redq-rental') . ' )' . ' , <br> ';
181
  }
182
  }
183
  $custom_data[] = array(
184
+ 'key' => $labels['resource'],
185
  'display' => $resource_name,
186
 
187
  );
188
  }
189
 
190
+ if (isset($meta['payable_security_deposites'])) {
191
  $security_deposite_name = '';
192
+ foreach ($meta['payable_security_deposites']['display'] as $key => $value) {
193
+ if ($value['cost_multiply'] === 'per_day') {
194
+ $security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price($value['security_deposite_cost']) . ' - ' . __('Per Day', 'redq-rental') . ' )' . ' , <br> ';
195
  } else {
196
+ $security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price($value['security_deposite_cost']) . ' - ' . __('One Time', 'redq-rental') . ' )' . ' , <br> ';
197
  }
198
  }
199
  $custom_data[] = array(
200
+ 'key' => $labels['deposite'],
201
  'display' => $security_deposite_name,
202
 
203
  );
204
  }
205
 
206
+ if (isset($meta['adults_info'])) {
207
  $custom_data[] = array(
208
+ 'key' => $labels['adults'],
209
  'display' => $meta['adults_info']['display']['person_count'],
210
 
211
  );
212
  }
213
 
214
+ if (isset($meta['childs_info'])) {
215
  $custom_data[] = array(
216
+ 'key' => $labels['childs'],
217
  'display' => $meta['childs_info']['display']['person_count'],
218
 
219
  );
220
  }
221
 
222
 
223
+ if (isset($meta['pickup_date']) && $displays['pickup_date'] === 'open') {
224
 
225
+ $pickup_date_time = convert_to_output_format($meta['pickup_date']['display'], $conditional_data['date_format']);
226
 
227
+ if (isset($meta['pickup_time'])) {
228
+ $pickup_date_time = $pickup_date_time . ' ' . esc_html__('at', 'redq-rental') . ' ' . $meta['pickup_time']['display'];
229
  }
230
  $custom_data[] = array(
231
+ 'key' => $labels['pickup_datetime'],
232
  'display' => $pickup_date_time,
233
 
234
  );
235
  }
236
 
237
+ if (isset($meta['dropoff_date']) && $displays['return_date'] === 'open') {
238
 
239
+ $return_date_time = convert_to_output_format($meta['dropoff_date']['display'], $conditional_data['date_format']);
240
 
241
+ if (isset($meta['dropoff_time'])) {
242
+ $return_date_time = $return_date_time . ' ' . esc_html__('at', 'redq-rental') . ' ' . $meta['dropoff_time']['display'];
243
  }
244
 
245
  $custom_data[] = array(
246
+ 'key' => $labels['return_datetime'],
247
  'display' => $return_date_time,
248
 
249
  );
250
  }
251
 
252
+ if (isset($meta['rental_days_and_costs'])) {
253
+ if ($meta['rental_days_and_costs']['display']['days'] > 0) {
254
  $custom_data[] = array(
255
+ 'key' => $general_data['total_days'] ? $general_data['total_days'] : esc_html__('Total Days', 'redq-rental'),
256
  'display' => $meta['rental_days_and_costs']['display']['days'],
257
 
258
  );
259
  } else {
260
  $custom_data[] = array(
261
+ 'key' => $general_data['total_hours'] ? $general_data['total_hours'] : esc_html__('Total Hours', 'redq-rental'),
262
  'display' => $meta['rental_days_and_costs']['display']['hours'],
263
 
264
  );
265
  }
266
 
267
+ if (!empty($meta['rental_days_and_costs']['due_payment'])) {
268
  $custom_data[] = array(
269
+ 'key' => $general_data['payment_due'] ? $general_data['payment_due'] : esc_html__('Due Payment', 'redq-rental'),
270
+ 'display' => wc_price($meta['rental_days_and_costs']['display']['due_payment']),
271
 
272
  );
273
  }
279
  return $meta;
280
  }
281
 
282
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_rental_and_booking', 20, 3);
283
  } // End if().
284
 
285
+ if (!function_exists('tinvwl_item_price_woocommerce_rental_and_booking')) {
286
 
287
  /**
288
  * Modify price for WooCommerce Rental & Bookings System
293
  *
294
  * @return string
295
  */
296
+ function tinvwl_item_price_woocommerce_rental_and_booking($price, $wl_product, $product)
297
+ {
298
+ if (!class_exists('RedQ_Rental_And_Bookings')) {
299
  return $price;
300
  }
301
 
302
  $product_type = $product->get_type();
303
 
304
+ if (isset($product_type) && $product_type === 'redq_rental') {
305
  $meta = $wl_product['meta'];
306
 
307
+ if (!empty($meta['quote_price'])) {
308
 
309
  $price = $meta['quote_price'];
310
 
311
+ return wc_price($price);
312
  }
313
  }
314
 
316
  return $price;
317
  }
318
 
319
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_rental_and_booking', 20, 3);
320
  } // End if().
integrations/woocommerce-square.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TI WooCommerce Wishlist integration with:
4
+ *
5
+ * @name WooCommerce Square
6
+ *
7
+ * @version 2.3.4
8
+ *
9
+ * @slug woocommerce-square
10
+ *
11
+ * @url https://woocommerce.com/products/square/
12
+ *
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-square";
24
+
25
+ $name = "WooCommerce Square";
26
+
27
+ $available = class_exists('WooCommerce_Square_Loader');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metaprepare_woocommerce_square')) {
43
+
44
+ /**
45
+ * Set description for meta WooCommerce Square
46
+ *
47
+ * @param array $meta Meta array.
48
+ * @param integer $product_id Product ID.
49
+ * @param integer $variation_id Product variation ID.
50
+ *
51
+ * @return array
52
+ */
53
+ function tinv_wishlist_metaprepare_woocommerce_square($meta, $product_id, $variation_id)
54
+ {
55
+
56
+ foreach (array_keys($meta) as $key) {
57
+ if (strpos($key, 'nds-pmd') === 0) {
58
+ unset($meta[$key]);
59
+ }
60
+ }
61
+
62
+ return $meta;
63
+ }
64
+
65
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metaprepare_woocommerce_square', 10, 3);
66
+ }
integrations/woocommerce-tm-extra-product-options.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @name WooCommerce TM Extra Product Options
6
  *
7
- * @version 5.0.12.1
8
  *
9
  * @slug woocommerce-tm-extra-product-options
10
  *
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce TM Extra Product Options
@@ -28,44 +50,45 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_
28
  *
29
  * @return array
30
  */
31
- function tinv_wishlist_metasupport_woocommerce_tm_extra_product_options( $meta, $product_id, $variation_id ) {
32
- if ( array_key_exists( 'tcaddtocart', $meta ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
33
- $api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
34
- $core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
35
- $version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
36
- $cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
37
-
38
- $has_epo = $api->has_options( $product_id );
39
- if ( $api->is_valid_options( $has_epo ) ) {
 
40
  $post_data = array();
41
- foreach ( $meta as $key => $value ) {
42
- $post_data[ $key ] = $value['display'];
43
  }
44
  $post_data['add-to-cart'] = $meta['tcaddtocart']['display'];
45
- $post_data['product_id'] = $product_id;
46
- if ( $variation_id ) {
47
  $post_data['variation_id'] = $variation_id;
48
  }
49
  $post_data['quantity'] = 1;
50
 
51
- $cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
52
 
53
- $cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $post_data );
54
- if ( 'normal' == $core->tm_epo_hide_options_in_cart && 'advanced' != $core->tm_epo_cart_field_display && ! empty( $cart_item['tmcartepo'] ) ) {
55
- $cart_item['quantity'] = 1;
56
- $cart_item['data'] = wc_get_product( $variation_id ? $variation_id : $product_id );
57
  $cart_item['tm_cart_item_key'] = '';
58
- $cart_item['product_id'] = $product_id;
59
- $item_data = $cart_class->get_item_data_array( array(), $cart_item );
60
 
61
- foreach ( $item_data as $key => $data ) {
62
  // Set hidden to true to not display meta on cart.
63
- if ( ! empty( $data['hidden'] ) ) {
64
- unset( $item_data[ $key ] );
65
  continue;
66
  }
67
- $item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
68
- $item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
69
  }
70
 
71
  return $item_data;
@@ -78,10 +101,128 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_
78
  return $meta;
79
  }
80
 
81
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options', 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  } // End if().
83
 
84
- if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options' ) ) {
85
 
86
  /**
87
  * Modify price for WooCommerce TM Extra Product Options
@@ -92,38 +233,39 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options'
92
  *
93
  * @return string
94
  */
95
- function tinvwl_item_price_woocommerce_tm_extra_product_options( $price, $wl_product, $product ) {
96
- if ( array_key_exists( 'tcaddtocart', (array) @$wl_product['meta'] ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
97
-
98
- $api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
99
- $core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
100
- $version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
101
- $cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
102
- if ( $core->tm_epo_hide_options_in_cart == 'normal' ) {
 
103
  $product_id = $wl_product['product_id'];
104
- $has_epo = $api->has_options( $product_id );
105
- if ( $api->is_valid_options( $has_epo ) ) {
106
 
107
- $cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
108
 
109
- $cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $wl_product['meta'] );
110
  $cart_item['quantity'] = 1;
111
- $cart_item['data'] = $product;
112
-
113
- $product_price = apply_filters( 'wc_epo_add_cart_item_original_price', $cart_item['data']->get_price(), $cart_item );
114
- if ( ! empty( $cart_item['tmcartepo'] ) ) {
115
- $to_currency = version_compare( $version, '4.9.0', '<' ) ? tc_get_woocommerce_currency() : themecomplete_get_woocommerce_currency();
116
- foreach ( $cart_item['tmcartepo'] as $value ) {
117
- if ( isset( $value['price_per_currency'] ) && array_key_exists( $to_currency, $value['price_per_currency'] ) ) {
118
- $value = floatval( $value['price_per_currency'][ $to_currency ] );
119
  $product_price += $value;
120
  } else {
121
- $product_price += floatval( $value['price'] );
122
  }
123
  }
124
  }
125
 
126
- $price = apply_filters( 'wc_tm_epo_ac_product_price', apply_filters( 'woocommerce_cart_item_price', $cart_class->get_price_for_cart( $product_price, $cart_item, '' ), $cart_item, '' ), '', $cart_item, $product, $product_id );
127
  }
128
  }
129
  }
@@ -131,20 +273,21 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options'
131
  return $price;
132
  }
133
 
134
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3 );
135
  } // End if().
136
 
137
- add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_tm_extra_product_options', 10, 3 );
138
 
139
- function tinvwl_meta_woocommerce_tm_extra_product_options( $meta, $post, $files ) {
 
140
 
141
- if ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) {
142
- foreach ( $files as $name => $file ) {
143
 
144
- if ( array_key_exists( $name, $meta ) ) {
145
- $upload = THEMECOMPLETE_EPO()->upload_file( $file );
146
- if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
147
- $meta[ $name ] = wc_clean( $upload['url'] );
148
  }
149
  }
150
  }
@@ -153,20 +296,21 @@ function tinvwl_meta_woocommerce_tm_extra_product_options( $meta, $post, $files
153
  return $meta;
154
  }
155
 
156
- add_filter( 'tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_tm_extra_product_options' );
157
 
158
- function tinvwl_cart_meta_woocommerce_tm_extra_product_options( $meta ) {
 
159
 
160
- if ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) {
161
 
162
  $files = $_FILES;
163
 
164
- foreach ( $files as $name => $file ) {
165
 
166
- if ( ! array_key_exists( $name, $meta ) ) {
167
- $upload = THEMECOMPLETE_EPO()->upload_file( $file );
168
- if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
169
- $meta[ $name ] = wc_clean( $upload['url'] );
170
  }
171
  }
172
  }
4
  *
5
  * @name WooCommerce TM Extra Product Options
6
  *
7
+ * @version 5.0.12.11
8
  *
9
  * @slug woocommerce-tm-extra-product-options
10
  *
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "woocommerce-tm-extra-product-options";
24
+
25
+ $name = "WooCommerce TM Extra Product Options";
26
+
27
+ $available = (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION'));
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_woocommerce_tm_extra_product_options')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce TM Extra Product Options
50
  *
51
  * @return array
52
  */
53
+ function tinv_wishlist_metasupport_woocommerce_tm_extra_product_options($meta, $product_id, $variation_id)
54
+ {
55
+ if (array_key_exists('tcaddtocart', $meta) && (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION'))) {
56
+ $api = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
57
+ $core = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO() : TM_EPO();
58
+ $version = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
59
+ $cart = defined('THEMECOMPLETE_EPO_VERSION') ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
60
+
61
+ $has_epo = $api->has_options($product_id);
62
+ if ($api->is_valid_options($has_epo)) {
63
  $post_data = array();
64
+ foreach ($meta as $key => $value) {
65
+ $post_data[$key] = $value['display'];
66
  }
67
  $post_data['add-to-cart'] = $meta['tcaddtocart']['display'];
68
+ $post_data['product_id'] = $product_id;
69
+ if ($variation_id) {
70
  $post_data['variation_id'] = $variation_id;
71
  }
72
  $post_data['quantity'] = 1;
73
 
74
+ $cart_class = version_compare($version, '4.8.0', '<') ? $core : $cart;
75
 
76
+ $cart_item = $cart_class->add_cart_item_data_helper(array(), $product_id, $post_data);
77
+ if ('normal' == $core->tm_epo_hide_options_in_cart && 'advanced' != $core->tm_epo_cart_field_display && !empty($cart_item['tmcartepo'])) {
78
+ $cart_item['quantity'] = 1;
79
+ $cart_item['data'] = wc_get_product($variation_id ? $variation_id : $product_id);
80
  $cart_item['tm_cart_item_key'] = '';
81
+ $cart_item['product_id'] = $product_id;
82
+ $item_data = $cart_class->get_item_data_array(array(), $cart_item);
83
 
84
+ foreach ($item_data as $key => $data) {
85
  // Set hidden to true to not display meta on cart.
86
+ if (!empty($data['hidden'])) {
87
+ unset($item_data[$key]);
88
  continue;
89
  }
90
+ $item_data[$key]['key'] = !empty($data['key']) ? $data['key'] : $data['name'];
91
+ $item_data[$key]['display'] = !empty($data['display']) ? $data['display'] : $data['value'];
92
  }
93
 
94
  return $item_data;
101
  return $meta;
102
  }
103
 
104
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options', 10, 3);
105
+ } // End if().
106
+
107
+ if (!function_exists('tinvwl_row_woocommerce_tm_extra_product_options')) {
108
+
109
+ /**
110
+ * Add rows for sub product for WooCommerce TM Extra Product Options
111
+ *
112
+ * @param array $wl_product Wishlist Product.
113
+ * @param \WC_Product_Composite $product Woocommerce Product.
114
+ */
115
+ function tinvwl_row_woocommerce_tm_extra_product_options($wl_product, $product)
116
+ {
117
+ if (isset($wl_product['meta']) && is_array($wl_product['meta']) && array_key_exists('tcaddtocart', $wl_product['meta']) && (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION'))) {
118
+ $api = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
119
+ $core = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO() : TM_EPO();
120
+
121
+ $has_epo = $api->has_options($product->get_id());
122
+
123
+ if ($api->is_valid_options($has_epo)) {
124
+ $cpf_price_array = $core->get_product_tm_epos($product->get_id(), TRUE, TRUE, TRUE);
125
+ if (empty($cpf_price_array)) {
126
+ return FALSE;
127
+ }
128
+ $global_price_array = $cpf_price_array['global'];
129
+
130
+ foreach ($global_price_array as $priorities) {
131
+ foreach ($priorities as $field) {
132
+ foreach ($field['sections'] as $section_id => $section) {
133
+ if (isset($section['elements'])) {
134
+ foreach ($section['elements'] as $element) {
135
+ if ('product' === $element['type']) {
136
+ $current_tmcp_post_fields = array_intersect_key($wl_product['meta'], array_flip(array($element['name_inc'])));
137
+ foreach ($current_tmcp_post_fields as $attribute => $key) {
138
+ if (isset($wl_product['meta'][$attribute . '_quantity'])) {
139
+ if (empty($wl_product['meta'][$attribute . '_quantity'])) {
140
+ continue;
141
+ }
142
+ }
143
+
144
+ $_product = wc_get_product($key);
145
+
146
+ $product_url = $_product->get_permalink();
147
+ $product_image = $_product->get_image();
148
+ $product_title = is_callable(array(
149
+ $_product,
150
+ 'get_name'
151
+ )) ? $_product->get_name() : $_product->get_title();
152
+
153
+ $product_price = '';
154
+
155
+ if ($element['priced_individually']) {
156
+ $product_price = $_product->get_price();
157
+ }
158
+
159
+ if ($element['discount']) {
160
+ $discount = wc_format_decimal((double)$element['discount'], wc_get_price_decimals());
161
+
162
+ if ($product_price && $element['discount']) {
163
+
164
+ $price = wc_format_decimal((double)$product_price, wc_get_price_decimals());
165
+
166
+ if ($element['discount_type'] == 'fixed') {
167
+ $product_price = max($price - $discount, 0);
168
+ } else {
169
+ $product_price = max($price * ((100 - $discount) / 100), 0);
170
+ }
171
+
172
+ }
173
+ }
174
+
175
+ $product_price = wc_price($product_price);
176
+
177
+ if ($_product->is_visible()) {
178
+ $product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
179
+ $product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
180
+ }
181
+ $product_title .= tinv_wishlist_get_item_data($_product, $wl_product);
182
+
183
+ $row_string = '<tr>';
184
+ $row_string .= ((!is_user_logged_in() || get_current_user_id() !== $wl_product['author']) ? ((!tinv_get_option('table', 'colm_checkbox')) ? '' : '<td colspan="1"></td>') : '<td colspan="' . ((!tinv_get_option('table', 'colm_checkbox')) ? '1' : '2') . '"></td>') . '&nbsp;';
185
+ $row_string .= ($element['show_image']) ? '<td class="product-thumbnail">%2$s</td>' : '<td class="product-thumbnail">&nbsp;</td>';
186
+
187
+ $row_string .= ($element['show_title']) ? '<td class="product-name">%1$s</td>' : '<td class="product-name">&nbsp;</td>';
188
+
189
+ if (tinv_get_option('product_table', 'colm_price')) {
190
+ $row_string .= ($product_price && $element['show_price'] && $element['priced_individually']) ? '<td class="product-price">%4$s &times; %6$s</td>' : '<td class="product-price">&times; %6$s</td>';
191
+ }
192
+ if (tinv_get_option('product_table', 'colm_date')) {
193
+ $row_string .= '<td class="product-date">&nbsp;</td>';
194
+ }
195
+ if (tinv_get_option('product_table', 'colm_stock')) {
196
+ $row_string .= '<td class="product-stock">%5$s</td>';
197
+ }
198
+ if (tinv_get_option('product_table', 'colm_quantity')) {
199
+ $row_string .= '<td class="product-quantity">&nbsp;</td>';
200
+ }
201
+ if (tinv_get_option('product_table', 'add_to_cart')) {
202
+ $row_string .= '<td class="product-action">&nbsp;</td>';
203
+ }
204
+ $row_string .= '</tr>';
205
+
206
+ echo sprintf($row_string, is_callable(array(
207
+ $_product,
208
+ 'get_name'
209
+ )) ? $_product->get_name() : $_product->get_title(), $product_image, $product_title, $product_price, '', $wl_product['meta'][$attribute . '_quantity']); // WPCS: xss ok.
210
+
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ } // End if().
218
+ }
219
+ }
220
+ }
221
+
222
+ add_action('tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_tm_extra_product_options', 10, 2);
223
  } // End if().
224
 
225
+ if (!function_exists('tinvwl_item_price_woocommerce_tm_extra_product_options')) {
226
 
227
  /**
228
  * Modify price for WooCommerce TM Extra Product Options
233
  *
234
  * @return string
235
  */
236
+ function tinvwl_item_price_woocommerce_tm_extra_product_options($price, $wl_product, $product)
237
+ {
238
+ if (array_key_exists('tcaddtocart', (array)@$wl_product['meta']) && (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION'))) {
239
+
240
+ $api = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
241
+ $core = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO() : TM_EPO();
242
+ $version = defined('THEMECOMPLETE_EPO_VERSION') ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
243
+ $cart = defined('THEMECOMPLETE_EPO_VERSION') ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
244
+ if ($core->tm_epo_hide_options_in_cart == 'normal') {
245
  $product_id = $wl_product['product_id'];
246
+ $has_epo = $api->has_options($product_id);
247
+ if ($api->is_valid_options($has_epo)) {
248
 
249
+ $cart_class = version_compare($version, '4.8.0', '<') ? $core : $cart;
250
 
251
+ $cart_item = $cart_class->add_cart_item_data_helper(array(), $product_id, $wl_product['meta']);
252
  $cart_item['quantity'] = 1;
253
+ $cart_item['data'] = $product;
254
+
255
+ $product_price = apply_filters('wc_epo_add_cart_item_original_price', $cart_item['data']->get_price(), $cart_item);
256
+ if (!empty($cart_item['tmcartepo'])) {
257
+ $to_currency = version_compare($version, '4.9.0', '<') ? tc_get_woocommerce_currency() : themecomplete_get_woocommerce_currency();
258
+ foreach ($cart_item['tmcartepo'] as $value) {
259
+ if (isset($value['price_per_currency']) && array_key_exists($to_currency, $value['price_per_currency'])) {
260
+ $value = floatval($value['price_per_currency'][$to_currency]);
261
  $product_price += $value;
262
  } else {
263
+ $product_price += floatval($value['price']);
264
  }
265
  }
266
  }
267
 
268
+ $price = apply_filters('wc_tm_epo_ac_product_price', apply_filters('woocommerce_cart_item_price', $cart_class->get_price_for_cart($product_price, $cart_item, ''), $cart_item, ''), '', $cart_item, $product, $product_id);
269
  }
270
  }
271
  }
273
  return $price;
274
  }
275
 
276
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3);
277
  } // End if().
278
 
279
+ add_filter('tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_tm_extra_product_options', 10, 3);
280
 
281
+ function tinvwl_meta_woocommerce_tm_extra_product_options($meta, $post, $files)
282
+ {
283
 
284
+ if (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION')) {
285
+ foreach ($files as $name => $file) {
286
 
287
+ if (array_key_exists($name, $meta)) {
288
+ $upload = THEMECOMPLETE_EPO()->upload_file($file);
289
+ if (empty($upload['error']) && !empty($upload['file'])) {
290
+ $meta[$name] = wc_clean($upload['url']);
291
  }
292
  }
293
  }
296
  return $meta;
297
  }
298
 
299
+ add_filter('tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_tm_extra_product_options');
300
 
301
+ function tinvwl_cart_meta_woocommerce_tm_extra_product_options($meta)
302
+ {
303
 
304
+ if (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION')) {
305
 
306
  $files = $_FILES;
307
 
308
+ foreach ($files as $name => $file) {
309
 
310
+ if (!array_key_exists($name, $meta)) {
311
+ $upload = THEMECOMPLETE_EPO()->upload_file($file);
312
+ if (empty($upload['error']) && !empty($upload['file'])) {
313
+ $meta[$name] = wc_clean($upload['url']);
314
  }
315
  }
316
  }
integrations/woocommerce-variation-swatches-and-photos.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- /**
3
- * TI WooCommerce Wishlist integration with:
4
- *
5
- * @name WooCommerce Variation Swatches and Photos
6
- *
7
- * @version 3.0.12
8
- *
9
- * @slug woocommerce-variation-swatches-and-photos
10
- *
11
- * @url https://woocommerce.com/products/variation-swatches-and-photos/
12
- *
13
- */
14
-
15
- // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
integrations/wp-fastest-cache.php CHANGED
@@ -13,76 +13,99 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_wp_fastest_cache_reject' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * Disable cache for WP Fastest Cache
23
  */
24
- function tinvwl_wp_fastest_cache_reject() {
25
- if ( defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
26
- $rules_json = get_option( 'WpFastestCacheExclude' );
 
27
 
28
- $ids = array(
29
- tinv_get_option( 'page', 'wishlist' ),
30
- tinv_get_option( 'page', 'manage' ),
31
  );
32
- $pages = $ids;
33
- $languages = apply_filters( 'wpml_active_languages', array(), array(
34
  'skip_missing' => 0,
35
- 'orderby' => 'code',
36
- ) );
37
- if ( ! empty( $languages ) ) {
38
- foreach ( $ids as $id ) {
39
- foreach ( $languages as $l ) {
40
- $pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
41
  }
42
  }
43
- $pages = array_unique( $pages );
44
  }
45
- $pages = array_filter( $pages );
46
- if ( ! empty( $pages ) ) {
47
- foreach ( $pages as $i => $page ) {
48
- $pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
49
  }
50
  }
51
- $pages = array_unique( $pages );
52
- $pages = array_filter( $pages );
53
 
54
- $rules_std = json_decode( $rules_json, true );
55
- $ex_pages = array();
56
- $rules_std = is_array( $rules_std ) ? $rules_std : array();
57
- foreach ( $rules_std as $value ) {
58
- $value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
59
- if ( 'page' === $value['type'] ) {
60
  $ex_pages[] = $value['content'];
61
  }
62
  }
63
- $ex_pages = array_unique( $ex_pages );
64
- $ex_pages = array_filter( $ex_pages );
65
- $changed = false;
66
 
67
- foreach ( $pages as $page ) {
68
- $page = preg_replace( '/\/$/', '', $page );
69
 
70
- if ( ! in_array( $page, $ex_pages ) ) {
71
- $changed = true;
72
  $rules_std[] = array(
73
- 'prefix' => 'startwith',
74
  'content' => $page,
75
- 'type' => 'page',
76
  );
77
  }
78
  }
79
- if ( $changed ) {
80
- $data = json_encode( $rules_std );
81
- update_option( 'WpFastestCacheExclude', $data );
82
  }
83
 
84
  } // End if().
85
  }
86
 
87
- add_action( 'admin_init', 'tinvwl_wp_fastest_cache_reject' );
88
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "wp-fastest-cache";
24
+
25
+ $name = "WP Fastest Cache";
26
+
27
+ $available = defined('WPFC_WP_PLUGIN_DIR');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_wp_fastest_cache_reject')) {
43
  /**
44
  * Disable cache for WP Fastest Cache
45
  */
46
+ function tinvwl_wp_fastest_cache_reject()
47
+ {
48
+ if (defined('WPFC_WP_PLUGIN_DIR')) {
49
+ $rules_json = get_option('WpFastestCacheExclude');
50
 
51
+ $ids = array(
52
+ tinv_get_option('page', 'wishlist'),
53
+ tinv_get_option('page', 'manage'),
54
  );
55
+ $pages = $ids;
56
+ $languages = apply_filters('wpml_active_languages', array(), array(
57
  'skip_missing' => 0,
58
+ 'orderby' => 'code',
59
+ ));
60
+ if (!empty($languages)) {
61
+ foreach ($ids as $id) {
62
+ foreach ($languages as $l) {
63
+ $pages[] = apply_filters('wpml_object_id', $id, 'page', true, $l['language_code']);
64
  }
65
  }
66
+ $pages = array_unique($pages);
67
  }
68
+ $pages = array_filter($pages);
69
+ if (!empty($pages)) {
70
+ foreach ($pages as $i => $page) {
71
+ $pages[$i] = preg_replace("/^\//", '', str_replace(get_site_url(), '', get_permalink($page))); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
72
  }
73
  }
74
+ $pages = array_unique($pages);
75
+ $pages = array_filter($pages);
76
 
77
+ $rules_std = json_decode($rules_json, true);
78
+ $ex_pages = array();
79
+ $rules_std = is_array($rules_std) ? $rules_std : array();
80
+ foreach ($rules_std as $value) {
81
+ $value['type'] = isset($value['type']) ? $value['type'] : 'page';
82
+ if ('page' === $value['type']) {
83
  $ex_pages[] = $value['content'];
84
  }
85
  }
86
+ $ex_pages = array_unique($ex_pages);
87
+ $ex_pages = array_filter($ex_pages);
88
+ $changed = false;
89
 
90
+ foreach ($pages as $page) {
91
+ $page = preg_replace('/\/$/', '', $page);
92
 
93
+ if (!in_array($page, $ex_pages)) {
94
+ $changed = true;
95
  $rules_std[] = array(
96
+ 'prefix' => 'startwith',
97
  'content' => $page,
98
+ 'type' => 'page',
99
  );
100
  }
101
  }
102
+ if ($changed) {
103
+ $data = json_encode($rules_std);
104
+ update_option('WpFastestCacheExclude', $data);
105
  }
106
 
107
  } // End if().
108
  }
109
 
110
+ add_action('admin_init', 'tinvwl_wp_fastest_cache_reject');
111
  } // End if().
integrations/wp-grid-builder.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( defined( 'WPGB_VERSION' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Add input, select, option to allowed wp_kses_post tags
@@ -27,23 +49,24 @@ if ( defined( 'WPGB_VERSION' ) ) {
27
  *
28
  * @return array
29
  */
30
- function tinvwl_wpkses_post_tags( $tags, $context ) {
31
- if ( 'post' === $context ) {
 
32
  // form fields - input
33
  $tags['input'] = array(
34
  'class' => array(),
35
- 'id' => array(),
36
- 'name' => array(),
37
  'value' => array(),
38
- 'type' => array(),
39
  );
40
  // select
41
  $tags['select'] = array(
42
  'class' => array(),
43
- 'id' => array(),
44
- 'name' => array(),
45
  'value' => array(),
46
- 'type' => array(),
47
  );
48
  // select options
49
  $tags['option'] = array(
@@ -54,45 +77,49 @@ if ( defined( 'WPGB_VERSION' ) ) {
54
  return $tags;
55
  }
56
 
57
- add_action( 'wp_grid_builder/card/wrapper_start', 'tinvwl_wpkses_fix' );
58
 
59
- function tinvwl_wpkses_fix() {
60
- add_filter( 'wp_kses_allowed_html', 'tinvwl_wpkses_post_tags', 10, 2 );
 
61
  }
62
 
63
- add_action( 'wp_grid_builder/card/wrapper_end', 'tinvwl_wpkses_fix_remove' );
64
 
65
- function tinvwl_wpkses_fix_remove() {
66
- remove_filter( 'wp_kses_allowed_html', 'tinvwl_wpkses_post_tags', 10, 2 );
 
67
  }
68
 
69
  // Add custom block to show wishlist button.
70
- function tinvwl_wpgb_block_add_to_wishlist( $blocks ) {
 
71
  $blocks['wishlist_button'] = array(
72
- 'name' => __( 'Wishlist Button', 'ti-woocommerce-wishlist' ),
73
  'render_callback' => 'tinvwl_wpgb_add_to_wishlist',
74
- 'icon' => TINVWL_URL . '/assets/img/heart-tinv.svg#tinv',
75
  );
76
 
77
  return $blocks;
78
  }
79
 
80
- add_filter( 'wp_grid_builder/blocks', 'tinvwl_wpgb_block_add_to_wishlist', 10, 1 );
81
 
82
  // Output wishlist button.
83
- function tinvwl_wpgb_add_to_wishlist() {
 
84
 
85
  $post = wpgb_get_post();
86
 
87
- if ( ! isset( $post->post_type ) && "product" !== $post->post_type ) {
88
  return;
89
  }
90
 
91
  global $product;
92
- $product = wc_get_product( $post->ID );
93
 
94
  // Output loop button.
95
- echo do_shortcode( '[ti_wishlists_addtowishlist product_id="' . $post->ID . '" loop="yes"]' );
96
  }
97
 
98
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "wp-grid-builder";
24
+
25
+ $name = "WP Grid Builder";
26
+
27
+ $available = defined('WPGB_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (defined('WPGB_VERSION')) {
43
 
44
  /**
45
  * Add input, select, option to allowed wp_kses_post tags
49
  *
50
  * @return array
51
  */
52
+ function tinvwl_wpkses_post_tags($tags, $context)
53
+ {
54
+ if ('post' === $context) {
55
  // form fields - input
56
  $tags['input'] = array(
57
  'class' => array(),
58
+ 'id' => array(),
59
+ 'name' => array(),
60
  'value' => array(),
61
+ 'type' => array(),
62
  );
63
  // select
64
  $tags['select'] = array(
65
  'class' => array(),
66
+ 'id' => array(),
67
+ 'name' => array(),
68
  'value' => array(),
69
+ 'type' => array(),
70
  );
71
  // select options
72
  $tags['option'] = array(
77
  return $tags;
78
  }
79
 
80
+ add_action('wp_grid_builder/card/wrapper_start', 'tinvwl_wpkses_fix');
81
 
82
+ function tinvwl_wpkses_fix()
83
+ {
84
+ add_filter('wp_kses_allowed_html', 'tinvwl_wpkses_post_tags', 10, 2);
85
  }
86
 
87
+ add_action('wp_grid_builder/card/wrapper_end', 'tinvwl_wpkses_fix_remove');
88
 
89
+ function tinvwl_wpkses_fix_remove()
90
+ {
91
+ remove_filter('wp_kses_allowed_html', 'tinvwl_wpkses_post_tags', 10, 2);
92
  }
93
 
94
  // Add custom block to show wishlist button.
95
+ function tinvwl_wpgb_block_add_to_wishlist($blocks)
96
+ {
97
  $blocks['wishlist_button'] = array(
98
+ 'name' => __('Wishlist Button', 'ti-woocommerce-wishlist'),
99
  'render_callback' => 'tinvwl_wpgb_add_to_wishlist',
100
+ 'icon' => TINVWL_URL . '/assets/img/heart-tinv.svg#tinv',
101
  );
102
 
103
  return $blocks;
104
  }
105
 
106
+ add_filter('wp_grid_builder/blocks', 'tinvwl_wpgb_block_add_to_wishlist', 10, 1);
107
 
108
  // Output wishlist button.
109
+ function tinvwl_wpgb_add_to_wishlist()
110
+ {
111
 
112
  $post = wpgb_get_post();
113
 
114
+ if (!isset($post->post_type) && "product" !== $post->post_type) {
115
  return;
116
  }
117
 
118
  global $product;
119
+ $product = wc_get_product($post->ID);
120
 
121
  // Output loop button.
122
+ echo do_shortcode('[ti_wishlists_addtowishlist product_id="' . $post->ID . '" loop="yes"]');
123
  }
124
 
125
  }
integrations/wp-multilang.php CHANGED
@@ -13,30 +13,52 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  // WP Multilang string translations.
21
- if ( function_exists( 'wpm_translate_string' ) ) {
22
 
23
- add_filter( 'tinvwl_default_wishlist_title', 'wpm_translate_string' );
24
- add_filter( 'tinvwl_view_wishlist_text', 'wpm_translate_string' );
25
- add_filter( 'tinvwl_added_to_wishlist_text', 'wpm_translate_string' );
26
- add_filter( 'tinvwl_already_in_wishlist_text', 'wpm_translate_string' );
27
- add_filter( 'tinvwl_removed_from_wishlist_text', 'wpm_translate_string' );
28
- add_filter( 'tinvwl_remove_from_wishlist_text', 'wpm_translate_string' );
29
 
30
- add_filter( 'tinvwl_added_to_wishlist_text_loop', 'wpm_translate_string' );
31
- add_filter( 'tinvwl_remove_from_wishlist_text_loop', 'wpm_translate_string' );
32
 
33
- add_filter( 'tinvwl_add_to_cart_text', 'wpm_translate_string' );
34
 
35
- add_filter( 'tinvwl_add_selected_to_cart_text', 'wpm_translate_string' );
36
- add_filter( 'tinvwl_add_all_to_cart_text', 'wpm_translate_string' );
37
 
38
- add_filter( 'tinvwl_share_on_text', 'wpm_translate_string' );
39
 
40
- add_filter( 'tinvwl_wishlist_products_counter_text', 'wpm_translate_string' );
41
 
42
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
+ }
19
+
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "wp-multilang";
24
+
25
+ $name = "WP Multilang";
26
+
27
+ $available = function_exists('wpm_translate_string');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
  }
41
 
42
  // WP Multilang string translations.
43
+ if (function_exists('wpm_translate_string')) {
44
 
45
+ add_filter('tinvwl_default_wishlist_title', 'wpm_translate_string');
46
+ add_filter('tinvwl_view_wishlist_text', 'wpm_translate_string');
47
+ add_filter('tinvwl_added_to_wishlist_text', 'wpm_translate_string');
48
+ add_filter('tinvwl_already_in_wishlist_text', 'wpm_translate_string');
49
+ add_filter('tinvwl_removed_from_wishlist_text', 'wpm_translate_string');
50
+ add_filter('tinvwl_remove_from_wishlist_text', 'wpm_translate_string');
51
 
52
+ add_filter('tinvwl_added_to_wishlist_text_loop', 'wpm_translate_string');
53
+ add_filter('tinvwl_remove_from_wishlist_text_loop', 'wpm_translate_string');
54
 
55
+ add_filter('tinvwl_add_to_cart_text', 'wpm_translate_string');
56
 
57
+ add_filter('tinvwl_add_selected_to_cart_text', 'wpm_translate_string');
58
+ add_filter('tinvwl_add_all_to_cart_text', 'wpm_translate_string');
59
 
60
+ add_filter('tinvwl_share_on_text', 'wpm_translate_string');
61
 
62
+ add_filter('tinvwl_wishlist_products_counter_text', 'wpm_translate_string');
63
 
64
  } // End if().
integrations/wp-rocket.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinvwl_rocket_cache_dynamic_cookies' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * Use dynamic cache with WP Rocket
23
  *
@@ -25,14 +47,15 @@ if ( ! function_exists( 'tinvwl_rocket_cache_dynamic_cookies' ) ) {
25
  *
26
  * @return array
27
  */
28
- function tinvwl_rocket_cache_dynamic_cookies( $cookies = array() ) {
 
29
  $cookies[] = 'tinv_wishlistkey';
30
 
31
  return $cookies;
32
  }
33
  }
34
 
35
- if ( ! function_exists( 'tinvwl_rocket_flush' ) ) {
36
  /**
37
  * Use dynamic cache with WP Rocket
38
  *
@@ -41,9 +64,10 @@ if ( ! function_exists( 'tinvwl_rocket_flush' ) ) {
41
  * @return array
42
  */
43
 
44
- function tinvwl_rocket_flush() {
45
- if ( ! function_exists( 'flush_rocket_htaccess' )
46
- || ! function_exists( 'rocket_generate_config_file' ) ) {
 
47
  return false;
48
  }
49
 
@@ -59,49 +83,51 @@ if ( ! function_exists( 'tinvwl_rocket_flush' ) ) {
59
  * Update WP Rocket config.
60
  *
61
  */
62
- function tivnwl_wp_rocket() {
63
- add_filter( 'rocket_cache_dynamic_cookies', 'tinvwl_rocket_cache_dynamic_cookies' );
64
- add_filter( 'rocket_htaccess_mod_rewrite', '__return_false' );
 
65
  tinvwl_rocket_flush();
66
  }
67
 
68
- add_action( 'tinvwl_flush_rewrite_rules', 'tivnwl_wp_rocket' );
69
- add_action( 'after_rocket_clean_domain', 'tivnwl_wp_rocket' );
70
 
71
- if ( defined( 'WP_ROCKET_VERSION' ) ) {
72
- add_action( 'tinvwl_product_added', 'tinvwl_rocket_clean_dynamic_cache' );
73
- add_action( 'tinvwl_product_updated', 'tinvwl_rocket_clean_dynamic_cache' );
74
- add_action( 'tinvwl_product_removed', 'tinvwl_rocket_clean_dynamic_cache' );
75
 
76
  /**
77
  * Clean dynamic cache on wishlist events.
78
  *
79
  */
80
- function tinvwl_rocket_clean_dynamic_cache() {
 
81
 
82
- $key = filter_input( INPUT_COOKIE, 'tinv_wishlistkey', FILTER_VALIDATE_REGEXP, array(
83
  'options' => array(
84
  'regexp' => '/^[A-Fa-f0-9]{6}$/',
85
  ),
86
- ) );
87
 
88
- if ( ! $key ) {
89
  return;
90
  }
91
 
92
  $urls = get_rocket_i18n_uri();
93
 
94
- if ( ! $urls ) {
95
  return;
96
  }
97
 
98
- foreach ( $urls as $url ) {
99
 
100
- $directories = glob( WP_ROCKET_CACHE_PATH . rocket_remove_url_protocol( $url ), GLOB_NOSORT );
101
 
102
- if ( $directories ) {
103
- foreach ( $directories as $dir ) {
104
- tinvwl_rocket_remove_dir( $dir, $key );
105
  }
106
  }
107
  }
@@ -112,42 +138,44 @@ if ( defined( 'WP_ROCKET_VERSION' ) ) {
112
  * Clean only dynamic key cache files.
113
  *
114
  */
115
- function tinvwl_rocket_remove_dir( $dir, $key ) {
116
- $dirs = glob( $dir . '/*', GLOB_NOSORT );
117
-
118
- if ( $dirs ) {
119
- foreach ( $dirs as $dir ) {
120
- if ( rocket_direct_filesystem()->is_dir( $dir ) ) {
121
- tinvwl_rocket_remove_dir( $dir, $key );
122
- } elseif ( strpos( $dir, $key ) !== false ) {
123
- rocket_direct_filesystem()->delete( $dir );
 
124
  }
125
  }
126
  }
127
  }
128
 
129
 
130
- add_action( 'init', 'tinvwl_rocket_empty_cart' );
131
 
132
  /**
133
  * Prevent cache WooCommerce cart fragments.
134
  *
135
  */
136
- function tinvwl_rocket_empty_cart() {
 
137
 
138
- if ( ( empty( $_COOKIE['woocommerce_cart_hash'] ) || empty( $_COOKIE['woocommerce_items_in_cart'] ) ) && apply_filters( 'tinvwl_rocket_disable_fragmetns_cache', true ) ) {
139
 
140
- $lang = function_exists( 'rocket_get_current_language' ) ? rocket_get_current_language() : false;
141
 
142
- if ( $lang ) {
143
- delete_transient( 'rocket_get_refreshed_fragments_cache_' . $lang );
144
  }
145
 
146
- delete_transient( 'rocket_get_refreshed_fragments_cache' );
147
  }
148
  }
149
 
150
- add_filter( 'nonce_user_logged_out', 'tinvwl_revert_uid_for_nonce_actions', 100, 2 );
151
 
152
  /**
153
  * Set $user_id to 0 for certain nonce actions.
@@ -165,13 +193,14 @@ if ( defined( 'WP_ROCKET_VERSION' ) ) {
165
  * @return int $uid ID of the nonce-owning user.
166
  *
167
  */
168
- function tinvwl_revert_uid_for_nonce_actions( $user_id, $action ) {
 
169
  // User ID is invalid.
170
- if ( empty( $user_id ) || 0 === $user_id ) {
171
  return $user_id;
172
  }
173
 
174
- if ( ! $action || 'wp_rest' !== $action ) {
175
  return $user_id;
176
  }
177
 
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "wp-rocket";
24
+
25
+ $name = "WP Rocket";
26
+
27
+ $available = defined('WP_ROCKET_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinvwl_rocket_cache_dynamic_cookies')) {
43
  /**
44
  * Use dynamic cache with WP Rocket
45
  *
47
  *
48
  * @return array
49
  */
50
+ function tinvwl_rocket_cache_dynamic_cookies($cookies = array())
51
+ {
52
  $cookies[] = 'tinv_wishlistkey';
53
 
54
  return $cookies;
55
  }
56
  }
57
 
58
+ if (!function_exists('tinvwl_rocket_flush')) {
59
  /**
60
  * Use dynamic cache with WP Rocket
61
  *
64
  * @return array
65
  */
66
 
67
+ function tinvwl_rocket_flush()
68
+ {
69
+ if (!function_exists('flush_rocket_htaccess')
70
+ || !function_exists('rocket_generate_config_file')) {
71
  return false;
72
  }
73
 
83
  * Update WP Rocket config.
84
  *
85
  */
86
+ function tivnwl_wp_rocket()
87
+ {
88
+ add_filter('rocket_cache_dynamic_cookies', 'tinvwl_rocket_cache_dynamic_cookies');
89
+ add_filter('rocket_htaccess_mod_rewrite', '__return_false');
90
  tinvwl_rocket_flush();
91
  }
92
 
93
+ add_action('tinvwl_flush_rewrite_rules', 'tivnwl_wp_rocket');
94
+ add_action('after_rocket_clean_domain', 'tivnwl_wp_rocket');
95
 
96
+ if (defined('WP_ROCKET_VERSION')) {
97
+ add_action('tinvwl_product_added', 'tinvwl_rocket_clean_dynamic_cache');
98
+ add_action('tinvwl_product_updated', 'tinvwl_rocket_clean_dynamic_cache');
99
+ add_action('tinvwl_product_removed', 'tinvwl_rocket_clean_dynamic_cache');
100
 
101
  /**
102
  * Clean dynamic cache on wishlist events.
103
  *
104
  */
105
+ function tinvwl_rocket_clean_dynamic_cache()
106
+ {
107
 
108
+ $key = filter_input(INPUT_COOKIE, 'tinv_wishlistkey', FILTER_VALIDATE_REGEXP, array(
109
  'options' => array(
110
  'regexp' => '/^[A-Fa-f0-9]{6}$/',
111
  ),
112
+ ));
113
 
114
+ if (!$key) {
115
  return;
116
  }
117
 
118
  $urls = get_rocket_i18n_uri();
119
 
120
+ if (!$urls) {
121
  return;
122
  }
123
 
124
+ foreach ($urls as $url) {
125
 
126
+ $directories = glob(WP_ROCKET_CACHE_PATH . rocket_remove_url_protocol($url), GLOB_NOSORT);
127
 
128
+ if ($directories) {
129
+ foreach ($directories as $dir) {
130
+ tinvwl_rocket_remove_dir($dir, $key);
131
  }
132
  }
133
  }
138
  * Clean only dynamic key cache files.
139
  *
140
  */
141
+ function tinvwl_rocket_remove_dir($dir, $key)
142
+ {
143
+ $dirs = glob($dir . '/*', GLOB_NOSORT);
144
+
145
+ if ($dirs) {
146
+ foreach ($dirs as $dir) {
147
+ if (rocket_direct_filesystem()->is_dir($dir)) {
148
+ tinvwl_rocket_remove_dir($dir, $key);
149
+ } elseif (strpos($dir, $key) !== false) {
150
+ rocket_direct_filesystem()->delete($dir);
151
  }
152
  }
153
  }
154
  }
155
 
156
 
157
+ add_action('init', 'tinvwl_rocket_empty_cart');
158
 
159
  /**
160
  * Prevent cache WooCommerce cart fragments.
161
  *
162
  */
163
+ function tinvwl_rocket_empty_cart()
164
+ {
165
 
166
+ if ((empty($_COOKIE['woocommerce_cart_hash']) || empty($_COOKIE['woocommerce_items_in_cart'])) && apply_filters('tinvwl_rocket_disable_fragmetns_cache', true)) {
167
 
168
+ $lang = function_exists('rocket_get_current_language') ? rocket_get_current_language() : false;
169
 
170
+ if ($lang) {
171
+ delete_transient('rocket_get_refreshed_fragments_cache_' . $lang);
172
  }
173
 
174
+ delete_transient('rocket_get_refreshed_fragments_cache');
175
  }
176
  }
177
 
178
+ add_filter('nonce_user_logged_out', 'tinvwl_revert_uid_for_nonce_actions', 100, 2);
179
 
180
  /**
181
  * Set $user_id to 0 for certain nonce actions.
193
  * @return int $uid ID of the nonce-owning user.
194
  *
195
  */
196
+ function tinvwl_revert_uid_for_nonce_actions($user_id, $action)
197
+ {
198
  // User ID is invalid.
199
+ if (empty($user_id) || 0 === $user_id) {
200
  return $user_id;
201
  }
202
 
203
+ if (!$action || 'wp_rest' !== $action) {
204
  return $user_id;
205
  }
206
 
integrations/wpc-variations-radio-buttons.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( defined( 'WOOVR_VERSION' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WPC Variations Radio Buttons for WooCommerce
@@ -29,11 +51,12 @@ if ( defined( 'WOOVR_VERSION' ) ) {
29
  * @return array
30
  */
31
 
32
- function tinv_wishlist_item_meta_wpc_variations_radio_buttons( $item_data, $product_id, $variation_id ) {
 
33
 
34
- foreach ( array_keys( $item_data ) as $key ) {
35
- if ( strpos( $key, 'woovr_' ) === 0 ) {
36
- unset( $item_data[ $key ] );
37
  }
38
  }
39
 
@@ -41,5 +64,5 @@ if ( defined( 'WOOVR_VERSION' ) ) {
41
  return $item_data;
42
  }
43
 
44
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_wpc_variations_radio_buttons', 10, 3 );
45
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "wpc-variations-radio-buttons";
24
+
25
+ $name = "WPC Variations Radio Buttons for WooCommerce";
26
+
27
+ $available = defined('WOOVR_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (defined('WOOVR_VERSION')) {
43
 
44
  /**
45
  * Set description for meta WPC Variations Radio Buttons for WooCommerce
51
  * @return array
52
  */
53
 
54
+ function tinv_wishlist_item_meta_wpc_variations_radio_buttons($item_data, $product_id, $variation_id)
55
+ {
56
 
57
+ foreach (array_keys($item_data) as $key) {
58
+ if (strpos($key, 'woovr_') === 0) {
59
+ unset($item_data[$key]);
60
  }
61
  }
62
 
64
  return $item_data;
65
  }
66
 
67
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_wpc_variations_radio_buttons', 10, 3);
68
  }
integrations/yith-woocommerce-product-add-ons.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta YITH WooCommerce Product Add-on
@@ -28,47 +50,48 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on
28
  *
29
  * @return array
30
  */
31
- function tinv_wishlist_item_meta_yith_woocommerce_product_add_on( $item_data, $product_id, $variation_id ) {
 
32
 
33
- if ( isset( $item_data['yith_wapo_is_single'] ) && class_exists( 'YITH_WAPO' ) ) {
34
- unset( $item_data['yith_wapo_is_single'] );
35
 
36
- $id = ( $variation_id ) ? $variation_id : $product_id;
37
 
38
- $base_product = wc_get_product( $id );
39
 
40
- if ( ( is_object( $base_product ) && get_option( 'yith_wapo_settings_show_product_price_cart' ) == 'yes' ) ) {
41
 
42
- $price = yit_get_display_price( $base_product );
43
 
44
- $price_html = wc_price( $price );
45
 
46
  $item_data[] = array(
47
- 'key' => __( 'Base price', 'ti-woocommerce-wishlist' ),
48
  'display' => $price_html,
49
  );
50
 
51
  }
52
- $type_list = YITH_WAPO_Type::getAllowedGroupTypes( $id );
53
 
54
- foreach ( $type_list as $single_type ) {
55
 
56
  $original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
57
 
58
- $value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ] : '';
59
 
60
- if ( ! $value || ! is_array( $value ) || ! isset( $value['display'] ) ) {
61
  $value = '';
62
- } elseif ( is_array( $value ) && isset( $value['display'] ) && ! ctype_digit( strval( $value['display'][0] ) ) ) {
63
  $value = $value['display'][0];
64
  } else {
65
- $value = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, $value['display'][0], 'label' );
66
  }
67
 
68
- unset( $item_data[ $original_data ] );
69
- if ( $value ) {
70
  $item_data[] = array(
71
- 'key' => $single_type->label,
72
  'display' => $value,
73
  );
74
  }
@@ -80,10 +103,10 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on
80
  return $item_data;
81
  }
82
 
83
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on', 10, 3 );
84
  } // End if().
85
 
86
- if ( ! function_exists( 'tinvwl_item_price_yith_woocommerce_product_add_on' ) ) {
87
 
88
  /**
89
  * Modify price for YITH WooCommerce product Addons.
@@ -94,41 +117,42 @@ if ( ! function_exists( 'tinvwl_item_price_yith_woocommerce_product_add_on' ) )
94
  *
95
  * @return string
96
  */
97
- function tinvwl_item_price_yith_woocommerce_product_add_on( $price, $wl_product, $product ) {
 
98
 
99
- if ( class_exists( 'YITH_WAPO' ) ) {
100
 
101
- $type_list = YITH_WAPO_Type::getAllowedGroupTypes( $product->get_id() );
102
 
103
- if ( $type_list ) {
104
 
105
  $addons_total = 0;
106
 
107
- foreach ( $type_list as $single_type ) {
108
 
109
  $original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
110
 
111
- $value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
112
 
113
 
114
- if ( ! is_array( $value ) || ! ctype_digit( strval( $value[0] ) ) ) {
115
  continue;
116
  }
117
 
118
- $addon_price = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, $value[0], 'price' );
119
 
120
- if ( is_numeric( $addon_price ) ) {
121
  $addons_total += $addon_price;
122
  }
123
 
124
  }
125
 
126
- $price = wc_price( $product->get_price() + $addons_total );
127
  }
128
  }
129
 
130
  return $price;
131
  }
132
 
133
- add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_yith_woocommerce_product_add_on', 10, 3 );
134
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "yith-woocommerce-product-add-ons";
24
+
25
+ $name = "YITH WooCommerce Product Add-Ons";
26
+
27
+ $available = class_exists('YITH_WAPO');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_item_meta_yith_woocommerce_product_add_on')) {
43
 
44
  /**
45
  * Set description for meta YITH WooCommerce Product Add-on
50
  *
51
  * @return array
52
  */
53
+ function tinv_wishlist_item_meta_yith_woocommerce_product_add_on($item_data, $product_id, $variation_id)
54
+ {
55
 
56
+ if (isset($item_data['yith_wapo_is_single']) && class_exists('YITH_WAPO')) {
57
+ unset($item_data['yith_wapo_is_single']);
58
 
59
+ $id = ($variation_id) ? $variation_id : $product_id;
60
 
61
+ $base_product = wc_get_product($id);
62
 
63
+ if ((is_object($base_product) && get_option('yith_wapo_settings_show_product_price_cart') == 'yes')) {
64
 
65
+ $price = yit_get_display_price($base_product);
66
 
67
+ $price_html = wc_price($price);
68
 
69
  $item_data[] = array(
70
+ 'key' => __('Base price', 'ti-woocommerce-wishlist'),
71
  'display' => $price_html,
72
  );
73
 
74
  }
75
+ $type_list = YITH_WAPO_Type::getAllowedGroupTypes($id);
76
 
77
+ foreach ($type_list as $single_type) {
78
 
79
  $original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
80
 
81
+ $value = isset($item_data[$original_data]) ? $item_data[$original_data] : '';
82
 
83
+ if (!$value || !is_array($value) || !isset($value['display'])) {
84
  $value = '';
85
+ } elseif (is_array($value) && isset($value['display']) && !ctype_digit(strval($value['display'][0]))) {
86
  $value = $value['display'][0];
87
  } else {
88
+ $value = YITH_WAPO_Option::getOptionDataByValueKey($single_type, $value['display'][0], 'label');
89
  }
90
 
91
+ unset($item_data[$original_data]);
92
+ if ($value) {
93
  $item_data[] = array(
94
+ 'key' => $single_type->label,
95
  'display' => $value,
96
  );
97
  }
103
  return $item_data;
104
  }
105
 
106
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on', 10, 3);
107
  } // End if().
108
 
109
+ if (!function_exists('tinvwl_item_price_yith_woocommerce_product_add_on')) {
110
 
111
  /**
112
  * Modify price for YITH WooCommerce product Addons.
117
  *
118
  * @return string
119
  */
120
+ function tinvwl_item_price_yith_woocommerce_product_add_on($price, $wl_product, $product)
121
+ {
122
 
123
+ if (class_exists('YITH_WAPO')) {
124
 
125
+ $type_list = YITH_WAPO_Type::getAllowedGroupTypes($product->get_id());
126
 
127
+ if ($type_list) {
128
 
129
  $addons_total = 0;
130
 
131
+ foreach ($type_list as $single_type) {
132
 
133
  $original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
134
 
135
+ $value = isset($wl_product['meta'][$original_data]) ? $wl_product['meta'][$original_data] : '';
136
 
137
 
138
+ if (!is_array($value) || !ctype_digit(strval($value[0]))) {
139
  continue;
140
  }
141
 
142
+ $addon_price = YITH_WAPO_Option::getOptionDataByValueKey($single_type, $value[0], 'price');
143
 
144
+ if (is_numeric($addon_price)) {
145
  $addons_total += $addon_price;
146
  }
147
 
148
  }
149
 
150
+ $price = wc_price($product->get_price() + $addons_total);
151
  }
152
  }
153
 
154
  return $price;
155
  }
156
 
157
+ add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_yith_woocommerce_product_add_on', 10, 3);
158
  } // End if().
integrations/yith-woocommerce-product-bundles.php CHANGED
@@ -13,11 +13,33 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( ! function_exists( 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  /**
23
  * Set description for meta WooCommerce Mix and Match
@@ -27,10 +49,11 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_yith_woocommerce_product_bund
27
  *
28
  * @return array
29
  */
30
- function tinv_wishlist_metasupport_yith_woocommerce_product_bundles( $meta, $product_id ) {
31
- if ( array_key_exists( 'yith_bundle_quantity_1', $meta ) ) {
32
- $product = wc_get_product( $product_id );
33
- if ( is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
 
34
  $meta = array();
35
  }
36
  }
@@ -38,10 +61,10 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_yith_woocommerce_product_bund
38
  return $meta;
39
  }
40
 
41
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles', 10, 2 );
42
  } // End if().
43
 
44
- if ( ! function_exists( 'tinvwl_item_status_yith_woocommerce_product_bundles' ) ) {
45
 
46
  /**
47
  * Modify status for YITH WooCommerce Product Bundles
@@ -53,37 +76,38 @@ if ( ! function_exists( 'tinvwl_item_status_yith_woocommerce_product_bundles' )
53
  *
54
  * @return string
55
  */
56
- function tinvwl_item_status_yith_woocommerce_product_bundles( $availability_html, $availability, $wl_product, $product ) {
57
- if ( empty( $availability ) && is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
58
- $response = true;
 
59
  $bundled_items = $product->get_bundled_items();
60
- foreach ( $bundled_items as $key => $bundled_item ) {
61
- if ( method_exists( $bundled_item, 'is_optional' ) ) {
62
- if ( $bundled_item->is_optional() && ! array_key_exists( 'yith_bundle_optional_' . $key, $wl_product['meta'] ) ) {
63
  continue;
64
  }
65
  }
66
- if ( ! $bundled_item->get_product()->is_in_stock() ) {
67
  $response = false;
68
  }
69
  }
70
 
71
- if ( ! $response ) {
72
- $availability = array(
73
- 'class' => 'out-of-stock',
74
- 'availability' => __( 'Out of stock', 'ti-woocommerce-wishlist' ),
75
  );
76
- $availability_html = '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
77
  }
78
  }
79
 
80
  return $availability_html;
81
  }
82
 
83
- add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_yith_woocommerce_product_bundles', 10, 4 );
84
  } // End if().
85
 
86
- if ( ! function_exists( 'tinvwl_row_yith_woocommerce_product_bundles' ) ) {
87
 
88
  /**
89
  * Add rows for sub product for YITH WooCommerce Product Bundles
@@ -91,72 +115,73 @@ if ( ! function_exists( 'tinvwl_row_yith_woocommerce_product_bundles' ) ) {
91
  * @param array $wl_product Wishlist Product.
92
  * @param \WC_Product $product Woocommerce Product.
93
  */
94
- function tinvwl_row_yith_woocommerce_product_bundles( $wl_product, $product ) {
95
- if ( is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
96
- $bundled_items = $product->get_bundled_items();
 
97
  $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
98
- if ( ! empty( $bundled_items ) ) {
99
- foreach ( $bundled_items as $key => $bundled_item ) {
100
  $item_quantity = $bundled_item->get_quantity();
101
- if ( array_key_exists( 'yith_bundle_quantity_' . $key, $wl_product['meta'] ) ) {
102
- $item_quantity = absint( $wl_product['meta'][ 'yith_bundle_quantity_' . $key ] );
103
  }
104
- if ( method_exists( $bundled_item, 'is_optional' ) ) {
105
- if ( $bundled_item->is_optional() && ! array_key_exists( 'yith_bundle_optional_' . $key, $wl_product['meta'] ) ) {
106
  $item_quantity = 0;
107
  }
108
  }
109
- if ( 0 >= $item_quantity ) {
110
  continue;
111
  }
112
 
113
  $product = $bundled_item->get_product();
114
- if ( ! is_object( $product ) ) {
115
  continue;
116
  }
117
 
118
- $product_url = $product->get_permalink();
119
  $product_image = $product->get_image();
120
- $product_title = is_callable( array(
121
  $product,
122
  'get_name'
123
- ) ) ? $product->get_name() : $product->get_title();
124
  $product_price = $product->get_price_html();
125
- if ( $product->is_visible() ) {
126
- $product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
127
- $product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
128
  }
129
- $product_title .= tinv_wishlist_get_item_data( $product, $wl_product );
130
 
131
- $availability = (array) $product->get_availability();
132
- if ( ! array_key_exists( 'availability', $availability ) ) {
133
  $availability['availability'] = '';
134
  }
135
- if ( ! array_key_exists( 'class', $availability ) ) {
136
  $availability['class'] = '';
137
  }
138
- $availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
139
- $row_string = '<tr>';
140
- $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
141
- if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
142
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
143
  }
144
- if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
145
  $row_string .= '<td class="product-date">&nbsp;</td>';
146
  }
147
- if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
148
  $row_string .= '<td class="product-stock">%4$s</td>';
149
  }
150
- if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
151
  $row_string .= '<td class="product-action">&nbsp;</td>';
152
  }
153
  $row_string .= '</tr>';
154
 
155
- echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
156
  } // End foreach().
157
  } // End if().
158
  } // End if().
159
  }
160
 
161
- add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_yith_woocommerce_product_bundles', 10, 2 );
162
  } // End if().
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
+
23
+ $slug = "yith-woocommerce-product-bundles";
24
+
25
+ $name = "YITH WooCommerce Product Bundles";
26
+
27
+ $available = defined('YITH_WCPB_VERSION');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (!function_exists('tinv_wishlist_metasupport_yith_woocommerce_product_bundles')) {
43
 
44
  /**
45
  * Set description for meta WooCommerce Mix and Match
49
  *
50
  * @return array
51
  */
52
+ function tinv_wishlist_metasupport_yith_woocommerce_product_bundles($meta, $product_id)
53
+ {
54
+ if (array_key_exists('yith_bundle_quantity_1', $meta)) {
55
+ $product = wc_get_product($product_id);
56
+ if (is_object($product) && $product->is_type('yith_bundle')) {
57
  $meta = array();
58
  }
59
  }
61
  return $meta;
62
  }
63
 
64
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles', 10, 2);
65
  } // End if().
66
 
67
+ if (!function_exists('tinvwl_item_status_yith_woocommerce_product_bundles')) {
68
 
69
  /**
70
  * Modify status for YITH WooCommerce Product Bundles
76
  *
77
  * @return string
78
  */
79
+ function tinvwl_item_status_yith_woocommerce_product_bundles($availability_html, $availability, $wl_product, $product)
80
+ {
81
+ if (empty($availability) && is_object($product) && $product->is_type('yith_bundle')) {
82
+ $response = true;
83
  $bundled_items = $product->get_bundled_items();
84
+ foreach ($bundled_items as $key => $bundled_item) {
85
+ if (method_exists($bundled_item, 'is_optional')) {
86
+ if ($bundled_item->is_optional() && !array_key_exists('yith_bundle_optional_' . $key, $wl_product['meta'])) {
87
  continue;
88
  }
89
  }
90
+ if (!$bundled_item->get_product()->is_in_stock()) {
91
  $response = false;
92
  }
93
  }
94
 
95
+ if (!$response) {
96
+ $availability = array(
97
+ 'class' => 'out-of-stock',
98
+ 'availability' => __('Out of stock', 'ti-woocommerce-wishlist'),
99
  );
100
+ $availability_html = '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html($availability['availability']) . '</span></p>';
101
  }
102
  }
103
 
104
  return $availability_html;
105
  }
106
 
107
+ add_filter('tinvwl_wishlist_item_status', 'tinvwl_item_status_yith_woocommerce_product_bundles', 10, 4);
108
  } // End if().
109
 
110
+ if (!function_exists('tinvwl_row_yith_woocommerce_product_bundles')) {
111
 
112
  /**
113
  * Add rows for sub product for YITH WooCommerce Product Bundles
115
  * @param array $wl_product Wishlist Product.
116
  * @param \WC_Product $product Woocommerce Product.
117
  */
118
+ function tinvwl_row_yith_woocommerce_product_bundles($wl_product, $product)
119
+ {
120
+ if (is_object($product) && $product->is_type('yith_bundle')) {
121
+ $bundled_items = $product->get_bundled_items();
122
  $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
123
+ if (!empty($bundled_items)) {
124
+ foreach ($bundled_items as $key => $bundled_item) {
125
  $item_quantity = $bundled_item->get_quantity();
126
+ if (array_key_exists('yith_bundle_quantity_' . $key, $wl_product['meta'])) {
127
+ $item_quantity = absint($wl_product['meta']['yith_bundle_quantity_' . $key]);
128
  }
129
+ if (method_exists($bundled_item, 'is_optional')) {
130
+ if ($bundled_item->is_optional() && !array_key_exists('yith_bundle_optional_' . $key, $wl_product['meta'])) {
131
  $item_quantity = 0;
132
  }
133
  }
134
+ if (0 >= $item_quantity) {
135
  continue;
136
  }
137
 
138
  $product = $bundled_item->get_product();
139
+ if (!is_object($product)) {
140
  continue;
141
  }
142
 
143
+ $product_url = $product->get_permalink();
144
  $product_image = $product->get_image();
145
+ $product_title = is_callable(array(
146
  $product,
147
  'get_name'
148
+ )) ? $product->get_name() : $product->get_title();
149
  $product_price = $product->get_price_html();
150
+ if ($product->is_visible()) {
151
+ $product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
152
+ $product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
153
  }
154
+ $product_title .= tinv_wishlist_get_item_data($product, $wl_product);
155
 
156
+ $availability = (array)$product->get_availability();
157
+ if (!array_key_exists('availability', $availability)) {
158
  $availability['availability'] = '';
159
  }
160
+ if (!array_key_exists('class', $availability)) {
161
  $availability['class'] = '';
162
  }
163
+ $availability_html = empty($availability['availability']) ? '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-check"></i></span><span class="tinvwl-txt">' . esc_html__('In stock', 'ti-woocommerce-wishlist') . '</span></p>' : '<p class="stock ' . esc_attr($availability['class']) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html($availability['availability']) . '</span></p>';
164
+ $row_string = '<tr>';
165
+ $row_string .= '<td colspan="2">&nbsp;</td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
166
+ if (tinv_get_option('product_table', 'colm_price')) {
167
  $row_string .= '<td class="product-price">%3$s &times; %5$s</td>';
168
  }
169
+ if (tinv_get_option('product_table', 'colm_date')) {
170
  $row_string .= '<td class="product-date">&nbsp;</td>';
171
  }
172
+ if (tinv_get_option('product_table', 'colm_stock')) {
173
  $row_string .= '<td class="product-stock">%4$s</td>';
174
  }
175
+ if (tinv_get_option('product_table', 'add_to_cart')) {
176
  $row_string .= '<td class="product-action">&nbsp;</td>';
177
  }
178
  $row_string .= '</tr>';
179
 
180
+ echo sprintf($row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity); // WPCS: xss ok.
181
  } // End foreach().
182
  } // End if().
183
  } // End if().
184
  }
185
 
186
+ add_action('tinvwl_wishlist_row_after', 'tinvwl_row_yith_woocommerce_product_bundles', 10, 2);
187
  } // End if().
integrations/yith-woocommerce-quick-view.php CHANGED
@@ -13,13 +13,35 @@
13
  */
14
 
15
  // If this file is called directly, abort.
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- die;
18
  }
19
 
20
- if ( defined( 'YITH_WCQV' ) ) {
 
21
 
22
- if ( ! function_exists( 'tinv_wishlist_meta_support_yith_wcqv' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  /**
25
  * Clear custom meta
@@ -28,18 +50,19 @@ if ( defined( 'YITH_WCQV' ) ) {
28
  *
29
  * @return array
30
  */
31
- function tinv_wishlist_meta_support_yith_wcqv( $meta ) {
 
32
 
33
- foreach ( $meta as $k => $v ) {
34
  $prefix = 'yith_';
35
- if ( 0 === strpos( $k, $prefix ) ) {
36
- unset( $meta[ $k ] );
37
  }
38
  }
39
 
40
  return $meta;
41
  }
42
 
43
- add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_yith_wcqv' );
44
  } // End if().
45
  }
13
  */
14
 
15
  // If this file is called directly, abort.
16
+ if (!defined('ABSPATH')) {
17
+ exit;
18
  }
19
 
20
+ // Load integration depends on current settings.
21
+ global $integrations;
22
 
23
+ $slug = "yith-woocommerce-quick-view";
24
+
25
+ $name = "YITH WooCommerce Quick View";
26
+
27
+ $available = defined('YITH_WCQV');
28
+
29
+ $integrations[$slug] = array(
30
+ 'name' => $name,
31
+ 'available' => $available,
32
+ );
33
+
34
+ if (!tinv_get_option('integrations', $slug)) {
35
+ return;
36
+ }
37
+
38
+ if (!$available) {
39
+ return;
40
+ }
41
+
42
+ if (defined('YITH_WCQV')) {
43
+
44
+ if (!function_exists('tinv_wishlist_meta_support_yith_wcqv')) {
45
 
46
  /**
47
  * Clear custom meta
50
  *
51
  * @return array
52
  */
53
+ function tinv_wishlist_meta_support_yith_wcqv($meta)
54
+ {
55
 
56
+ foreach ($meta as $k => $v) {
57
  $prefix = 'yith_';
58
+ if (0 === strpos($k, $prefix)) {
59
+ unset($meta[$k]);
60
  }
61
  }
62
 
63
  return $meta;
64
  }
65
 
66
+ add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_yith_wcqv');
67
  } // End if().
68
  }
languages/ti-woocommerce-wishlist.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2021 TI WooCommerce Wishlist Plugin - 1.23.10
2
- # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.23.10 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.23.10\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
@@ -32,7 +32,7 @@ msgstr ""
32
  msgid "Template Custom CSS"
33
  msgstr ""
34
 
35
- #: admin/basestyle.helper.php:115, admin/settings/general.class.php:885
36
  msgid "Save Settings"
37
  msgstr ""
38
 
@@ -40,7 +40,7 @@ msgstr ""
40
  msgid "Reset"
41
  msgstr ""
42
 
43
- #: admin/basestyle.helper.php:127, admin/settings/general.class.php:897
44
  msgid "Save"
45
  msgstr ""
46
 
@@ -492,6 +492,22 @@ msgstr ""
492
  msgid "Disable support chat"
493
  msgstr ""
494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  #: admin/settings/settings.class.php:56
496
  msgid "Export/Import Settings"
497
  msgstr ""
@@ -920,7 +936,7 @@ msgstr ""
920
  msgid "Page Setup"
921
  msgstr ""
922
 
923
- #: includes/wizard.class.php:295, includes/wizard.class.php:326, integrations/theme-flatsome.php:99, public/tinvwl.class.php:671
924
  msgid "Wishlist"
925
  msgstr ""
926
 
@@ -1000,87 +1016,87 @@ msgstr ""
1000
  msgid "If checked the trigger will fire only once for each customer for each wishlist they create. Most customers only use the one wishlist so use with caution. Setting a high Reminder interval may be a better plan."
1001
  msgstr ""
1002
 
1003
- #: integrations/gift-cards-for-woocommerce.php:92
1004
  msgid "Note"
1005
  msgstr ""
1006
 
1007
- #: integrations/gift-cards-for-woocommerce.php:95
1008
  msgid "To"
1009
  msgstr ""
1010
 
1011
- #: integrations/gift-cards-for-woocommerce.php:98
1012
  msgid "To Email"
1013
  msgstr ""
1014
 
1015
- #: integrations/gift-cards-for-woocommerce.php:101
1016
  msgid "Address"
1017
  msgstr ""
1018
 
1019
- #: integrations/gift-cards-for-woocommerce.php:104
1020
  msgid "Reload existing Gift Card"
1021
  msgstr ""
1022
 
1023
- #: integrations/mycred.php:30
1024
  msgid "WooCommerce Wishlist"
1025
  msgstr ""
1026
 
1027
- #: integrations/mycred.php:31
1028
  msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
1029
  msgstr ""
1030
 
1031
- #: integrations/mycred.php:177
1032
  msgid "Adding Product to Wishlist"
1033
  msgstr ""
1034
 
1035
- #: integrations/mycred.php:182, integrations/mycred.php:227
1036
  msgid "Points"
1037
  msgstr ""
1038
 
1039
- #: integrations/mycred.php:195, integrations/mycred.php:240
1040
  msgid "Limit"
1041
  msgstr ""
1042
 
1043
- #: integrations/mycred.php:208, integrations/mycred.php:253
1044
  msgid "Log Template"
1045
  msgstr ""
1046
 
1047
- #: integrations/mycred.php:212, integrations/mycred.php:257
1048
  msgid "required"
1049
  msgstr ""
1050
 
1051
- #: integrations/mycred.php:222
1052
  msgid "Purchasing Product from Wishlist"
1053
  msgstr ""
1054
 
1055
- #: integrations/mycred.php:308
1056
  msgid "Purchased From Wishlist"
1057
  msgstr ""
1058
 
1059
- #: integrations/mycred.php:309
1060
  msgid "Added To Wishlist"
1061
  msgstr ""
1062
 
1063
- #: integrations/product-extras-for-woocommerce.php:69
1064
  msgid "Flat rate cost"
1065
  msgstr ""
1066
 
1067
- #: integrations/woo-product-bundle.php:89, integrations/woocommerce-composite-products.php:116, integrations/woocommerce-mix-and-match-products.php:86, integrations/woocommerce-product-bundles.php:110, integrations/yith-woocommerce-product-bundles.php:138, templates/ti-wishlist-user.php:145, templates/ti-wishlist.php:153
1068
  msgid "In stock"
1069
  msgstr ""
1070
 
1071
- #: integrations/woocommerce-gravityforms-product-addons.php:43
1072
  msgid "Select options"
1073
  msgstr ""
1074
 
1075
- #: integrations/wp-grid-builder.php:72
1076
  msgid "Wishlist Button"
1077
  msgstr ""
1078
 
1079
- #: integrations/yith-woocommerce-product-add-ons.php:47
1080
  msgid "Base price"
1081
  msgstr ""
1082
 
1083
- #: integrations/yith-woocommerce-product-bundles.php:74
1084
  msgid "Out of stock"
1085
  msgstr ""
1086
 
@@ -1096,19 +1112,19 @@ msgstr ""
1096
  msgid "Something went wrong"
1097
  msgstr ""
1098
 
1099
- #: public/tinvwl.class.php:535
1100
  msgid "Create New"
1101
  msgstr ""
1102
 
1103
- #: public/tinvwl.class.php:539
1104
  msgid "Please select some product options before adding this product to your wishlist."
1105
  msgstr ""
1106
 
1107
- #: public/tinvwl.class.php:540
1108
  msgid "No items or actions are selected."
1109
  msgstr ""
1110
 
1111
- #: public/tinvwl.class.php:541
1112
  msgid "Copied!"
1113
  msgstr ""
1114
 
1
+ # Copyright (C) 2021 TI WooCommerce Wishlist Plugin - 1.24.0
2
+ # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.24.0 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.24.0\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
32
  msgid "Template Custom CSS"
33
  msgstr ""
34
 
35
+ #: admin/basestyle.helper.php:115, admin/settings/general.class.php:885, admin/settings/integrations.class.php:113
36
  msgid "Save Settings"
37
  msgstr ""
38
 
40
  msgid "Reset"
41
  msgstr ""
42
 
43
+ #: admin/basestyle.helper.php:127, admin/settings/general.class.php:897, admin/settings/integrations.class.php:119
44
  msgid "Save"
45
  msgstr ""
46
 
492
  msgid "Disable support chat"
493
  msgstr ""
494
 
495
+ #: admin/settings/integrations.class.php:59
496
+ msgid "Integrations"
497
+ msgstr ""
498
+
499
+ #: admin/settings/integrations.class.php:60
500
+ msgid "Wishlist Integrations with 3rd party plugins and themes"
501
+ msgstr ""
502
+
503
+ #: admin/settings/integrations.class.php:95
504
+ msgid "Available Integrations"
505
+ msgstr ""
506
+
507
+ #: admin/settings/integrations.class.php:98
508
+ msgid "You can disable built-in integrations with 3rd party plugins and themes."
509
+ msgstr ""
510
+
511
  #: admin/settings/settings.class.php:56
512
  msgid "Export/Import Settings"
513
  msgstr ""
936
  msgid "Page Setup"
937
  msgstr ""
938
 
939
+ #: includes/wizard.class.php:295, includes/wizard.class.php:326, integrations/theme-flatsome.php:122, public/tinvwl.class.php:683
940
  msgid "Wishlist"
941
  msgstr ""
942
 
1016
  msgid "If checked the trigger will fire only once for each customer for each wishlist they create. Most customers only use the one wishlist so use with caution. Setting a high Reminder interval may be a better plan."
1017
  msgstr ""
1018
 
1019
+ #: integrations/gift-cards-for-woocommerce.php:117
1020
  msgid "Note"
1021
  msgstr ""
1022
 
1023
+ #: integrations/gift-cards-for-woocommerce.php:120
1024
  msgid "To"
1025
  msgstr ""
1026
 
1027
+ #: integrations/gift-cards-for-woocommerce.php:123
1028
  msgid "To Email"
1029
  msgstr ""
1030
 
1031
+ #: integrations/gift-cards-for-woocommerce.php:126
1032
  msgid "Address"
1033
  msgstr ""
1034
 
1035
+ #: integrations/gift-cards-for-woocommerce.php:129
1036
  msgid "Reload existing Gift Card"
1037
  msgstr ""
1038
 
1039
+ #: integrations/mycred.php:53
1040
  msgid "WooCommerce Wishlist"
1041
  msgstr ""
1042
 
1043
+ #: integrations/mycred.php:54
1044
  msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
1045
  msgstr ""
1046
 
1047
+ #: integrations/mycred.php:207
1048
  msgid "Adding Product to Wishlist"
1049
  msgstr ""
1050
 
1051
+ #: integrations/mycred.php:212, integrations/mycred.php:257
1052
  msgid "Points"
1053
  msgstr ""
1054
 
1055
+ #: integrations/mycred.php:225, integrations/mycred.php:270
1056
  msgid "Limit"
1057
  msgstr ""
1058
 
1059
+ #: integrations/mycred.php:238, integrations/mycred.php:283
1060
  msgid "Log Template"
1061
  msgstr ""
1062
 
1063
+ #: integrations/mycred.php:242, integrations/mycred.php:287
1064
  msgid "required"
1065
  msgstr ""
1066
 
1067
+ #: integrations/mycred.php:252
1068
  msgid "Purchasing Product from Wishlist"
1069
  msgstr ""
1070
 
1071
+ #: integrations/mycred.php:340
1072
  msgid "Purchased From Wishlist"
1073
  msgstr ""
1074
 
1075
+ #: integrations/mycred.php:341
1076
  msgid "Added To Wishlist"
1077
  msgstr ""
1078
 
1079
+ #: integrations/product-extras-for-woocommerce.php:92
1080
  msgid "Flat rate cost"
1081
  msgstr ""
1082
 
1083
+ #: integrations/woo-product-bundle.php:113, integrations/woocommerce-composite-products.php:140, integrations/woocommerce-mix-and-match-products.php:110, integrations/woocommerce-product-bundles.php:134, integrations/yith-woocommerce-product-bundles.php:163, templates/ti-wishlist-user.php:145, templates/ti-wishlist.php:153
1084
  msgid "In stock"
1085
  msgstr ""
1086
 
1087
+ #: integrations/woocommerce-gravityforms-product-addons.php:67
1088
  msgid "Select options"
1089
  msgstr ""
1090
 
1091
+ #: integrations/wp-grid-builder.php:98
1092
  msgid "Wishlist Button"
1093
  msgstr ""
1094
 
1095
+ #: integrations/yith-woocommerce-product-add-ons.php:70
1096
  msgid "Base price"
1097
  msgstr ""
1098
 
1099
+ #: integrations/yith-woocommerce-product-bundles.php:98
1100
  msgid "Out of stock"
1101
  msgstr ""
1102
 
1112
  msgid "Something went wrong"
1113
  msgstr ""
1114
 
1115
+ #: public/tinvwl.class.php:547
1116
  msgid "Create New"
1117
  msgstr ""
1118
 
1119
+ #: public/tinvwl.class.php:551
1120
  msgid "Please select some product options before adding this product to your wishlist."
1121
  msgstr ""
1122
 
1123
+ #: public/tinvwl.class.php:552
1124
  msgid "No items or actions are selected."
1125
  msgstr ""
1126
 
1127
+ #: public/tinvwl.class.php:553
1128
  msgid "Copied!"
1129
  msgstr ""
1130
 
public/tinvwl.class.php CHANGED
@@ -438,9 +438,11 @@ class TInvWL_Public_TInvWL
438
  function enqueue_styles()
439
  {
440
  if (apply_filters('tinvwl_load_webfont', true)) {
 
441
  wp_enqueue_style($this->_name . '-webfont', TINVWL_URL . 'assets/css/webfont.min.css', array(), $this->_version, 'all');
442
  wp_style_add_data($this->_name . '-webfont', 'rtl', 'replace');
443
  wp_style_add_data($this->_name . '-webfont', 'suffix', '.min');
 
444
  }
445
  wp_enqueue_style('tinvwl', TINVWL_URL . 'assets/css/public.min.css', array(), $this->_version, 'all');
446
  wp_style_add_data('tinvwl', 'rtl', 'replace');
@@ -460,6 +462,16 @@ class TInvWL_Public_TInvWL
460
  }
461
  }
462
 
 
 
 
 
 
 
 
 
 
 
463
  /**
464
  * Compress CSS
465
  *
438
  function enqueue_styles()
439
  {
440
  if (apply_filters('tinvwl_load_webfont', true)) {
441
+ wp_enqueue_style($this->_name . '-webfont-font', TINVWL_URL . 'assets/fonts/tinvwl-webfont.woff2', array(), 'xu2uyi');
442
  wp_enqueue_style($this->_name . '-webfont', TINVWL_URL . 'assets/css/webfont.min.css', array(), $this->_version, 'all');
443
  wp_style_add_data($this->_name . '-webfont', 'rtl', 'replace');
444
  wp_style_add_data($this->_name . '-webfont', 'suffix', '.min');
445
+ add_filter('style_loader_tag', array($this, 'font_loader_tag_filter'), 10, 2);
446
  }
447
  wp_enqueue_style('tinvwl', TINVWL_URL . 'assets/css/public.min.css', array(), $this->_version, 'all');
448
  wp_style_add_data('tinvwl', 'rtl', 'replace');
462
  }
463
  }
464
 
465
+ /* Preload Icons font */
466
+ function font_loader_tag_filter($html, $handle)
467
+ {
468
+ if ($handle === $this->_name . '-webfont-font') {
469
+ return str_replace("rel='stylesheet'", "rel='preload' as='font' type='font/woff2' crossorigin='anonymous'", $html);
470
+ }
471
+
472
+ return $html;
473
+ }
474
+
475
  /**
476
  * Compress CSS
477
  *
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: templateinvaders
3
  Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
4
  Requires at least: 4.7
5
  Tested up to: 5.7
6
- Stable tag: 1.23.10
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
  Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
@@ -163,6 +163,14 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
163
 
164
 
165
  == Changelog ==
 
 
 
 
 
 
 
 
166
  = 1.23.10 =
167
  *Release Date - 10 March 2021*
168
 
3
  Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
4
  Requires at least: 4.7
5
  Tested up to: 5.7
6
+ Stable tag: 1.24.0
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
  Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
163
 
164
 
165
  == Changelog ==
166
+ = 1.24.0 =
167
+ *Release Date - 18 March 2021*
168
+
169
+ * Added plugin settings to allow disabling built-in integrations with 3rd party plugins and themes
170
+ * Added preload for the plugin custom webfont
171
+ * Added integration with [WooCommerce Square](https://woocommerce.com/products/square/?aff=3955) plugin
172
+ * Updated integration with WooCommerce TM Extra Product Options plugin
173
+
174
  = 1.23.10 =
175
  *Release Date - 10 March 2021*
176
 
ti-woocommerce-wishlist.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: TI WooCommerce Wishlist
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
- * Version: 1.23.10
8
  * Requires at least: 4.7
9
  * Tested up to: 5.7
10
  * WC requires at least: 3.0
@@ -20,35 +20,35 @@
20
  */
21
 
22
  // If this file is called directly, abort.
23
- if ( ! defined( 'ABSPATH' ) ) {
24
  die;
25
  }
26
 
27
  // Define default path.
28
- if ( ! defined( 'TINVWL_URL' ) ) {
29
- define( 'TINVWL_URL', plugins_url( '/', __FILE__ ) );
30
  }
31
- if ( ! defined( 'TINVWL_PATH' ) ) {
32
- define( 'TINVWL_PATH', plugin_dir_path( __FILE__ ) );
33
  }
34
 
35
- if ( ! defined( 'TINVWL_PREFIX' ) ) {
36
- define( 'TINVWL_PREFIX', 'tinvwl' );
37
  }
38
 
39
- if ( ! defined( 'TINVWL_DOMAIN' ) ) {
40
- define( 'TINVWL_DOMAIN', 'ti-woocommerce-wishlist' );
41
  }
42
 
43
- if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
- define( 'TINVWL_FVERSION', '1.23.10' );
45
  }
46
 
47
- if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
48
- define( 'TINVWL_LOAD_FREE', plugin_basename( __FILE__ ) );
49
  }
50
 
51
- if ( ! function_exists( 'tinv_array_merge' ) ) {
52
 
53
  /**
54
  * Function to merge arrays with replacement options
@@ -58,16 +58,17 @@ if ( ! function_exists( 'tinv_array_merge' ) ) {
58
  *
59
  * @return array
60
  */
61
- function tinv_array_merge( $array1, $_ = null ) {
62
- if ( ! is_array( $array1 ) ) {
 
63
  return $array1;
64
  }
65
  $args = func_get_args();
66
- array_shift( $args );
67
- foreach ( $args as $array2 ) {
68
- if ( is_array( $array2 ) ) {
69
- foreach ( $array2 as $key => $value ) {
70
- $array1[ $key ] = $value;
71
  }
72
  }
73
  }
@@ -77,7 +78,7 @@ if ( ! function_exists( 'tinv_array_merge' ) ) {
77
  }
78
 
79
 
80
- if ( ! function_exists( 'tinv_get_option_defaults' ) ) {
81
 
82
  /**
83
  * Extract default options from settings class
@@ -86,80 +87,86 @@ if ( ! function_exists( 'tinv_get_option_defaults' ) ) {
86
  *
87
  * @return array
88
  */
89
- function tinv_get_option_defaults( $category ) {
 
90
  $dir = TINVWL_PATH . 'admin/settings/';
91
- if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
92
  return array();
93
  }
94
- $files = scandir( $dir );
95
- foreach ( $files as $key => $value ) {
96
- if ( preg_match( '/\.class\.php$/i', $value ) ) {
97
- $files[ $key ] = preg_replace( '/\.class\.php$/i', '', $value );
98
  } else {
99
- unset( $files[ $key ] );
100
  }
101
  }
102
  $defaults = array();
103
- foreach ( $files as $file ) {
104
- $class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
105
- $class = $class::instance();
106
- $class_methods = get_class_methods( $class );
107
- foreach ( $class_methods as $method ) {
108
- if ( preg_match( '/_data$/i', $method ) ) {
109
- $settings = $class->get_defaults( $class->$method() );
110
- $defaults = tinv_array_merge( $defaults, $settings );
 
111
  }
112
  }
113
  }
114
- if ( 'all' === $category ) {
 
115
  return $defaults;
116
  }
117
- if ( array_key_exists( $category, $defaults ) ) {
118
- return $defaults[ $category ];
119
  }
120
 
121
  return array();
122
  }
123
  } // End if().
124
 
125
- if ( ! function_exists( 'activation_tinv_wishlist' ) ) {
126
 
127
  /**
128
  * Activation plugin
129
  */
130
- function activation_tinv_wishlist() {
131
- if ( dependency_tinv_wishlist( false ) ) {
 
132
  TInvWL_Activator::activate();
133
  flush_rewrite_rules();
134
  }
135
  }
136
  }
137
 
138
- if ( ! function_exists( 'deactivation_tinv_wishlist' ) ) {
139
 
140
  /**
141
  * Deactivation plugin
142
  */
143
- function deactivation_tinv_wishlist() {
 
144
  flush_rewrite_rules();
145
  }
146
  }
147
 
148
- if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
149
 
150
  /**
151
  * Uninstall plugin
152
  */
153
- function uninstall_tinv_wishlist() {
154
- if ( ! defined( 'TINVWL_LOAD_PREMIUM' ) ) {
 
155
  TInvWL_Activator::uninstall();
156
  flush_rewrite_rules();
157
- wp_clear_scheduled_hook( 'tinvwl_remove_without_author_wishlist' );
158
  }
159
  }
160
  }
161
 
162
- if ( function_exists( 'spl_autoload_register' ) && ! function_exists( 'autoload_tinv_wishlist' ) ) {
163
 
164
  /**
165
  * Autoloader class. If no function spl_autoload_register, then all the files will be required
@@ -168,28 +175,29 @@ if ( function_exists( 'spl_autoload_register' ) && ! function_exists( 'autoload_
168
  *
169
  * @return boolean
170
  */
171
- function autoload_tinv_wishlist( $_class ) {
 
172
  $preffix = 'TInvWL';
173
- $ext = '.php';
174
- $class = explode( '_', $_class );
175
- $object = array_shift( $class );
176
- if ( $preffix !== $object ) {
177
  return false;
178
  }
179
- if ( empty( $class ) ) {
180
- $class = array( $preffix );
181
  }
182
  $basicclass = $class;
183
- array_unshift( $class, 'includes' );
184
  $classes = array(
185
- TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $basicclass ) ),
186
- TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $class ) ),
187
  );
188
 
189
- foreach ( $classes as $class ) {
190
- foreach ( array( '.class', '.helper' ) as $suffix ) {
191
  $filename = $class . $suffix . $ext;
192
- if ( file_exists( $filename ) ) {
193
  require_once $filename;
194
  }
195
  }
@@ -198,10 +206,10 @@ if ( function_exists( 'spl_autoload_register' ) && ! function_exists( 'autoload_
198
  return false;
199
  }
200
 
201
- spl_autoload_register( 'autoload_tinv_wishlist' );
202
  } // End if().
203
 
204
- if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
205
 
206
  /**
207
  * Dependency plugin
@@ -210,10 +218,11 @@ if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
210
  *
211
  * @return boolean
212
  */
213
- function dependency_tinv_wishlist( $run = true ) {
214
- $ext = new TInvWL_PluginExtend( null, __FILE__, TINVWL_PREFIX );
215
- $ext->set_dependency( 'woocommerce/woocommerce.php', 'WooCommerce' )->need();
216
- if ( $run ) {
 
217
  $ext->run();
218
  }
219
 
@@ -221,35 +230,40 @@ if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
221
  }
222
  }
223
 
224
- if ( ! function_exists( 'run_tinv_wishlist' ) ) {
225
 
226
  /**
227
  * Run plugin
228
  */
229
- function run_tinv_wishlist() {
 
 
 
 
 
230
  require_once TINVWL_PATH . 'tinv-wishlists-function.php';
231
 
232
- foreach ( glob( TINVWL_PATH . 'integrations' . DIRECTORY_SEPARATOR . '*.php' ) as $file ) {
233
  require_once $file;
234
  }
235
 
236
- if ( ! function_exists( 'is_plugin_active' ) ) {
237
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
238
  }
239
- if ( defined( 'TINVWL_LOAD_PREMIUM' ) && defined( 'TINVWL_LOAD_FREE' ) || defined( 'TINVWL_LOAD_PREMIUM' ) && is_plugin_active_for_network( TINVWL_LOAD_PREMIUM ) || defined( 'TINVWL_LOAD_FREE' ) && is_plugin_active_for_network( TINVWL_LOAD_FREE ) ) {
240
- $redirect = tinv_wishlist_status( plugin_basename( __FILE__ ) );
241
- if ( $redirect ) {
242
- header( 'Location: ' . $redirect );
243
  exit;
244
  }
245
- } elseif ( dependency_tinv_wishlist() ) {
246
  $plugin = new TInvWL();
247
  $plugin->run();
248
  }
249
  }
250
  }
251
 
252
- register_activation_hook( __FILE__, 'activation_tinv_wishlist' );
253
- register_deactivation_hook( __FILE__, 'deactivation_tinv_wishlist' );
254
- register_uninstall_hook( __FILE__, 'uninstall_tinv_wishlist' );
255
- add_action( 'plugins_loaded', 'run_tinv_wishlist', 20 );
4
  * Plugin Name: TI WooCommerce Wishlist
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
+ * Version: 1.24.0
8
  * Requires at least: 4.7
9
  * Tested up to: 5.7
10
  * WC requires at least: 3.0
20
  */
21
 
22
  // If this file is called directly, abort.
23
+ if (!defined('ABSPATH')) {
24
  die;
25
  }
26
 
27
  // Define default path.
28
+ if (!defined('TINVWL_URL')) {
29
+ define('TINVWL_URL', plugins_url('/', __FILE__));
30
  }
31
+ if (!defined('TINVWL_PATH')) {
32
+ define('TINVWL_PATH', plugin_dir_path(__FILE__));
33
  }
34
 
35
+ if (!defined('TINVWL_PREFIX')) {
36
+ define('TINVWL_PREFIX', 'tinvwl');
37
  }
38
 
39
+ if (!defined('TINVWL_DOMAIN')) {
40
+ define('TINVWL_DOMAIN', 'ti-woocommerce-wishlist');
41
  }
42
 
43
+ if (!defined('TINVWL_FVERSION')) {
44
+ define('TINVWL_FVERSION', '1.24.0');
45
  }
46
 
47
+ if (!defined('TINVWL_LOAD_FREE')) {
48
+ define('TINVWL_LOAD_FREE', plugin_basename(__FILE__));
49
  }
50
 
51
+ if (!function_exists('tinv_array_merge')) {
52
 
53
  /**
54
  * Function to merge arrays with replacement options
58
  *
59
  * @return array
60
  */
61
+ function tinv_array_merge($array1, $_ = null)
62
+ {
63
+ if (!is_array($array1)) {
64
  return $array1;
65
  }
66
  $args = func_get_args();
67
+ array_shift($args);
68
+ foreach ($args as $array2) {
69
+ if (is_array($array2)) {
70
+ foreach ($array2 as $key => $value) {
71
+ $array1[$key] = $value;
72
  }
73
  }
74
  }
78
  }
79
 
80
 
81
+ if (!function_exists('tinv_get_option_defaults')) {
82
 
83
  /**
84
  * Extract default options from settings class
87
  *
88
  * @return array
89
  */
90
+ function tinv_get_option_defaults($category)
91
+ {
92
  $dir = TINVWL_PATH . 'admin/settings/';
93
+ if (!file_exists($dir) || !is_dir($dir)) {
94
  return array();
95
  }
96
+ $files = scandir($dir);
97
+ foreach ($files as $key => $value) {
98
+ if (preg_match('/\.class\.php$/i', $value)) {
99
+ $files[$key] = preg_replace('/\.class\.php$/i', '', $value);
100
  } else {
101
+ unset($files[$key]);
102
  }
103
  }
104
  $defaults = array();
105
+ foreach ($files as $file) {
106
+ $class = 'TInvWL_Admin_Settings_' . ucfirst($file);
107
+ $class = $class::instance();
108
+ $class_methods = get_class_methods($class);
109
+
110
+ foreach ($class_methods as $method) {
111
+ if (preg_match('/_data$/i', $method)) {
112
+ $settings = $class->get_defaults($class->$method());
113
+ $defaults = tinv_array_merge($defaults, $settings);
114
  }
115
  }
116
  }
117
+
118
+ if ('all' === $category) {
119
  return $defaults;
120
  }
121
+ if (array_key_exists($category, $defaults)) {
122
+ return $defaults[$category];
123
  }
124
 
125
  return array();
126
  }
127
  } // End if().
128
 
129
+ if (!function_exists('activation_tinv_wishlist')) {
130
 
131
  /**
132
  * Activation plugin
133
  */
134
+ function activation_tinv_wishlist()
135
+ {
136
+ if (dependency_tinv_wishlist(false)) {
137
  TInvWL_Activator::activate();
138
  flush_rewrite_rules();
139
  }
140
  }
141
  }
142
 
143
+ if (!function_exists('deactivation_tinv_wishlist')) {
144
 
145
  /**
146
  * Deactivation plugin
147
  */
148
+ function deactivation_tinv_wishlist()
149
+ {
150
  flush_rewrite_rules();
151
  }
152
  }
153
 
154
+ if (!function_exists('uninstall_tinv_wishlist')) {
155
 
156
  /**
157
  * Uninstall plugin
158
  */
159
+ function uninstall_tinv_wishlist()
160
+ {
161
+ if (!defined('TINVWL_LOAD_PREMIUM')) {
162
  TInvWL_Activator::uninstall();
163
  flush_rewrite_rules();
164
+ wp_clear_scheduled_hook('tinvwl_remove_without_author_wishlist');
165
  }
166
  }
167
  }
168
 
169
+ if (function_exists('spl_autoload_register') && !function_exists('autoload_tinv_wishlist')) {
170
 
171
  /**
172
  * Autoloader class. If no function spl_autoload_register, then all the files will be required
175
  *
176
  * @return boolean
177
  */
178
+ function autoload_tinv_wishlist($_class)
179
+ {
180
  $preffix = 'TInvWL';
181
+ $ext = '.php';
182
+ $class = explode('_', $_class);
183
+ $object = array_shift($class);
184
+ if ($preffix !== $object) {
185
  return false;
186
  }
187
+ if (empty($class)) {
188
+ $class = array($preffix);
189
  }
190
  $basicclass = $class;
191
+ array_unshift($class, 'includes');
192
  $classes = array(
193
+ TINVWL_PATH . strtolower(implode(DIRECTORY_SEPARATOR, $basicclass)),
194
+ TINVWL_PATH . strtolower(implode(DIRECTORY_SEPARATOR, $class)),
195
  );
196
 
197
+ foreach ($classes as $class) {
198
+ foreach (array('.class', '.helper') as $suffix) {
199
  $filename = $class . $suffix . $ext;
200
+ if (file_exists($filename)) {
201
  require_once $filename;
202
  }
203
  }
206
  return false;
207
  }
208
 
209
+ spl_autoload_register('autoload_tinv_wishlist');
210
  } // End if().
211
 
212
+ if (!function_exists('dependency_tinv_wishlist')) {
213
 
214
  /**
215
  * Dependency plugin
218
  *
219
  * @return boolean
220
  */
221
+ function dependency_tinv_wishlist($run = true)
222
+ {
223
+ $ext = new TInvWL_PluginExtend(null, __FILE__, TINVWL_PREFIX);
224
+ $ext->set_dependency('woocommerce/woocommerce.php', 'WooCommerce')->need();
225
+ if ($run) {
226
  $ext->run();
227
  }
228
 
230
  }
231
  }
232
 
233
+ if (!function_exists('run_tinv_wishlist')) {
234
 
235
  /**
236
  * Run plugin
237
  */
238
+ function run_tinv_wishlist()
239
+ {
240
+ global $integrations;
241
+
242
+ $integrations = array();
243
+
244
  require_once TINVWL_PATH . 'tinv-wishlists-function.php';
245
 
246
+ foreach (glob(TINVWL_PATH . 'integrations' . DIRECTORY_SEPARATOR . '*.php') as $file) {
247
  require_once $file;
248
  }
249
 
250
+ if (!function_exists('is_plugin_active')) {
251
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
252
  }
253
+ if (defined('TINVWL_LOAD_PREMIUM') && defined('TINVWL_LOAD_FREE') || defined('TINVWL_LOAD_PREMIUM') && is_plugin_active_for_network(TINVWL_LOAD_PREMIUM) || defined('TINVWL_LOAD_FREE') && is_plugin_active_for_network(TINVWL_LOAD_FREE)) {
254
+ $redirect = tinv_wishlist_status(plugin_basename(__FILE__));
255
+ if ($redirect) {
256
+ header('Location: ' . $redirect);
257
  exit;
258
  }
259
+ } elseif (dependency_tinv_wishlist()) {
260
  $plugin = new TInvWL();
261
  $plugin->run();
262
  }
263
  }
264
  }
265
 
266
+ register_activation_hook(__FILE__, 'activation_tinv_wishlist');
267
+ register_deactivation_hook(__FILE__, 'deactivation_tinv_wishlist');
268
+ register_uninstall_hook(__FILE__, 'uninstall_tinv_wishlist');
269
+ add_action('plugins_loaded', 'run_tinv_wishlist', 20);