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 | WooCommerce Wishlist Plugin |
Version | 1.24.0 |
Comparing to | |
See all releases |
Code changes from version 1.23.10 to 1.24.0
- admin/settings/integrations.class.php +126 -0
- assets/css/admin-form-rtl.min.css +1 -1
- assets/css/admin-form.min.css +1 -1
- assets/css/admin-rtl.min.css +1 -1
- assets/css/admin-setup-rtl.min.css +1 -1
- assets/css/admin-setup.min.css +1 -1
- assets/css/admin.min.css +1 -1
- assets/css/public-rtl.min.css +1 -1
- assets/css/public.min.css +1 -1
- assets/css/theme-rtl.min.css +1 -1
- assets/css/theme.min.css +1 -1
- assets/css/webfont-rtl.css +2 -2
- assets/css/webfont-rtl.css.map +1 -1
- assets/css/webfont-rtl.min.css +2 -2
- assets/css/webfont.css +2 -2
- assets/css/webfont.css.map +1 -1
- assets/css/webfont.min.css +2 -2
- assets/fonts/tinvwl-webfont.woff2 +0 -0
- assets/js/admin.min.js +1 -1
- assets/js/public.min.js +1 -1
- integrations/advanced-product-fields-for-woocommerce-pro.php +68 -44
- integrations/advanced-product-fields-for-woocommerce.php +76 -52
- integrations/automatewoo.php +48 -22
- integrations/check-pincodezipcode-for-shipping-woocommerce.php +24 -2
- integrations/clever-swatches.php +98 -74
- integrations/comet-cache.php +34 -11
- integrations/duracelltomi-google-tag-manager.php +31 -8
- integrations/elex-woocommerce-catalog-mode.php +40 -16
- integrations/gift-cards-for-woocommerce.php +170 -144
- integrations/hide-price-add-to-cart-button.php +454 -429
- integrations/improved-variable-product-attributes.php +59 -35
- integrations/litespeed-cache.php +55 -30
- integrations/mycred.php +345 -313
- integrations/product-extras-for-woocommerce.php +130 -106
- integrations/pw-woocommerce-gift-cards.php +23 -1
- integrations/show-single-variations.php +29 -6
- integrations/sitepress-multilingual-cms.php +46 -22
- integrations/theme-divi.php +36 -13
- integrations/theme-flatsome.php +24 -1
- integrations/theme-kallyas.php +32 -9
- integrations/theme-oceanwp.php +32 -9
- integrations/uni-woo-custom-product-options.php +107 -83
- integrations/woo-advanced-qty.php +46 -22
- integrations/woo-custom-product-addons.php +142 -117
- integrations/woo-payment-gateway.php +36 -13
- integrations/woo-product-bundle.php +67 -42
- integrations/woo-variation-swatches-pro.php +38 -13
- integrations/woo-variations-table-grid.php +47 -21
- integrations/woocommerce-booking.php +47 -23
- integrations/woocommerce-bookings.php +75 -49
- integrations/woocommerce-composite-products.php +110 -84
- integrations/woocommerce-custom-fields.php +69 -45
- integrations/woocommerce-gravityforms-product-addons.php +59 -32
- integrations/woocommerce-mix-and-match-products.php +88 -62
- integrations/woocommerce-multilingual.php +95 -68
- integrations/woocommerce-product-addon.php +47 -25
- integrations/woocommerce-product-addons.php +146 -119
- integrations/woocommerce-product-bundles.php +97 -72
- integrations/woocommerce-product-table.php +29 -9
- integrations/woocommerce-rental-and-booking.php +107 -82
- integrations/woocommerce-square.php +66 -0
- integrations/woocommerce-tm-extra-product-options.php +214 -70
- integrations/woocommerce-variation-swatches-and-photos.php +0 -18
- integrations/wp-fastest-cache.php +66 -43
- integrations/wp-grid-builder.php +52 -25
- integrations/wp-multilang.php +38 -16
- integrations/wp-rocket.php +76 -47
- integrations/wpc-variations-radio-buttons.php +31 -8
- integrations/yith-woocommerce-product-add-ons.php +58 -34
- integrations/yith-woocommerce-product-bundles.php +78 -53
- integrations/yith-woocommerce-quick-view.php +32 -9
- languages/ti-woocommerce-wishlist.pot +47 -31
- public/tinvwl.class.php +12 -0
- readme.txt +9 -1
- 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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 (
|
18 |
-
|
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 (
|
28 |
|
29 |
$wapf_ti_cartfield_cache = array();
|
30 |
|
31 |
-
if (
|
32 |
|
33 |
-
function tinv_wishlist_item_meta_wapf(
|
|
|
34 |
global $wapf_ti_cartfield_cache;
|
35 |
|
36 |
-
if (
|
37 |
|
38 |
-
if (
|
39 |
return $item_data;
|
40 |
}
|
41 |
|
42 |
-
$field_groups = SW_WAPF_PRO\Includes\Classes\Field_Groups::get_by_ids(
|
43 |
|
44 |
-
$fields = SW_WAPF_PRO\Includes\Classes\Enumerable::from(
|
45 |
return $x->fields;
|
46 |
-
}
|
47 |
|
48 |
-
foreach (
|
49 |
|
50 |
-
if (
|
51 |
continue;
|
52 |
}
|
53 |
-
$field_id = str_replace(
|
54 |
|
55 |
-
$field_obj = SW_WAPF_PRO\Includes\Classes\Enumerable::from(
|
56 |
return $x->id === $field_id;
|
57 |
-
}
|
58 |
|
59 |
-
$cartitem
|
60 |
$wapf_ti_cartfield_cache[] = $cartitem;
|
61 |
|
62 |
-
$item_data[
|
63 |
-
'key'
|
64 |
-
'display' => Helper::values_to_string(
|
65 |
);
|
66 |
}
|
67 |
|
68 |
-
foreach (
|
69 |
-
if (
|
70 |
-
unset(
|
71 |
}
|
72 |
}
|
73 |
|
@@ -76,63 +98,65 @@ if ( class_exists( 'SW_WAPF_PRO\WAPF' ) ) {
|
|
76 |
return $item_data;
|
77 |
}
|
78 |
|
79 |
-
add_filter(
|
80 |
}
|
81 |
|
82 |
-
if (
|
83 |
-
function tinvwl_calc_wapf_option_price(
|
|
|
84 |
global $wapf_ti_cartfield_cache;
|
85 |
|
86 |
$options_total = 0;
|
87 |
|
88 |
-
$quantity = empty(
|
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 (
|
96 |
-
foreach (
|
97 |
-
foreach (
|
98 |
-
if (
|
99 |
continue;
|
100 |
}
|
101 |
|
102 |
-
$v
|
103 |
$field_ids = array();
|
104 |
-
if (
|
105 |
-
$field_ids = explode(
|
106 |
}
|
107 |
|
108 |
-
$n_price
|
109 |
$options_total = $options_total + $n_price;
|
110 |
}
|
111 |
}
|
112 |
}
|
113 |
|
114 |
$wapf_ti_cartfield_cache = [];
|
115 |
-
if (
|
116 |
-
return wc_price(
|
117 |
}
|
118 |
|
119 |
return $price;
|
120 |
}
|
121 |
|
122 |
-
add_filter(
|
123 |
}
|
124 |
|
125 |
-
if (
|
126 |
-
function tinv_wishlist_metaprepare_wapf(
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
130 |
}
|
131 |
}
|
132 |
|
133 |
return $meta;
|
134 |
}
|
135 |
|
136 |
-
add_filter(
|
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 (
|
18 |
-
|
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 (
|
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(
|
39 |
-
|
|
|
40 |
|
41 |
-
if (
|
42 |
return $item_data;
|
43 |
}
|
44 |
|
45 |
-
$field_groups = SW_WAPF\Includes\Classes\Field_Groups::get_by_ids(
|
46 |
|
47 |
-
$fields = SW_WAPF\Includes\Classes\Enumerable::from(
|
48 |
return $x->fields;
|
49 |
-
}
|
50 |
|
51 |
-
foreach (
|
52 |
-
if (
|
53 |
continue;
|
54 |
}
|
55 |
-
$field_id = str_replace(
|
56 |
|
57 |
-
$field_obj
|
58 |
return $x->id === $field_id;
|
59 |
-
}
|
60 |
-
$product
|
61 |
$price_addition = array();
|
62 |
|
63 |
-
if (
|
64 |
-
$price_addition = SW_WAPF\Includes\Classes\Fields::pricing_value(
|
65 |
}
|
66 |
|
67 |
-
$item_data[
|
68 |
-
'key'
|
69 |
-
'display' => SW_WAPF\Includes\Classes\Fields::value_to_string(
|
70 |
);
|
71 |
}
|
72 |
|
73 |
-
foreach (
|
74 |
-
if (
|
75 |
-
unset(
|
76 |
}
|
77 |
}
|
78 |
|
@@ -81,10 +103,10 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_wapf' ) ) {
|
|
81 |
return $item_data;
|
82 |
}
|
83 |
|
84 |
-
add_filter(
|
85 |
}
|
86 |
|
87 |
-
if (
|
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(
|
|
|
99 |
|
100 |
-
if (
|
101 |
|
102 |
-
if (
|
103 |
return $price;
|
104 |
}
|
105 |
|
106 |
-
$field_groups = SW_WAPF\Includes\Classes\Field_Groups::get_by_ids(
|
107 |
|
108 |
-
$fields = SW_WAPF\Includes\Classes\Enumerable::from(
|
109 |
return $x->fields;
|
110 |
-
}
|
111 |
|
112 |
-
$quantity = empty(
|
113 |
|
114 |
-
$base
|
115 |
$options_total = 0;
|
116 |
|
117 |
-
foreach (
|
118 |
|
119 |
-
$field_id = str_replace(
|
120 |
|
121 |
-
$field_obj = SW_WAPF\Includes\Classes\Enumerable::from(
|
122 |
return $x->id === $field_id;
|
123 |
-
}
|
124 |
|
125 |
$price_addition = array();
|
126 |
|
127 |
-
if (
|
128 |
-
$price_addition = SW_WAPF\Includes\Classes\Fields::pricing_value(
|
129 |
}
|
130 |
|
131 |
-
if (
|
132 |
-
foreach (
|
133 |
|
134 |
-
if (
|
135 |
continue;
|
136 |
}
|
137 |
|
138 |
-
$options_total = $options_total + SW_WAPF\Includes\Classes\Fields::do_pricing(
|
139 |
|
140 |
}
|
141 |
}
|
142 |
}
|
143 |
|
144 |
-
if (
|
145 |
-
return wc_price(
|
146 |
}
|
147 |
|
148 |
}
|
@@ -150,10 +173,10 @@ if ( ! function_exists( 'tinvwl_item_price_wapf' ) ) {
|
|
150 |
return $price;
|
151 |
}
|
152 |
|
153 |
-
add_filter(
|
154 |
} // End if().
|
155 |
|
156 |
-
if (
|
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(
|
|
|
166 |
|
167 |
-
foreach (
|
168 |
-
if (
|
169 |
|
170 |
-
$meta[
|
171 |
}
|
172 |
}
|
173 |
|
174 |
return $meta;
|
175 |
}
|
176 |
|
177 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
/**
|
23 |
* @param array $triggers
|
24 |
*
|
25 |
* @return array
|
26 |
*/
|
27 |
-
function tinvwl_automatewoo_triggers(
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
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 (
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
30 |
-
|
|
|
31 |
|
32 |
return $data;
|
33 |
}
|
34 |
|
35 |
-
add_filter(
|
36 |
-
add_action(
|
37 |
-
add_action(
|
38 |
-
add_action(
|
39 |
-
add_action(
|
40 |
-
add_action(
|
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 (
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
// Google Tag Manager for WordPress compatibility.
|
21 |
-
if (
|
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(
|
|
|
31 |
|
32 |
-
foreach (
|
33 |
-
if (
|
34 |
-
unset(
|
35 |
}
|
36 |
}
|
37 |
|
38 |
return $meta;
|
39 |
}
|
40 |
|
41 |
-
add_filter(
|
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 (
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
|
21 |
/**
|
22 |
* Run hooks on page redirect.
|
23 |
*/
|
24 |
-
function tinvwl_elex_init()
|
25 |
-
|
|
|
26 |
|
27 |
global $post;
|
28 |
-
$product = wc_get_product(
|
29 |
-
if (
|
30 |
|
31 |
-
if (
|
32 |
-
if (
|
33 |
-
add_action(
|
34 |
}
|
35 |
-
} elseif (
|
36 |
-
if (
|
37 |
-
add_action(
|
38 |
}
|
39 |
}
|
40 |
}
|
41 |
}
|
42 |
}
|
43 |
|
44 |
-
add_action(
|
45 |
|
46 |
// Add a custom hook for single page.
|
47 |
-
function tinvwl_elex_single_product_summary()
|
48 |
-
|
49 |
-
|
|
|
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 (
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
*
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
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 (
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
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('"', '"', $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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
30 |
global $product;
|
31 |
|
32 |
-
if (
|
33 |
|
34 |
$curr_customizations = XforWC_Improved_Options_Frontend::get_settings();
|
35 |
|
36 |
-
foreach (
|
37 |
|
38 |
-
$prefix
|
39 |
-
$k_ivpac = (
|
40 |
|
41 |
-
$prefix
|
42 |
-
$k_ivpac
|
43 |
-
$local_attribute = (
|
44 |
-
$v
|
45 |
|
46 |
-
if (
|
47 |
-
if (
|
48 |
-
$meta[
|
49 |
-
'key'
|
50 |
'display' => $v,
|
51 |
);
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
if (
|
56 |
|
57 |
$attributes = $product->get_attributes();
|
58 |
-
$attribute
|
59 |
|
60 |
$term_slug = '';
|
61 |
|
62 |
-
if (
|
63 |
-
$term_slug = $attributes[
|
64 |
-
} elseif (
|
65 |
-
$term_slug = $attributes[
|
66 |
}
|
67 |
|
68 |
-
if (
|
69 |
-
unset(
|
70 |
} else {
|
71 |
-
$meta[
|
72 |
-
'key'
|
73 |
'display' => $v,
|
74 |
);
|
75 |
}
|
76 |
-
} elseif (
|
77 |
-
$meta[
|
78 |
-
'key'
|
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(
|
89 |
} // End if().
|
90 |
|
91 |
|
92 |
-
function tinv_add_to_wishlist_ivpa()
|
93 |
-
|
|
|
94 |
|
95 |
-
wp_add_inline_script(
|
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(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
// Force ESI nonce.
|
23 |
-
if (
|
24 |
-
add_action(
|
25 |
|
26 |
-
function tinvwl_litespeed_conf_esi_nonce()
|
27 |
-
|
|
|
28 |
}
|
29 |
|
30 |
}
|
31 |
|
32 |
// Force exclude URL
|
33 |
-
if (
|
34 |
-
add_action(
|
35 |
|
36 |
-
function tinvwl_litespeed_conf_exc_uri()
|
37 |
-
|
|
|
38 |
|
39 |
-
$ids
|
40 |
-
tinv_get_option(
|
41 |
);
|
42 |
-
$pages
|
43 |
-
$languages = apply_filters(
|
44 |
'skip_missing' => 0,
|
45 |
-
'orderby'
|
46 |
-
)
|
47 |
-
if (
|
48 |
-
foreach (
|
49 |
-
foreach (
|
50 |
-
$pages[] = apply_filters(
|
51 |
}
|
52 |
}
|
53 |
-
$pages = array_unique(
|
54 |
}
|
55 |
-
$pages = array_filter(
|
56 |
|
57 |
-
if (
|
58 |
-
foreach (
|
59 |
-
$pages[
|
60 |
}
|
61 |
}
|
62 |
-
$pages = array_unique(
|
63 |
-
$pages = array_filter(
|
64 |
|
65 |
-
$val = array_unique(
|
66 |
-
do_action(
|
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 (
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
//
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
</div>
|
234 |
-
</div>
|
235 |
-
<div class="col-lg-
|
236 |
-
<div class="form-group">
|
237 |
-
<label
|
238 |
-
'
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
33 |
|
34 |
-
if (
|
35 |
// Check for product_extra groups
|
36 |
-
$product_extra_groups = pewc_get_extra_fields(
|
37 |
-
$hidden_group_types
|
38 |
-
if (
|
39 |
|
40 |
-
foreach (
|
41 |
|
42 |
-
if (
|
43 |
|
44 |
-
foreach (
|
45 |
|
46 |
|
47 |
-
if (
|
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 (
|
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(
|
59 |
|
60 |
-
if (
|
61 |
|
62 |
-
if (
|
63 |
continue;
|
64 |
}
|
65 |
|
66 |
$price = '';
|
67 |
|
68 |
-
if (
|
69 |
-
$price = '<span class="pewc-flat-rate-cart-label">(' . __(
|
70 |
}
|
71 |
|
72 |
-
$price = apply_filters(
|
73 |
|
74 |
-
$item['label'] = isset(
|
75 |
|
76 |
-
$value = (
|
77 |
|
78 |
-
if (
|
79 |
-
$value = sanitize_textarea_field(
|
80 |
-
} else if (
|
81 |
'image_swatch',
|
82 |
'radio',
|
83 |
'upload'
|
84 |
-
)
|
85 |
-
$value = wp_kses_post(
|
86 |
} else {
|
87 |
-
$value = sanitize_text_field(
|
88 |
}
|
89 |
|
90 |
$item['value'] = $value;
|
91 |
|
92 |
-
if (
|
93 |
continue;
|
94 |
}
|
95 |
|
96 |
-
if (
|
97 |
$item_data[] = array(
|
98 |
-
'key'
|
99 |
-
'display' => '<span class="pewc-price pewc-cart-item-price">' . sanitize_text_field(
|
100 |
);
|
101 |
-
} else if (
|
102 |
$item_data[] = array(
|
103 |
-
'key'
|
104 |
-
'display' => str_replace(
|
105 |
);
|
106 |
-
} else if (
|
107 |
-
$value
|
108 |
$item_data[] = array(
|
109 |
-
'key'
|
110 |
-
'display' => sanitize_text_field(
|
111 |
);
|
112 |
} else {
|
113 |
$item_data[] = array(
|
114 |
-
'key'
|
115 |
-
'display' => sanitize_text_field(
|
116 |
);
|
117 |
}
|
118 |
}
|
@@ -122,19 +145,19 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_pewc' ) ) {
|
|
122 |
}
|
123 |
}
|
124 |
|
125 |
-
foreach (
|
126 |
-
if (
|
127 |
-
unset(
|
128 |
}
|
129 |
}
|
130 |
|
131 |
return $item_data;
|
132 |
}
|
133 |
|
134 |
-
add_filter(
|
135 |
}
|
136 |
|
137 |
-
if (
|
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(
|
|
|
149 |
|
150 |
-
if (
|
151 |
|
152 |
$product_price = $product->get_price();
|
153 |
-
$product_id
|
154 |
-
$extra_price
|
155 |
|
156 |
-
$product_extra_groups = pewc_get_extra_fields(
|
157 |
|
158 |
-
if (
|
159 |
|
160 |
-
foreach (
|
161 |
|
162 |
-
if (
|
163 |
|
164 |
-
foreach (
|
165 |
|
166 |
-
$show_option_prices_in_cart = pewc_show_option_prices_in_cart(
|
167 |
|
168 |
|
169 |
-
$group_id
|
170 |
-
$field_id
|
171 |
$field_type = $item['field_type'];
|
172 |
|
173 |
-
if (
|
174 |
|
175 |
-
$id
|
176 |
$price = 0;
|
177 |
-
$value = isset(
|
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(
|
183 |
|
184 |
-
$is_percentage = !
|
185 |
|
186 |
// Only add item if it's visible
|
187 |
-
if (
|
188 |
|
189 |
-
$field_price = pewc_get_field_price(
|
190 |
|
191 |
// Add the value of the field (not including the value of options)
|
192 |
-
if (
|
193 |
-
$price = floatval(
|
194 |
}
|
195 |
|
196 |
// Check for Name Your Price
|
197 |
-
if (
|
198 |
-
if (
|
199 |
$price = $value;
|
200 |
}
|
201 |
}
|
202 |
|
203 |
// Check for Calculation fields
|
204 |
-
if (
|
205 |
|
206 |
-
if (
|
207 |
|
208 |
-
if (
|
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 (
|
218 |
-
$remove_line_breaks = preg_replace(
|
219 |
-
$str_length
|
220 |
-
if (
|
221 |
-
$str_length -= absint(
|
222 |
-
$str_length = max(
|
223 |
}
|
224 |
-
if (
|
225 |
$price = $str_length * $price;
|
226 |
}
|
227 |
}
|
228 |
|
229 |
// Calculate price for multiply fields
|
230 |
-
if (
|
231 |
-
if (
|
232 |
$price = $value * $price;
|
233 |
}
|
234 |
}
|
235 |
|
236 |
// Calculate price for percentage fields
|
237 |
-
if (
|
238 |
-
if (
|
239 |
-
$price = pewc_calculate_percentage_price(
|
240 |
// $price = $value * $price;
|
241 |
}
|
242 |
}
|
243 |
|
244 |
// Filtered by Bookings to include per unit cost for extras
|
245 |
-
$price = apply_filters(
|
246 |
|
247 |
// Find any additional cost for options and select fields
|
248 |
-
if (
|
249 |
|
250 |
// Record checkbox group values differently
|
251 |
$checkbox_group_values = array();
|
252 |
// Radio buttons are arrays, select are simple values
|
253 |
-
if (
|
254 |
$option_value = $value[0];
|
255 |
} else {
|
256 |
$option_value = $value;
|
257 |
}
|
258 |
|
259 |
|
260 |
-
foreach (
|
261 |
|
262 |
// If it's a checkbox group, we need to total all selected options
|
263 |
-
if (
|
264 |
|
265 |
-
if (
|
266 |
$option_price = $option['price'];
|
267 |
-
if (
|
268 |
-
$option_price = pewc_calculate_percentage_price(
|
269 |
}
|
270 |
|
271 |
-
if (
|
272 |
-
$price
|
273 |
-
$option_price
|
274 |
-
$checkbox_group_values[] = $show_option_prices_in_cart === true ? $option['value'] . ' (' . wc_price(
|
275 |
}
|
276 |
}
|
277 |
|
278 |
-
} else if (
|
279 |
$option_price = $option['price'];
|
280 |
-
if (
|
281 |
-
$option_price = pewc_calculate_percentage_price(
|
282 |
}
|
283 |
|
284 |
-
if (
|
285 |
-
$price += floatval(
|
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(
|
297 |
|
298 |
-
$extra_price += floatval(
|
299 |
}
|
300 |
}
|
301 |
}
|
302 |
|
303 |
// Ensure price can't be less than 0
|
304 |
-
$new_price = floatval(
|
305 |
-
if (
|
306 |
$new_price = 0;
|
307 |
}
|
308 |
|
309 |
-
return wc_price(
|
310 |
}
|
311 |
}
|
312 |
}
|
@@ -315,5 +339,5 @@ if ( ! function_exists( 'tinvwl_item_price_pewc' ) ) {
|
|
315 |
return $price;
|
316 |
}
|
317 |
|
318 |
-
add_filter(
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
30 |
-
|
31 |
-
|
|
|
32 |
$_variation_id = $variation_id = $product['variation_id'];
|
33 |
-
$_product_id
|
34 |
-
if (
|
35 |
-
$_variation_id = apply_filters(
|
36 |
}
|
37 |
-
if (
|
38 |
-
$product['data'] = wc_get_product(
|
39 |
}
|
40 |
}
|
41 |
|
42 |
return $product;
|
43 |
}
|
44 |
|
45 |
-
add_filter(
|
46 |
}
|
47 |
|
48 |
-
if (
|
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(
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
62 |
$suffix = '';
|
63 |
-
if (
|
64 |
$full_link = $_full_link[1];
|
65 |
-
$suffix
|
66 |
}
|
67 |
-
if (
|
68 |
$full_link .= '/';
|
69 |
}
|
70 |
$full_link .= $share_key . '/' . $suffix;
|
71 |
} else {
|
72 |
-
$full_link .= add_query_arg(
|
73 |
}
|
74 |
}
|
75 |
|
76 |
return $full_link;
|
77 |
}
|
78 |
|
79 |
-
add_filter(
|
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
|
10 |
*
|
11 |
* @url http://www.elegantthemes.com/gallery/divi/
|
12 |
*
|
13 |
*/
|
14 |
|
15 |
// If this file is called directly, abort.
|
16 |
-
if (
|
17 |
-
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
* Run hooks on page redirect.
|
23 |
*/
|
24 |
-
function tinvwl_divi_init()
|
25 |
-
|
|
|
26 |
global $post;
|
27 |
-
$product = wc_get_product(
|
28 |
-
if (
|
29 |
-
remove_action(
|
30 |
-
remove_action(
|
31 |
-
add_action(
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
|
36 |
-
add_action(
|
37 |
|
38 |
// Add a custom hook for single page.
|
39 |
-
function tinvwl_divi_single_product_summary()
|
40 |
-
|
|
|
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 |
-
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
/**
|
23 |
* Run hooks after theme init.
|
24 |
*/
|
25 |
-
function tinvwl_kallyas_init()
|
26 |
-
|
|
|
27 |
|
28 |
-
$show_cart_to_visitors = zget_option(
|
29 |
-
if (
|
30 |
-
add_filter(
|
31 |
}
|
32 |
|
33 |
|
34 |
}
|
35 |
}
|
36 |
|
37 |
-
add_action(
|
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 (
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
// OceanWP theme compatibility;
|
21 |
-
if (
|
22 |
-
add_action(
|
23 |
|
24 |
/**
|
25 |
* OceanWP theme fix for catalog add to wishlist button position
|
26 |
*/
|
27 |
-
function tinvwl_oceanwp_fix_archive_markup()
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
33 |
|
34 |
-
if (
|
35 |
-
foreach (
|
36 |
-
if (
|
37 |
-
unset(
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
if (
|
42 |
|
43 |
$form_data = array();
|
44 |
|
45 |
-
foreach (
|
46 |
-
$form_data[
|
47 |
}
|
48 |
|
49 |
-
$filtered_form_data = array_filter(
|
50 |
-
return false !== strpos(
|
51 |
-
}, ARRAY_FILTER_USE_KEY
|
52 |
-
|
53 |
-
if (
|
54 |
-
$posts = uni_cpo_get_posts_by_slugs(
|
55 |
-
|
56 |
-
if (
|
57 |
-
$posts_ids = wp_list_pluck(
|
58 |
-
foreach (
|
59 |
-
$option = uni_cpo_get_option(
|
60 |
-
if (
|
61 |
-
$calculate_result = $option->calculate(
|
62 |
-
if (
|
63 |
-
if (
|
64 |
-
$calculate_result[
|
65 |
-
if (
|
66 |
-
return esc_html__(
|
67 |
} else {
|
68 |
return $item;
|
69 |
}
|
70 |
-
}, $calculate_result[
|
71 |
-
$display_value
|
72 |
} else {
|
73 |
-
if (
|
74 |
-
$display_value = esc_html__(
|
75 |
} else {
|
76 |
-
$display_value = $calculate_result[
|
77 |
}
|
78 |
}
|
79 |
-
$item_data[
|
80 |
}
|
81 |
-
$item_data[
|
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(
|
96 |
}
|
97 |
|
98 |
-
if (
|
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(
|
|
|
110 |
|
111 |
-
if (
|
112 |
-
$product_data
|
113 |
-
$form_data
|
114 |
$options_eval_result = array();
|
115 |
-
$variables
|
116 |
-
$is_calc_disabled
|
117 |
-
$formatted_vars
|
118 |
|
119 |
-
$main_formula
|
120 |
-
$filtered_form_data = array_filter(
|
121 |
-
return false !== strpos(
|
122 |
-
}, ARRAY_FILTER_USE_KEY
|
123 |
|
124 |
|
125 |
-
if (
|
126 |
-
$posts = uni_cpo_get_posts_by_slugs(
|
127 |
|
128 |
-
if (
|
129 |
-
$posts_ids = wp_list_pluck(
|
130 |
-
foreach (
|
131 |
-
$option = uni_cpo_get_option(
|
132 |
|
133 |
-
if (
|
134 |
-
$calculate_result = $option->calculate(
|
135 |
-
if (
|
136 |
-
$options_eval_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(
|
146 |
-
foreach (
|
147 |
// prepare $variables for calculation purpose
|
148 |
-
$variables[
|
149 |
// prepare $formatted_vars for conditional logic purpose
|
150 |
-
$formatted_vars[
|
151 |
}
|
152 |
-
}
|
153 |
-
$variables['{uni_cpo_price}'] = $product->get_price(
|
154 |
// non option variables
|
155 |
-
if (
|
156 |
-
$variables = uni_cpo_process_formula_with_non_option_vars(
|
157 |
}
|
158 |
// formula conditional logic
|
159 |
|
160 |
-
if (
|
161 |
-
$conditional_formula = uni_cpo_process_formula_scheme(
|
162 |
-
if (
|
163 |
$main_formula = $conditional_formula;
|
164 |
}
|
165 |
}
|
166 |
|
167 |
-
if (
|
168 |
$is_calc_disabled = true;
|
169 |
}
|
170 |
//
|
171 |
|
172 |
-
if (
|
173 |
-
$main_formula = uni_cpo_process_formula_with_vars(
|
174 |
// calculates formula
|
175 |
-
$price_calculated = uni_cpo_calculate_formula(
|
176 |
-
$price_min
|
177 |
-
$price_max
|
178 |
// check for min price
|
179 |
-
if (
|
180 |
$price_calculated = $price_min;
|
181 |
}
|
182 |
// check for max price
|
183 |
-
if (
|
184 |
$is_calc_disabled = true;
|
185 |
}
|
186 |
|
187 |
-
if (
|
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(
|
197 |
} else {
|
198 |
-
return wc_price(
|
199 |
}
|
200 |
|
201 |
} else {
|
202 |
-
return wc_price(
|
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(
|
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 (
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
// WooCommerce Advanced Quantity compatibility.
|
21 |
-
if (
|
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(
|
|
|
32 |
|
33 |
-
if (
|
34 |
-
$advanced_qty = new Woo_Advanced_QTY_Public(
|
35 |
|
36 |
-
$args = $advanced_qty->qty_input_args(
|
37 |
'min_value' => 1,
|
38 |
'max_value' => '',
|
39 |
-
'step'
|
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(
|
49 |
}
|
50 |
|
51 |
// WooCommerce Advanced Quantity compatibility.
|
52 |
-
if (
|
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(
|
|
|
61 |
|
62 |
-
if (
|
63 |
-
if (
|
64 |
-
$advanced_qty = new Woo_Advanced_QTY_Public(
|
65 |
-
$args
|
66 |
'min_value' => 1,
|
67 |
'max_value' => '',
|
68 |
-
'step'
|
69 |
-
), $product
|
70 |
|
71 |
-
$url = preg_replace(
|
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(
|
81 |
-
add_filter(
|
82 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
33 |
-
|
34 |
-
|
|
|
35 |
$frontend = new WCPA_Front_End();
|
36 |
-
$data
|
37 |
-
$post_ids = $form->get_form_ids(
|
38 |
|
39 |
-
if (
|
40 |
-
unset(
|
41 |
}
|
42 |
|
43 |
-
if (
|
44 |
-
if (
|
45 |
-
$post_ids = get_posts(
|
46 |
-
'posts_per_page' => -
|
47 |
-
'include'
|
48 |
-
'fields'
|
49 |
-
'post_type'
|
50 |
-
'posts_per_page' => -
|
51 |
-
)
|
52 |
}
|
53 |
}
|
54 |
-
foreach (
|
55 |
-
if (
|
56 |
-
$json_string
|
57 |
-
$json_encoded = json_decode(
|
58 |
-
if (
|
59 |
-
$data = array_merge(
|
60 |
}
|
61 |
}
|
62 |
}
|
63 |
|
64 |
-
foreach (
|
65 |
$form_data = clone $v;
|
66 |
-
unset(
|
67 |
-
unset(
|
68 |
-
if (
|
69 |
-
if (
|
70 |
-
|
71 |
-
if (
|
72 |
-
$value = sanitize_text_field(
|
73 |
-
} else if (
|
74 |
-
if (
|
75 |
-
|
76 |
-
$_values = $item_data[
|
77 |
-
array_walk(
|
78 |
-
sanitize_text_field(
|
79 |
-
}
|
80 |
$value = $_values;
|
81 |
-
} else if (
|
82 |
-
$value = sanitize_textarea_field(
|
83 |
} else {
|
84 |
-
$value = sanitize_text_field(
|
85 |
}
|
86 |
}
|
87 |
-
$item_data[
|
88 |
-
$item_data[
|
89 |
-
'type'
|
90 |
-
'name'
|
91 |
-
'label'
|
92 |
-
'value'
|
93 |
-
'price'
|
94 |
'form_data' => $form_data,
|
95 |
-
), wc_get_product(
|
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(
|
105 |
}
|
106 |
|
107 |
-
if (
|
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(
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$
|
123 |
-
$
|
124 |
-
$
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
'
|
131 |
-
'
|
132 |
-
'
|
133 |
-
'
|
134 |
-
|
|
|
135 |
}
|
136 |
}
|
137 |
-
foreach (
|
138 |
-
if (
|
139 |
-
$json_string
|
140 |
-
$json_encoded = json_decode(
|
141 |
-
if (
|
142 |
-
$data = array_merge(
|
143 |
}
|
144 |
}
|
145 |
}
|
146 |
|
147 |
-
foreach (
|
148 |
$form_data = clone $v;
|
149 |
-
unset(
|
150 |
-
unset(
|
151 |
-
if (
|
152 |
-
if (
|
153 |
-
if (
|
154 |
continue;
|
155 |
-
} else if (
|
156 |
-
if (
|
157 |
-
if (
|
158 |
-
foreach (
|
159 |
$price += $p;
|
160 |
}
|
161 |
-
} else if (
|
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
|
171 |
-
$price = $mc->mayBeConvert(
|
172 |
|
173 |
-
$price = wc_price(
|
174 |
|
175 |
}
|
176 |
|
177 |
return $price;
|
178 |
}
|
179 |
|
180 |
-
add_filter(
|
181 |
} // End if().
|
182 |
|
183 |
-
if (
|
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(
|
|
|
195 |
|
196 |
-
if (
|
197 |
$product_id = $product->get_id();
|
198 |
-
$form
|
199 |
-
$post_ids
|
200 |
-
$data
|
201 |
-
if (
|
202 |
-
if (
|
203 |
-
$post_ids = get_posts(
|
204 |
-
'posts_per_page' => -
|
205 |
-
'include'
|
206 |
-
'fields'
|
207 |
-
'post_type'
|
208 |
-
'posts_per_page' => -
|
209 |
-
)
|
210 |
}
|
211 |
}
|
212 |
-
foreach (
|
213 |
-
if (
|
214 |
-
$json_string
|
215 |
-
$json_encoded = json_decode(
|
216 |
-
if (
|
217 |
-
$data = array_merge(
|
218 |
}
|
219 |
}
|
220 |
}
|
221 |
|
222 |
$status = true;
|
223 |
|
224 |
-
foreach (
|
225 |
-
if (
|
226 |
$status = false;
|
227 |
}
|
228 |
}
|
229 |
|
230 |
-
if (
|
231 |
|
232 |
$WCPA = new WCPA_Front_End();
|
233 |
|
234 |
-
return $WCPA->add_to_cart_text(
|
235 |
}
|
236 |
}
|
237 |
|
@@ -239,5 +264,5 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons_tex
|
|
239 |
|
240 |
}
|
241 |
|
242 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
}
|
38 |
-
if (
|
39 |
-
unset(
|
40 |
}
|
41 |
-
if (
|
42 |
-
unset(
|
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(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
$ids_str = '';
|
28 |
|
29 |
-
if (
|
30 |
-
$ids_str = get_post_meta(
|
31 |
}
|
32 |
|
33 |
-
$ids_str = WPCleverWoosb_Helper::woosb_clean_ids(
|
34 |
?>
|
35 |
<input name="woosb_ids" class="woosb_ids woosb-ids" type="hidden"
|
36 |
-
value="<?php echo esc_attr(
|
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(
|
49 |
-
|
|
|
50 |
|
51 |
$bundle = WPCleverWoosb::instance();
|
52 |
|
53 |
-
$bundled_items = $bundle->woosb_get_bundled(
|
54 |
-
if (
|
55 |
-
foreach (
|
56 |
|
57 |
$bundled_item = new stdClass();
|
58 |
|
59 |
-
$bundled_item->product = wc_get_product(
|
60 |
|
61 |
-
if (
|
62 |
continue;
|
63 |
}
|
64 |
|
65 |
$bundled_product_qty = $data['qty'];
|
66 |
-
$product_url
|
67 |
-
$product_image
|
68 |
|
69 |
-
$product_title = is_callable(
|
70 |
$bundled_item->product,
|
71 |
'get_name'
|
72 |
-
)
|
73 |
|
74 |
$product_price = $bundled_item->product->get_price_html();
|
75 |
|
76 |
-
if (
|
77 |
-
$product_image = sprintf(
|
78 |
-
$product_title = sprintf(
|
79 |
}
|
80 |
-
$product_title .= tinv_wishlist_get_item_data(
|
81 |
|
82 |
-
$availability = (array)
|
83 |
-
if (
|
84 |
$availability['availability'] = '';
|
85 |
}
|
86 |
-
if (
|
87 |
$availability['class'] = '';
|
88 |
}
|
89 |
-
$availability_html = empty(
|
90 |
-
$row_string
|
91 |
-
$row_string
|
92 |
-
if (
|
93 |
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
94 |
}
|
95 |
-
if (
|
96 |
$row_string .= '<td class="product-date"> </td>';
|
97 |
}
|
98 |
-
if (
|
99 |
$row_string .= '<td class="product-stock">%4$s</td>';
|
100 |
}
|
101 |
|
102 |
-
if (
|
103 |
$row_string .= '<td class="product-action"> </td>';
|
104 |
}
|
105 |
$row_string .= '</tr>';
|
106 |
|
107 |
-
echo sprintf(
|
108 |
} // End foreach().
|
109 |
} // End if().
|
110 |
} // End if().
|
111 |
}
|
112 |
|
113 |
-
add_action(
|
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(
|
|
|
126 |
|
127 |
-
foreach (
|
128 |
-
if (
|
129 |
-
unset(
|
130 |
}
|
131 |
}
|
132 |
|
@@ -134,5 +159,5 @@ if ( defined( 'WOOSB_VERSION' ) ) {
|
|
134 |
return $item_data;
|
135 |
}
|
136 |
|
137 |
-
add_filter(
|
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"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">➥ %2$s</td>';
|
116 |
+
if (tinv_get_option('product_table', 'colm_price')) {
|
117 |
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
118 |
}
|
119 |
+
if (tinv_get_option('product_table', 'colm_date')) {
|
120 |
$row_string .= '<td class="product-date"> </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"> </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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
-
add_action(
|
29 |
|
30 |
-
function tinvwl_add_custom_url_woo_variation_swatches_pro()
|
31 |
-
|
|
|
32 |
}
|
33 |
|
34 |
-
function tinv_add_to_wishlist_woo_variation_swatches_pro()
|
|
|
35 |
|
36 |
-
wp_add_inline_script(
|
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(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
global $vartable_product;
|
34 |
$vartable_product = $_product;
|
35 |
|
36 |
-
add_action(
|
37 |
-
add_action(
|
38 |
|
39 |
-
add_action(
|
40 |
-
add_action(
|
41 |
|
42 |
}
|
43 |
}
|
44 |
|
45 |
}
|
46 |
|
47 |
-
add_action(
|
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 (
|
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(
|
|
|
80 |
|
81 |
-
if (
|
82 |
|
83 |
-
foreach (
|
84 |
$prefix = 'form_vartable';
|
85 |
-
if (
|
86 |
-
unset(
|
87 |
}
|
88 |
}
|
89 |
}
|
@@ -91,5 +117,5 @@ if ( ! function_exists( 'tinv_wishlist_meta_support_vartable' ) ) {
|
|
91 |
return $meta;
|
92 |
}
|
93 |
|
94 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
32 |
-
|
|
|
33 |
return $meta;
|
34 |
}
|
35 |
|
36 |
-
if (
|
37 |
|
38 |
$item_data = array(
|
39 |
'bkap_booking' => array(),
|
40 |
-
'product_id'
|
41 |
);
|
42 |
|
43 |
-
if (
|
44 |
$item_data['bkap_booking'][0]['date'] = $meta['booking_calender']['display'];
|
45 |
}
|
46 |
|
47 |
-
if (
|
48 |
$item_data['bkap_booking'][0]['date_checkout'] = $meta['booking_calender_checkout']['display'];
|
49 |
}
|
50 |
|
51 |
-
if (
|
52 |
$item_data['bkap_booking'][0]['time_slot'] = $meta['time_slot']['display'];
|
53 |
}
|
54 |
-
if (
|
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(
|
59 |
|
60 |
-
foreach (
|
61 |
-
$custom_meta[
|
62 |
-
unset(
|
63 |
}
|
64 |
|
65 |
-
if (
|
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(
|
74 |
} // End if().
|
75 |
|
76 |
-
if (
|
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(
|
88 |
-
|
|
|
89 |
return $price;
|
90 |
}
|
91 |
|
92 |
$meta = $wl_product['meta'];
|
93 |
|
94 |
-
if (
|
95 |
|
96 |
$price = $meta['bkap_price_charged'];
|
97 |
|
98 |
-
return wc_price(
|
99 |
}
|
100 |
|
101 |
return $price;
|
102 |
}
|
103 |
|
104 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
34 |
-
|
|
|
35 |
return $meta;
|
36 |
}
|
37 |
-
$product = wc_get_product(
|
38 |
-
if (
|
39 |
-
$booking_form = (
|
40 |
-
$post_data
|
41 |
-
foreach (
|
42 |
-
$post_data[
|
43 |
}
|
44 |
-
$booking_data = (
|
45 |
-
$meta
|
46 |
-
foreach (
|
47 |
-
if (
|
48 |
-
$meta[
|
49 |
-
'key'
|
50 |
'display' => $value,
|
51 |
);
|
52 |
}
|
@@ -56,10 +79,10 @@ if ( class_exists( 'WC_Bookings' ) ) {
|
|
56 |
return $meta;
|
57 |
}
|
58 |
|
59 |
-
add_filter(
|
60 |
} // End if().
|
61 |
|
62 |
-
if (
|
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(
|
74 |
-
|
|
|
75 |
return $price;
|
76 |
}
|
77 |
-
if (
|
78 |
-
$booking_form = (
|
79 |
-
$cost
|
80 |
-
if (
|
81 |
return $price;
|
82 |
}
|
83 |
|
84 |
-
if (
|
85 |
-
if (
|
86 |
-
$display_price = wc_get_price_including_tax(
|
87 |
} else {
|
88 |
-
$display_price = $product->get_price_including_tax(
|
89 |
}
|
90 |
} else {
|
91 |
-
if (
|
92 |
-
$display_price = wc_get_price_excluding_tax(
|
93 |
} else {
|
94 |
-
$display_price = $product->get_price_excluding_tax(
|
95 |
}
|
96 |
}
|
97 |
|
98 |
-
if (
|
99 |
-
$price_suffix = $product->get_price_suffix(
|
100 |
} else {
|
101 |
$price_suffix = $product->get_price_suffix();
|
102 |
}
|
103 |
-
$price = wc_price(
|
104 |
}
|
105 |
|
106 |
return $price;
|
107 |
}
|
108 |
|
109 |
-
add_filter(
|
110 |
} // End if().
|
111 |
|
112 |
-
if (
|
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(
|
125 |
-
|
|
|
126 |
return $status;
|
127 |
}
|
128 |
-
if (
|
129 |
-
$booking_form = (
|
130 |
-
$cost
|
131 |
-
if (
|
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(
|
140 |
}
|
141 |
|
142 |
|
143 |
-
add_filter(
|
144 |
|
145 |
-
function tinvwl_item_product_type_woocommerce_bookings(
|
|
|
146 |
|
147 |
-
if (
|
148 |
-
$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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
31 |
-
|
|
|
32 |
$meta = array();
|
33 |
} // End if().
|
34 |
|
35 |
return $meta;
|
36 |
}
|
37 |
|
38 |
-
add_filter(
|
39 |
} // End if().
|
40 |
|
41 |
-
if (
|
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(
|
50 |
-
|
|
|
51 |
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
52 |
|
53 |
$components = $product->get_components();
|
54 |
-
foreach (
|
55 |
-
$composited_product_id
|
56 |
-
$composited_product_quantity = isset(
|
57 |
|
58 |
-
$composited_variation_id = isset(
|
59 |
|
60 |
-
if (
|
61 |
|
62 |
-
$composited_product_wrapper = $component->get_option(
|
63 |
|
64 |
-
if (
|
65 |
continue;
|
66 |
}
|
67 |
|
68 |
$composited_product = $composited_product_wrapper->get_product();
|
69 |
|
70 |
-
if (
|
71 |
$composited_product_quantity = 1;
|
72 |
}
|
73 |
|
74 |
-
$product_url
|
75 |
$product_image = $composited_product->get_image();
|
76 |
-
$product_title = is_callable(
|
77 |
$composited_product,
|
78 |
'get_name'
|
79 |
-
)
|
80 |
$product_price = $composited_product->get_price();
|
81 |
|
82 |
-
$component_option = $product->get_component_option(
|
83 |
|
84 |
$discount = $component_option->get_discount();
|
85 |
|
86 |
-
if (
|
87 |
-
$product_price = $product_price * (
|
88 |
}
|
89 |
-
$product_price = wc_price(
|
90 |
|
91 |
-
if (
|
92 |
-
if (
|
93 |
$product_price = '';
|
94 |
-
} elseif (
|
95 |
$product_price = '';
|
96 |
-
} elseif (
|
97 |
-
if (
|
98 |
$product_price = '<span class="component_table_item_price">' . $product_price . '</span>';
|
99 |
}
|
100 |
}
|
101 |
}
|
102 |
|
103 |
-
if (
|
104 |
-
$product_image = sprintf(
|
105 |
-
$product_title = sprintf(
|
106 |
}
|
107 |
-
$product_title .= tinv_wishlist_get_item_data(
|
108 |
|
109 |
-
$availability = (array)
|
110 |
-
if (
|
111 |
$availability['availability'] = '';
|
112 |
}
|
113 |
-
if (
|
114 |
$availability['class'] = '';
|
115 |
}
|
116 |
-
$availability_html = empty(
|
117 |
-
$row_string
|
118 |
-
$row_string
|
119 |
-
if (
|
120 |
-
$row_string .= (
|
121 |
}
|
122 |
-
if (
|
123 |
$row_string .= '<td class="product-date"> </td>';
|
124 |
}
|
125 |
-
if (
|
126 |
$row_string .= '<td class="product-stock">%5$s</td>';
|
127 |
}
|
128 |
-
if (
|
129 |
$row_string .= '<td class="product-quantity"> </td>';
|
130 |
}
|
131 |
-
if (
|
132 |
$row_string .= '<td class="product-action"> </td>';
|
133 |
}
|
134 |
$row_string .= '</tr>';
|
135 |
|
136 |
-
if (
|
137 |
$product_price = $availability_html = $product_title = '';
|
138 |
}
|
139 |
|
140 |
-
echo sprintf(
|
141 |
$component,
|
142 |
'get_name'
|
143 |
-
)
|
144 |
|
145 |
-
if (
|
146 |
|
147 |
-
$wl_product_bundle
|
148 |
$wl_product_bundle['product_id'] = $composited_product->get_id();
|
149 |
|
150 |
$component_meta = array();
|
151 |
|
152 |
-
foreach (
|
153 |
-
if (
|
154 |
|
155 |
-
$component_meta[
|
156 |
}
|
157 |
}
|
158 |
|
159 |
$wl_product_bundle['meta'] = $component_meta;
|
160 |
|
161 |
-
tinvwl_row_woocommerce_product_bundles(
|
162 |
}
|
163 |
} // End if().
|
164 |
} // End foreach().
|
165 |
} // End if().
|
166 |
}
|
167 |
|
168 |
-
add_action(
|
169 |
} // End if().
|
170 |
|
171 |
-
if (
|
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(
|
183 |
-
|
184 |
-
|
185 |
-
$
|
|
|
186 |
$regular_price = $product->get_regular_price();
|
187 |
-
foreach (
|
188 |
-
$composited_product_id
|
189 |
-
$composited_product_quantity = isset(
|
190 |
|
191 |
-
$composited_variation_id = isset(
|
192 |
|
193 |
-
if (
|
194 |
-
$composited_product_wrapper = $component->get_option(
|
195 |
-
if (
|
196 |
|
197 |
$composited_product = $composited_product_wrapper->get_product();
|
198 |
-
if (
|
199 |
|
200 |
-
$wl_product_bundle
|
201 |
$wl_product_bundle['product_id'] = $composited_product->get_id();
|
202 |
|
203 |
$component_meta = array();
|
204 |
|
205 |
-
foreach (
|
206 |
-
if (
|
207 |
|
208 |
-
$component_meta[
|
209 |
}
|
210 |
}
|
211 |
|
212 |
$wl_product_bundle['meta'] = $component_meta;
|
213 |
|
214 |
-
$bundle_price
|
215 |
$regular_price += $bundle_price;
|
216 |
|
217 |
-
if (
|
218 |
-
$bundle_price = empty(
|
219 |
}
|
220 |
$_price += $bundle_price;
|
221 |
|
222 |
continue;
|
223 |
}
|
224 |
|
225 |
-
$_price
|
226 |
$regular_price += $composited_product_wrapper->get_regular_price() * $composited_product_quantity;
|
227 |
}
|
228 |
}
|
229 |
}
|
230 |
|
231 |
-
$price = wc_price(
|
232 |
|
233 |
}
|
234 |
|
235 |
return $price;
|
236 |
}
|
237 |
|
238 |
-
add_filter(
|
239 |
} // End if().
|
240 |
|
241 |
-
if (
|
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(
|
|
|
251 |
|
252 |
-
foreach (
|
253 |
-
if (
|
254 |
|
255 |
-
$meta[
|
256 |
}
|
257 |
}
|
258 |
|
259 |
return $meta;
|
260 |
}
|
261 |
|
262 |
-
add_filter(
|
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>') . ' <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 × %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"> </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"> </td>';
|
154 |
}
|
155 |
+
if (tinv_get_option('product_table', 'add_to_cart')) {
|
156 |
$row_string .= '<td class="product-action"> </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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
32 |
|
33 |
-
if (
|
34 |
|
35 |
$posted = array();
|
36 |
|
37 |
-
foreach (
|
38 |
-
$posted[
|
39 |
}
|
40 |
|
41 |
-
$price = wc_price(
|
42 |
}
|
43 |
|
44 |
return $price;
|
45 |
}
|
46 |
|
47 |
-
add_filter(
|
48 |
} // End if().
|
49 |
|
50 |
-
if (
|
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(
|
|
|
62 |
|
63 |
-
if (
|
64 |
|
65 |
-
$id
|
66 |
-
$product = wc_get_product(
|
67 |
-
if (
|
68 |
|
69 |
// Get fields to save values for
|
70 |
-
$fields = WCCF_Product_Field_Controller::get_filtered(
|
71 |
-
'item_id'
|
72 |
'child_id' => $variation_id,
|
73 |
-
)
|
74 |
|
75 |
// Set quantity
|
76 |
-
$quantity
|
77 |
-
$quantity_index
|
78 |
$display_pricing = null;
|
79 |
|
80 |
// Check if pricing can be displayed for this product
|
81 |
-
if (
|
82 |
-
$display_pricing = !
|
83 |
}
|
84 |
|
85 |
-
foreach (
|
86 |
|
87 |
// Check how many times to iterate the same field (used for quantity-based product fields)
|
88 |
-
if (
|
89 |
-
$iterations = (
|
90 |
-
$i
|
91 |
} else {
|
92 |
-
$iterations = (
|
93 |
-
$i
|
94 |
}
|
95 |
|
96 |
// Start iteration of the same field
|
97 |
-
for (
|
98 |
|
99 |
// Get field id
|
100 |
-
$field_id = $field->get_id() . (
|
101 |
|
102 |
// Special handling for files
|
103 |
-
if (
|
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 (
|
110 |
|
111 |
// Get field value
|
112 |
-
if (
|
113 |
-
$field_value = $item_data['wccf']['display']['product_field'][
|
114 |
}
|
115 |
|
116 |
// Prepare multiselect field values
|
117 |
-
if (
|
118 |
|
119 |
// Ensure that value is array
|
120 |
-
$value = !
|
121 |
|
122 |
// Filter out hidden placeholder input value
|
123 |
-
$value = array_filter(
|
124 |
-
return trim(
|
125 |
-
}
|
126 |
} else {
|
127 |
-
$value = stripslashes(
|
128 |
}
|
129 |
|
130 |
$item_data[] = array(
|
131 |
-
'key'
|
132 |
-
'display' => $field->format_display_value(
|
133 |
);
|
134 |
|
135 |
}
|
@@ -137,13 +161,13 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) )
|
|
137 |
}
|
138 |
}
|
139 |
|
140 |
-
unset(
|
141 |
-
unset(
|
142 |
}
|
143 |
}
|
144 |
|
145 |
return $item_data;
|
146 |
}
|
147 |
|
148 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
/**
|
23 |
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
24 |
*/
|
25 |
-
function tinvwl_gf_productaddon_support()
|
26 |
-
|
|
|
27 |
return false;
|
28 |
}
|
29 |
-
if (
|
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(
|
41 |
-
|
|
|
42 |
|
43 |
-
return (
|
44 |
}
|
45 |
|
46 |
-
add_filter(
|
47 |
}
|
48 |
|
49 |
-
if (
|
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(
|
60 |
-
|
|
|
61 |
|
62 |
-
return (
|
63 |
}
|
64 |
|
65 |
-
add_filter(
|
66 |
}
|
67 |
|
68 |
-
if (
|
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(
|
79 |
-
|
|
|
80 |
|
81 |
-
return (
|
82 |
}
|
83 |
|
84 |
-
add_filter(
|
85 |
}
|
86 |
}
|
87 |
|
88 |
-
add_action(
|
89 |
} // End if().
|
90 |
|
91 |
-
if (
|
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(
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
104 |
$_meta = array();
|
105 |
-
foreach (
|
106 |
-
$field_name = $field->get_first_input_id(
|
107 |
-
if (
|
108 |
-
$meta[
|
109 |
-
$_meta[
|
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(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
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(
|
42 |
} // End if().
|
43 |
|
44 |
-
if (
|
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(
|
53 |
-
|
|
|
54 |
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
55 |
-
$mnm_items
|
56 |
-
if (
|
57 |
-
foreach (
|
58 |
$item_quantity = 0;
|
59 |
-
if (
|
60 |
-
$item_quantity = absint(
|
61 |
}
|
62 |
-
if (
|
63 |
continue;
|
64 |
}
|
65 |
|
66 |
-
$product_url
|
67 |
$product_image = $mnm_item->get_image();
|
68 |
-
$product_title = is_callable(
|
69 |
$mnm_item,
|
70 |
'get_name'
|
71 |
-
)
|
72 |
$product_price = $mnm_item->get_price_html();
|
73 |
-
if (
|
74 |
-
$product_image = sprintf(
|
75 |
-
$product_title = sprintf(
|
76 |
}
|
77 |
-
$product_title .= tinv_wishlist_get_item_data(
|
78 |
|
79 |
-
$availability = (array)
|
80 |
-
if (
|
81 |
$availability['availability'] = '';
|
82 |
}
|
83 |
-
if (
|
84 |
$availability['class'] = '';
|
85 |
}
|
86 |
-
$availability_html = empty(
|
87 |
-
$row_string
|
88 |
-
$row_string
|
89 |
-
if (
|
90 |
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
91 |
}
|
92 |
-
if (
|
93 |
$row_string .= '<td class="product-date"> </td>';
|
94 |
}
|
95 |
-
if (
|
96 |
$row_string .= '<td class="product-stock">%4$s</td>';
|
97 |
}
|
98 |
-
if (
|
99 |
$row_string .= '<td class="product-action"> </td>';
|
100 |
}
|
101 |
$row_string .= '</tr>';
|
102 |
|
103 |
-
echo sprintf(
|
104 |
} // End foreach().
|
105 |
} // End if().
|
106 |
} // End if().
|
107 |
}
|
108 |
|
109 |
-
add_action(
|
110 |
} // End if().
|
111 |
|
112 |
-
if (
|
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(
|
124 |
-
|
|
|
125 |
$mnm_items = $product->get_children();
|
126 |
-
if (
|
127 |
$_price = 0;
|
128 |
-
foreach (
|
129 |
$item_quantity = 0;
|
130 |
-
if (
|
131 |
-
$item_quantity = absint(
|
132 |
}
|
133 |
-
if (
|
134 |
continue;
|
135 |
}
|
136 |
-
$_price += wc_get_price_to_display(
|
137 |
}
|
138 |
-
if (
|
139 |
-
if (
|
140 |
-
$price = wc_format_sale_price(
|
141 |
} else {
|
142 |
-
$price = wc_price(
|
143 |
}
|
144 |
-
$price = apply_filters(
|
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(
|
153 |
} // End if().
|
154 |
|
155 |
-
if (
|
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(
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
171 |
}
|
172 |
}
|
173 |
-
if (
|
174 |
-
unset(
|
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(
|
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"> </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 × %5$s</td>';
|
115 |
}
|
116 |
+
if (tinv_get_option('product_table', 'colm_date')) {
|
117 |
$row_string .= '<td class="product-date"> </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"> </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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
30 |
-
|
|
|
31 |
|
32 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
33 |
|
34 |
// Reload products class.
|
35 |
-
if (
|
36 |
-
$woocommerce_wpml->products = new WCML_Products(
|
37 |
} else {
|
38 |
global $wpml_post_translations;
|
39 |
-
if (
|
40 |
return $post_data;
|
41 |
}
|
42 |
-
$woocommerce_wpml->products = new WCML_Products(
|
43 |
}
|
44 |
|
45 |
-
if (
|
46 |
-
$post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id(
|
47 |
}
|
48 |
-
if (
|
49 |
-
$original_product_language
|
50 |
-
$post_data['product_variation'] = apply_filters(
|
51 |
}
|
52 |
}
|
53 |
|
54 |
return $post_data;
|
55 |
}
|
56 |
|
57 |
-
add_filter(
|
58 |
}
|
59 |
|
60 |
-
if (
|
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(
|
70 |
-
|
|
|
71 |
|
72 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
73 |
|
74 |
// Reload products class.
|
75 |
-
if (
|
76 |
-
$woocommerce_wpml->products = new WCML_Products(
|
77 |
} else {
|
78 |
global $wpml_post_translations;
|
79 |
-
if (
|
80 |
return $product;
|
81 |
}
|
82 |
-
$woocommerce_wpml->products = new WCML_Products(
|
83 |
}
|
84 |
|
85 |
-
if (
|
86 |
-
$product = wc_get_product(
|
87 |
}
|
88 |
|
89 |
}
|
@@ -91,11 +115,11 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_check_product' ) ) {
|
|
91 |
return $product;
|
92 |
}
|
93 |
|
94 |
-
add_filter(
|
95 |
}
|
96 |
|
97 |
|
98 |
-
if (
|
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(
|
108 |
-
|
|
|
109 |
|
110 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
111 |
|
112 |
// Reload products class.
|
113 |
-
if (
|
114 |
-
$woocommerce_wpml->products = new WCML_Products(
|
115 |
} else {
|
116 |
global $wpml_post_translations;
|
117 |
-
if (
|
118 |
return $attr;
|
119 |
}
|
120 |
|
121 |
-
$woocommerce_wpml->products = new WCML_Products(
|
122 |
}
|
123 |
|
124 |
-
if (
|
125 |
-
$attr['product_id'] = $woocommerce_wpml->products->get_original_product_id(
|
126 |
}
|
127 |
-
if (
|
128 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language(
|
129 |
-
$attr['variation_id']
|
130 |
}
|
131 |
}
|
132 |
|
133 |
return $attr;
|
134 |
}
|
135 |
|
136 |
-
add_filter(
|
137 |
}
|
138 |
|
139 |
-
if (
|
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(
|
149 |
-
|
|
|
150 |
|
151 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
152 |
|
153 |
// Reload products class.
|
154 |
-
if (
|
155 |
-
$woocommerce_wpml->products = new WCML_Products(
|
156 |
} else {
|
157 |
global $wpml_post_translations;
|
158 |
-
if (
|
159 |
return $product;
|
160 |
}
|
161 |
-
$woocommerce_wpml->products = new WCML_Products(
|
162 |
}
|
163 |
|
164 |
-
$product_id
|
165 |
-
$variation_id = $product->is_type(
|
166 |
|
167 |
-
if (
|
168 |
-
$product_id = $woocommerce_wpml->products->get_original_product_id(
|
169 |
}
|
170 |
-
if (
|
171 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language(
|
172 |
-
$variation_id
|
173 |
}
|
174 |
-
if (
|
175 |
-
$product = wc_get_product(
|
176 |
}
|
177 |
}
|
178 |
|
179 |
return $product;
|
180 |
}
|
181 |
|
182 |
-
add_filter(
|
183 |
}
|
184 |
|
185 |
-
if (
|
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(
|
195 |
-
|
|
|
196 |
|
197 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
198 |
|
199 |
// Reload products class.
|
200 |
-
if (
|
201 |
-
$woocommerce_wpml->products = new WCML_Products(
|
202 |
} else {
|
203 |
global $wpml_post_translations;
|
204 |
-
if (
|
205 |
return $post_data;
|
206 |
}
|
207 |
-
$woocommerce_wpml->products = new WCML_Products(
|
208 |
}
|
209 |
|
210 |
-
if (
|
211 |
-
$post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id(
|
212 |
}
|
213 |
-
if (
|
214 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language(
|
215 |
-
$post_data['variation_id'] = apply_filters(
|
216 |
}
|
217 |
}
|
218 |
|
219 |
return $post_data;
|
220 |
}
|
221 |
|
222 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (
|
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
|
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
|
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 (
|
86 |
$item_meta[] = array(
|
87 |
-
'key'
|
88 |
'display' => $qty,
|
89 |
);
|
90 |
-
$total_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
|
99 |
$file_thumbs_html .= ppom_show_file_thumb($file_name);
|
100 |
}
|
101 |
$item_meta[] = array(
|
102 |
-
'key'
|
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
|
113 |
$file_thumbs_html .= ppom_show_file_thumb($file_name, true);
|
114 |
}
|
115 |
$item_meta[] = array(
|
116 |
-
'key'
|
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
|
126 |
-
$image_html
|
127 |
-
$meta_key
|
128 |
$item_meta[] = array(
|
129 |
-
'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
|
141 |
-
$audio_url
|
142 |
-
$audio_html
|
143 |
-
$meta_key
|
144 |
$item_meta[] = array(
|
145 |
-
'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'
|
155 |
'display' => $value['option'] . ' (' . $value['qty'] . ')',
|
156 |
);
|
157 |
break;
|
158 |
|
159 |
default:
|
160 |
-
$value
|
161 |
$item_meta[] = array(
|
162 |
-
'key'
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
32 |
|
33 |
-
if (
|
34 |
|
35 |
-
$id = (
|
36 |
|
37 |
-
if (
|
38 |
-
$product_addons = get_product_addons(
|
39 |
} else {
|
40 |
-
$product_addons = WC_Product_Addons_Helper::get_product_addons(
|
41 |
}
|
42 |
|
43 |
-
if (
|
44 |
|
45 |
$field = null;
|
46 |
|
47 |
-
foreach (
|
48 |
-
foreach (
|
49 |
$original_data = 'addon-' . $addon['field_name'];
|
50 |
|
51 |
-
$value = isset(
|
52 |
|
53 |
-
if (
|
54 |
continue;
|
55 |
}
|
56 |
|
57 |
-
if (
|
58 |
-
$value = array_map(
|
59 |
} else {
|
60 |
-
$value = stripslashes(
|
61 |
}
|
62 |
-
include_once(
|
63 |
-
switch (
|
64 |
case 'checkbox':
|
65 |
-
$value = json_decode(
|
66 |
-
include_once(
|
67 |
-
$field = new WC_Product_Addons_Field_List(
|
68 |
break;
|
69 |
case 'multiple_choice':
|
70 |
-
switch (
|
71 |
case 'radiobutton':
|
72 |
-
$value = json_decode(
|
73 |
-
include_once(
|
74 |
-
$field = new WC_Product_Addons_Field_List(
|
75 |
break;
|
76 |
case 'images':
|
77 |
case 'select':
|
78 |
-
include_once(
|
79 |
-
$field = new WC_Product_Addons_Field_Select(
|
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(
|
88 |
-
$field = new WC_Product_Addons_Field_Custom(
|
89 |
break;
|
90 |
case 'file_upload':
|
91 |
-
include_once(
|
92 |
-
$field = new WC_Product_Addons_Field_File_Upload(
|
93 |
-
if (
|
94 |
-
$field->value = basename(
|
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 (
|
103 |
$data = $field->get_cart_item_data();
|
104 |
-
unset(
|
105 |
-
foreach (
|
106 |
$name = $opt['name'];
|
107 |
|
108 |
-
if (
|
109 |
-
$name .= ' (' . wc_price(
|
110 |
}
|
111 |
|
112 |
$item_data[] = array(
|
113 |
-
'key'
|
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(
|
127 |
} // End if().
|
128 |
|
129 |
-
if (
|
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(
|
|
|
141 |
|
142 |
-
if (
|
143 |
|
144 |
-
if (
|
145 |
-
$product_addons = get_product_addons(
|
146 |
} else {
|
147 |
-
$product_addons = WC_Product_Addons_Helper::get_product_addons(
|
148 |
}
|
149 |
|
150 |
-
if (
|
151 |
|
152 |
$price = 0;
|
153 |
$field = null;
|
154 |
|
155 |
-
foreach (
|
156 |
|
157 |
$original_data = 'addon-' . $addon['field_name'];
|
158 |
|
159 |
-
$value = isset(
|
160 |
-
if (
|
161 |
continue;
|
162 |
}
|
163 |
|
164 |
-
if (
|
165 |
-
$value = array_map(
|
166 |
} else {
|
167 |
-
$value = stripslashes(
|
168 |
}
|
169 |
-
include_once(
|
170 |
-
switch (
|
171 |
case 'checkbox':
|
172 |
-
$value = json_decode(
|
173 |
-
include_once(
|
174 |
-
$field = new WC_Product_Addons_Field_List(
|
175 |
break;
|
176 |
case 'multiple_choice':
|
177 |
-
switch (
|
178 |
case 'radiobutton':
|
179 |
-
$value = json_decode(
|
180 |
-
include_once(
|
181 |
-
$field = new WC_Product_Addons_Field_List(
|
182 |
break;
|
183 |
case 'images':
|
184 |
case 'select':
|
185 |
-
include_once(
|
186 |
-
$field = new WC_Product_Addons_Field_Select(
|
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(
|
195 |
-
$field = new WC_Product_Addons_Field_Custom(
|
196 |
break;
|
197 |
case 'file_upload':
|
198 |
-
include_once(
|
199 |
-
$field = new WC_Product_Addons_Field_File_Upload(
|
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 (
|
207 |
$data = $field->get_cart_item_data();
|
208 |
-
foreach (
|
209 |
-
if (
|
210 |
-
$price += (float)
|
211 |
}
|
212 |
}
|
213 |
}
|
214 |
|
215 |
}
|
216 |
|
217 |
-
$price = wc_price(
|
218 |
}
|
219 |
}
|
220 |
|
221 |
return $price;
|
222 |
}
|
223 |
|
224 |
-
add_filter(
|
225 |
} // End if().
|
226 |
|
227 |
-
add_filter(
|
228 |
|
229 |
-
function tinvwl_meta_woocommerce_product_addons(
|
|
|
230 |
|
231 |
-
if (
|
232 |
-
include_once(
|
233 |
-
include_once(
|
234 |
-
$field = new WC_Product_Addons_Field_File_Upload(
|
235 |
-
foreach (
|
236 |
|
237 |
-
if (
|
238 |
-
$upload = $field->handle_upload(
|
239 |
-
if (
|
240 |
-
$meta[
|
241 |
}
|
242 |
}
|
243 |
}
|
@@ -246,23 +271,24 @@ function tinvwl_meta_woocommerce_product_addons( $meta, $post, $files ) {
|
|
246 |
return $meta;
|
247 |
}
|
248 |
|
249 |
-
add_filter(
|
250 |
|
251 |
-
function tinvwl_cart_meta_woocommerce_product_addons(
|
|
|
252 |
|
253 |
-
if (
|
254 |
-
include_once(
|
255 |
-
include_once(
|
256 |
-
$field = new WC_Product_Addons_Field_File_Upload(
|
257 |
|
258 |
$files = $_FILES;
|
259 |
|
260 |
-
foreach (
|
261 |
|
262 |
-
if (
|
263 |
-
$upload = $field->handle_upload(
|
264 |
-
if (
|
265 |
-
$meta[
|
266 |
}
|
267 |
}
|
268 |
}
|
@@ -272,50 +298,51 @@ function tinvwl_cart_meta_woocommerce_product_addons( $meta ) {
|
|
272 |
}
|
273 |
|
274 |
|
275 |
-
add_filter(
|
276 |
|
277 |
-
function tinvwl_add_to_cart_meta_woocommerce_product_addons(
|
278 |
-
|
|
|
279 |
|
280 |
-
$id = (
|
281 |
|
282 |
-
if (
|
283 |
-
$product_addons = get_product_addons(
|
284 |
} else {
|
285 |
-
$product_addons = WC_Product_Addons_Helper::get_product_addons(
|
286 |
}
|
287 |
|
288 |
-
if (
|
289 |
|
290 |
$field = null;
|
291 |
|
292 |
-
foreach (
|
293 |
-
foreach (
|
294 |
$original_data = 'addon-' . $addon['field_name'];
|
295 |
|
296 |
-
$value = isset(
|
297 |
|
298 |
-
if (
|
299 |
continue;
|
300 |
}
|
301 |
|
302 |
-
if (
|
303 |
-
$value = array_map(
|
304 |
} else {
|
305 |
-
$value = stripslashes(
|
306 |
}
|
307 |
-
include_once(
|
308 |
-
switch (
|
309 |
case 'checkbox':
|
310 |
-
if (
|
311 |
-
$wl_product['meta'][
|
312 |
}
|
313 |
break;
|
314 |
case 'multiple_choice':
|
315 |
-
switch (
|
316 |
case 'radiobutton':
|
317 |
-
if (
|
318 |
-
$wl_product['meta'][
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
31 |
-
|
|
|
32 |
|
33 |
-
if (
|
34 |
$meta = array();
|
35 |
}
|
36 |
|
37 |
return $meta;
|
38 |
}
|
39 |
|
40 |
-
add_filter(
|
41 |
} // End if().
|
42 |
|
43 |
-
if (
|
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(
|
53 |
-
|
|
|
54 |
|
55 |
-
$product_id
|
56 |
$bundled_items = $product->get_bundled_items();
|
57 |
-
if (
|
58 |
-
foreach (
|
59 |
|
60 |
-
$bundled_item_variation_id_request_key = apply_filters(
|
61 |
-
$bundled_variation_id
|
62 |
-
if (
|
63 |
-
$bundled_item->product = wc_get_product(
|
64 |
}
|
65 |
|
66 |
$is_optional = $bundled_item->is_optional();
|
67 |
|
68 |
-
$bundled_item_quantity_request_key = apply_filters(
|
69 |
-
$bundled_product_qty
|
70 |
|
71 |
-
if (
|
72 |
|
73 |
/** Documented in method 'get_posted_bundle_configuration'. */
|
74 |
-
$bundled_item_selected_request_key = apply_filters(
|
75 |
|
76 |
-
if (
|
77 |
$bundled_product_qty = 0;
|
78 |
}
|
79 |
}
|
80 |
-
if (
|
81 |
continue;
|
82 |
}
|
83 |
|
84 |
-
$product_url
|
85 |
$product_image = $bundled_item->product->get_image();
|
86 |
-
$product_title = $bundled_item->has_title_override() ? is_callable(
|
87 |
$bundled_item,
|
88 |
'get_name'
|
89 |
-
)
|
90 |
|
91 |
-
$product_price
|
92 |
$product_price_raw = $bundled_item->product->get_regular_price();
|
93 |
-
$discount
|
94 |
-
$discount
|
95 |
-
$product_price
|
96 |
|
97 |
-
if (
|
98 |
-
$product_image = sprintf(
|
99 |
-
$product_title = sprintf(
|
100 |
}
|
101 |
-
$product_title .= tinv_wishlist_get_item_data(
|
102 |
|
103 |
-
$availability = (array)
|
104 |
-
if (
|
105 |
$availability['availability'] = '';
|
106 |
}
|
107 |
-
if (
|
108 |
$availability['class'] = '';
|
109 |
}
|
110 |
-
$availability_html = empty(
|
111 |
-
$row_string
|
112 |
-
$row_string
|
113 |
-
if (
|
114 |
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
115 |
-
} elseif (
|
116 |
$row_string .= '<td class="product-price"></td>';
|
117 |
}
|
118 |
-
if (
|
119 |
$row_string .= '<td class="product-date"> </td>';
|
120 |
}
|
121 |
-
if (
|
122 |
$row_string .= '<td class="product-stock">%4$s</td>';
|
123 |
}
|
124 |
|
125 |
-
if (
|
126 |
$row_string .= '<td class="product-action"> </td>';
|
127 |
}
|
128 |
$row_string .= '</tr>';
|
129 |
|
130 |
-
echo sprintf(
|
131 |
} // End foreach().
|
132 |
} // End if().
|
133 |
} // End if().
|
134 |
}
|
135 |
|
136 |
-
add_action(
|
137 |
} // End if().
|
138 |
|
139 |
-
if (
|
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(
|
151 |
-
|
|
|
152 |
|
153 |
-
$bundle_price
|
154 |
-
$product_id
|
155 |
$bundled_items = $product->get_bundled_items();
|
156 |
|
157 |
-
if (
|
158 |
|
159 |
$bundled_items_price = 0.0;
|
160 |
|
161 |
-
foreach (
|
162 |
|
163 |
-
$bundled_item_variation_id_request_key = apply_filters(
|
164 |
-
$bundled_variation_id
|
165 |
-
if (
|
166 |
-
$_bundled_product = wc_get_product(
|
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(
|
174 |
-
$bundled_product_qty
|
175 |
|
176 |
-
if (
|
177 |
|
178 |
/** Documented in method 'get_posted_bundle_configuration'. */
|
179 |
-
$bundled_item_selected_request_key = apply_filters(
|
180 |
|
181 |
-
if (
|
182 |
$bundled_product_qty = 0;
|
183 |
}
|
184 |
}
|
185 |
|
186 |
-
if (
|
187 |
$product_price = $_bundled_product->get_regular_price();
|
188 |
|
189 |
-
$discount
|
190 |
-
$product_price = empty(
|
191 |
|
192 |
-
$bundled_item_price = (double)
|
193 |
|
194 |
-
$bundled_items_price += (double)
|
195 |
}
|
196 |
|
197 |
} // End foreach().
|
198 |
-
$price = (double)
|
199 |
-
if (
|
200 |
-
$price = apply_filters(
|
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(
|
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"> </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 × %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"> </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"> </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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
33 |
}
|
34 |
|
35 |
}
|
36 |
|
37 |
-
add_filter(
|
38 |
-
return new TINVWL_Product_Table_Data_Wishlist(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
30 |
|
31 |
-
if (
|
32 |
-
$product_types['redq_rental'] = __(
|
33 |
}
|
34 |
|
35 |
return $product_types;
|
36 |
}
|
37 |
|
38 |
-
add_filter(
|
39 |
}
|
40 |
|
41 |
-
if (
|
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(
|
53 |
-
|
|
|
54 |
return $meta;
|
55 |
}
|
56 |
|
57 |
-
$product_type = wc_get_product(
|
58 |
|
59 |
-
if (
|
60 |
|
61 |
$custom_data = array();
|
62 |
|
63 |
-
$options_data
|
64 |
$options_data['quote_id'] = '';
|
65 |
|
66 |
-
$get_labels
|
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
|
77 |
-
$get_displays = redq_rental_get_settings(
|
78 |
-
$displays
|
79 |
|
80 |
-
$get_conditions
|
81 |
$conditional_data = $get_conditions['conditions'];
|
82 |
|
83 |
-
$get_general
|
84 |
$general_data = $get_general['general'];
|
85 |
|
86 |
-
if (
|
87 |
$custom_data[] = array(
|
88 |
-
'key'
|
89 |
'display' => '#' . $meta['quote_id']['display'],
|
90 |
|
91 |
);
|
92 |
}
|
93 |
|
94 |
-
if (
|
95 |
$custom_data[] = array(
|
96 |
-
'key'
|
97 |
'display' => $meta['pickup_location']['display']['address'],
|
98 |
|
99 |
);
|
100 |
}
|
101 |
|
102 |
-
if (
|
103 |
$custom_data[] = array(
|
104 |
-
'key'
|
105 |
-
'display' => wc_price(
|
106 |
|
107 |
);
|
108 |
}
|
109 |
|
110 |
-
if (
|
111 |
$custom_data[] = array(
|
112 |
-
'key'
|
113 |
'display' => $meta['dropoff_location']['display']['address'],
|
114 |
|
115 |
);
|
116 |
}
|
117 |
|
118 |
-
if (
|
119 |
$custom_data[] = array(
|
120 |
-
'key'
|
121 |
-
'display' => wc_price(
|
122 |
|
123 |
);
|
124 |
}
|
125 |
|
126 |
-
if (
|
127 |
$custom_data[] = array(
|
128 |
-
'key'
|
129 |
-
'display' => wc_price(
|
130 |
|
131 |
);
|
132 |
}
|
133 |
|
134 |
-
if (
|
135 |
$cat_name = '';
|
136 |
-
foreach (
|
137 |
-
if (
|
138 |
-
$cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price(
|
139 |
} else {
|
140 |
-
$cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price(
|
141 |
}
|
142 |
}
|
143 |
$custom_data[] = array(
|
144 |
-
'key'
|
145 |
'display' => $cat_name,
|
146 |
|
147 |
);
|
148 |
}
|
149 |
|
150 |
-
if (
|
151 |
$resource_name = '';
|
152 |
-
foreach (
|
153 |
-
if (
|
154 |
-
$resource_name .= $value['resource_name'] . ' ( ' . wc_price(
|
155 |
} else {
|
156 |
-
$resource_name .= $value['resource_name'] . ' ( ' . wc_price(
|
157 |
}
|
158 |
}
|
159 |
$custom_data[] = array(
|
160 |
-
'key'
|
161 |
'display' => $resource_name,
|
162 |
|
163 |
);
|
164 |
}
|
165 |
|
166 |
-
if (
|
167 |
$security_deposite_name = '';
|
168 |
-
foreach (
|
169 |
-
if (
|
170 |
-
$security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price(
|
171 |
} else {
|
172 |
-
$security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price(
|
173 |
}
|
174 |
}
|
175 |
$custom_data[] = array(
|
176 |
-
'key'
|
177 |
'display' => $security_deposite_name,
|
178 |
|
179 |
);
|
180 |
}
|
181 |
|
182 |
-
if (
|
183 |
$custom_data[] = array(
|
184 |
-
'key'
|
185 |
'display' => $meta['adults_info']['display']['person_count'],
|
186 |
|
187 |
);
|
188 |
}
|
189 |
|
190 |
-
if (
|
191 |
$custom_data[] = array(
|
192 |
-
'key'
|
193 |
'display' => $meta['childs_info']['display']['person_count'],
|
194 |
|
195 |
);
|
196 |
}
|
197 |
|
198 |
|
199 |
-
if (
|
200 |
|
201 |
-
$pickup_date_time = convert_to_output_format(
|
202 |
|
203 |
-
if (
|
204 |
-
$pickup_date_time = $pickup_date_time . ' ' . esc_html__(
|
205 |
}
|
206 |
$custom_data[] = array(
|
207 |
-
'key'
|
208 |
'display' => $pickup_date_time,
|
209 |
|
210 |
);
|
211 |
}
|
212 |
|
213 |
-
if (
|
214 |
|
215 |
-
$return_date_time = convert_to_output_format(
|
216 |
|
217 |
-
if (
|
218 |
-
$return_date_time = $return_date_time . ' ' . esc_html__(
|
219 |
}
|
220 |
|
221 |
$custom_data[] = array(
|
222 |
-
'key'
|
223 |
'display' => $return_date_time,
|
224 |
|
225 |
);
|
226 |
}
|
227 |
|
228 |
-
if (
|
229 |
-
if (
|
230 |
$custom_data[] = array(
|
231 |
-
'key'
|
232 |
'display' => $meta['rental_days_and_costs']['display']['days'],
|
233 |
|
234 |
);
|
235 |
} else {
|
236 |
$custom_data[] = array(
|
237 |
-
'key'
|
238 |
'display' => $meta['rental_days_and_costs']['display']['hours'],
|
239 |
|
240 |
);
|
241 |
}
|
242 |
|
243 |
-
if (
|
244 |
$custom_data[] = array(
|
245 |
-
'key'
|
246 |
-
'display' => wc_price(
|
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(
|
259 |
} // End if().
|
260 |
|
261 |
-
if (
|
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(
|
273 |
-
|
|
|
274 |
return $price;
|
275 |
}
|
276 |
|
277 |
$product_type = $product->get_type();
|
278 |
|
279 |
-
if (
|
280 |
$meta = $wl_product['meta'];
|
281 |
|
282 |
-
if (
|
283 |
|
284 |
$price = $meta['quote_price'];
|
285 |
|
286 |
-
return wc_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(
|
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.
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
32 |
-
|
33 |
-
|
34 |
-
$
|
35 |
-
$
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
$post_data = array();
|
41 |
-
foreach (
|
42 |
-
$post_data[
|
43 |
}
|
44 |
$post_data['add-to-cart'] = $meta['tcaddtocart']['display'];
|
45 |
-
$post_data['product_id']
|
46 |
-
if (
|
47 |
$post_data['variation_id'] = $variation_id;
|
48 |
}
|
49 |
$post_data['quantity'] = 1;
|
50 |
|
51 |
-
$cart_class = version_compare(
|
52 |
|
53 |
-
$cart_item = $cart_class->add_cart_item_data_helper(
|
54 |
-
if (
|
55 |
-
$cart_item['quantity']
|
56 |
-
$cart_item['data']
|
57 |
$cart_item['tm_cart_item_key'] = '';
|
58 |
-
$cart_item['product_id']
|
59 |
-
$item_data
|
60 |
|
61 |
-
foreach (
|
62 |
// Set hidden to true to not display meta on cart.
|
63 |
-
if (
|
64 |
-
unset(
|
65 |
continue;
|
66 |
}
|
67 |
-
$item_data[
|
68 |
-
$item_data[
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
} // End if().
|
83 |
|
84 |
-
if (
|
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(
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
$
|
101 |
-
$
|
102 |
-
|
|
|
103 |
$product_id = $wl_product['product_id'];
|
104 |
-
$has_epo
|
105 |
-
if (
|
106 |
|
107 |
-
$cart_class = version_compare(
|
108 |
|
109 |
-
$cart_item
|
110 |
$cart_item['quantity'] = 1;
|
111 |
-
$cart_item['data']
|
112 |
-
|
113 |
-
$product_price = apply_filters(
|
114 |
-
if (
|
115 |
-
$to_currency = version_compare(
|
116 |
-
foreach (
|
117 |
-
if (
|
118 |
-
$value
|
119 |
$product_price += $value;
|
120 |
} else {
|
121 |
-
$product_price += floatval(
|
122 |
}
|
123 |
}
|
124 |
}
|
125 |
|
126 |
-
$price = apply_filters(
|
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(
|
135 |
} // End if().
|
136 |
|
137 |
-
add_filter(
|
138 |
|
139 |
-
function tinvwl_meta_woocommerce_tm_extra_product_options(
|
|
|
140 |
|
141 |
-
if (
|
142 |
-
foreach (
|
143 |
|
144 |
-
if (
|
145 |
-
$upload = THEMECOMPLETE_EPO()->upload_file(
|
146 |
-
if (
|
147 |
-
$meta[
|
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(
|
157 |
|
158 |
-
function tinvwl_cart_meta_woocommerce_tm_extra_product_options(
|
|
|
159 |
|
160 |
-
if (
|
161 |
|
162 |
$files = $_FILES;
|
163 |
|
164 |
-
foreach (
|
165 |
|
166 |
-
if (
|
167 |
-
$upload = THEMECOMPLETE_EPO()->upload_file(
|
168 |
-
if (
|
169 |
-
$meta[
|
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>') . ' ';
|
185 |
+
$row_string .= ($element['show_image']) ? '<td class="product-thumbnail">%2$s</td>' : '<td class="product-thumbnail"> </td>';
|
186 |
+
|
187 |
+
$row_string .= ($element['show_title']) ? '<td class="product-name">%1$s</td>' : '<td class="product-name"> </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 × %6$s</td>' : '<td class="product-price">× %6$s</td>';
|
191 |
+
}
|
192 |
+
if (tinv_get_option('product_table', 'colm_date')) {
|
193 |
+
$row_string .= '<td class="product-date"> </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"> </td>';
|
200 |
+
}
|
201 |
+
if (tinv_get_option('product_table', 'add_to_cart')) {
|
202 |
+
$row_string .= '<td class="product-action"> </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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Disable cache for WP Fastest Cache
|
23 |
*/
|
24 |
-
function tinvwl_wp_fastest_cache_reject()
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
$ids
|
29 |
-
tinv_get_option(
|
30 |
-
tinv_get_option(
|
31 |
);
|
32 |
-
$pages
|
33 |
-
$languages = apply_filters(
|
34 |
'skip_missing' => 0,
|
35 |
-
'orderby'
|
36 |
-
)
|
37 |
-
if (
|
38 |
-
foreach (
|
39 |
-
foreach (
|
40 |
-
$pages[] = apply_filters(
|
41 |
}
|
42 |
}
|
43 |
-
$pages = array_unique(
|
44 |
}
|
45 |
-
$pages = array_filter(
|
46 |
-
if (
|
47 |
-
foreach (
|
48 |
-
$pages[
|
49 |
}
|
50 |
}
|
51 |
-
$pages = array_unique(
|
52 |
-
$pages = array_filter(
|
53 |
|
54 |
-
$rules_std = json_decode(
|
55 |
-
$ex_pages
|
56 |
-
$rules_std = is_array(
|
57 |
-
foreach (
|
58 |
-
$value['type'] = isset(
|
59 |
-
if (
|
60 |
$ex_pages[] = $value['content'];
|
61 |
}
|
62 |
}
|
63 |
-
$ex_pages = array_unique(
|
64 |
-
$ex_pages = array_filter(
|
65 |
-
$changed
|
66 |
|
67 |
-
foreach (
|
68 |
-
$page = preg_replace(
|
69 |
|
70 |
-
if (
|
71 |
-
$changed
|
72 |
$rules_std[] = array(
|
73 |
-
'prefix'
|
74 |
'content' => $page,
|
75 |
-
'type'
|
76 |
);
|
77 |
}
|
78 |
}
|
79 |
-
if (
|
80 |
-
$data = json_encode(
|
81 |
-
update_option(
|
82 |
}
|
83 |
|
84 |
} // End if().
|
85 |
}
|
86 |
|
87 |
-
add_action(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
31 |
-
|
|
|
32 |
// form fields - input
|
33 |
$tags['input'] = array(
|
34 |
'class' => array(),
|
35 |
-
'id'
|
36 |
-
'name'
|
37 |
'value' => array(),
|
38 |
-
'type'
|
39 |
);
|
40 |
// select
|
41 |
$tags['select'] = array(
|
42 |
'class' => array(),
|
43 |
-
'id'
|
44 |
-
'name'
|
45 |
'value' => array(),
|
46 |
-
'type'
|
47 |
);
|
48 |
// select options
|
49 |
$tags['option'] = array(
|
@@ -54,45 +77,49 @@ if ( defined( 'WPGB_VERSION' ) ) {
|
|
54 |
return $tags;
|
55 |
}
|
56 |
|
57 |
-
add_action(
|
58 |
|
59 |
-
function tinvwl_wpkses_fix()
|
60 |
-
|
|
|
61 |
}
|
62 |
|
63 |
-
add_action(
|
64 |
|
65 |
-
function tinvwl_wpkses_fix_remove()
|
66 |
-
|
|
|
67 |
}
|
68 |
|
69 |
// Add custom block to show wishlist button.
|
70 |
-
function tinvwl_wpgb_block_add_to_wishlist(
|
|
|
71 |
$blocks['wishlist_button'] = array(
|
72 |
-
'name'
|
73 |
'render_callback' => 'tinvwl_wpgb_add_to_wishlist',
|
74 |
-
'icon'
|
75 |
);
|
76 |
|
77 |
return $blocks;
|
78 |
}
|
79 |
|
80 |
-
add_filter(
|
81 |
|
82 |
// Output wishlist button.
|
83 |
-
function tinvwl_wpgb_add_to_wishlist()
|
|
|
84 |
|
85 |
$post = wpgb_get_post();
|
86 |
|
87 |
-
if (
|
88 |
return;
|
89 |
}
|
90 |
|
91 |
global $product;
|
92 |
-
$product = wc_get_product(
|
93 |
|
94 |
// Output loop button.
|
95 |
-
echo do_shortcode(
|
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 (
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
// WP Multilang string translations.
|
21 |
-
if (
|
22 |
|
23 |
-
add_filter(
|
24 |
-
add_filter(
|
25 |
-
add_filter(
|
26 |
-
add_filter(
|
27 |
-
add_filter(
|
28 |
-
add_filter(
|
29 |
|
30 |
-
add_filter(
|
31 |
-
add_filter(
|
32 |
|
33 |
-
add_filter(
|
34 |
|
35 |
-
add_filter(
|
36 |
-
add_filter(
|
37 |
|
38 |
-
add_filter(
|
39 |
|
40 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
29 |
$cookies[] = 'tinv_wishlistkey';
|
30 |
|
31 |
return $cookies;
|
32 |
}
|
33 |
}
|
34 |
|
35 |
-
if (
|
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 |
-
|
46 |
-
|
|
|
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 |
-
|
64 |
-
add_filter(
|
|
|
65 |
tinvwl_rocket_flush();
|
66 |
}
|
67 |
|
68 |
-
add_action(
|
69 |
-
add_action(
|
70 |
|
71 |
-
if (
|
72 |
-
add_action(
|
73 |
-
add_action(
|
74 |
-
add_action(
|
75 |
|
76 |
/**
|
77 |
* Clean dynamic cache on wishlist events.
|
78 |
*
|
79 |
*/
|
80 |
-
function tinvwl_rocket_clean_dynamic_cache()
|
|
|
81 |
|
82 |
-
$key = filter_input(
|
83 |
'options' => array(
|
84 |
'regexp' => '/^[A-Fa-f0-9]{6}$/',
|
85 |
),
|
86 |
-
)
|
87 |
|
88 |
-
if (
|
89 |
return;
|
90 |
}
|
91 |
|
92 |
$urls = get_rocket_i18n_uri();
|
93 |
|
94 |
-
if (
|
95 |
return;
|
96 |
}
|
97 |
|
98 |
-
foreach (
|
99 |
|
100 |
-
$directories = glob(
|
101 |
|
102 |
-
if (
|
103 |
-
foreach (
|
104 |
-
tinvwl_rocket_remove_dir(
|
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(
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
124 |
}
|
125 |
}
|
126 |
}
|
127 |
}
|
128 |
|
129 |
|
130 |
-
add_action(
|
131 |
|
132 |
/**
|
133 |
* Prevent cache WooCommerce cart fragments.
|
134 |
*
|
135 |
*/
|
136 |
-
function tinvwl_rocket_empty_cart()
|
|
|
137 |
|
138 |
-
if (
|
139 |
|
140 |
-
$lang = function_exists(
|
141 |
|
142 |
-
if (
|
143 |
-
delete_transient(
|
144 |
}
|
145 |
|
146 |
-
delete_transient(
|
147 |
}
|
148 |
}
|
149 |
|
150 |
-
add_filter(
|
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(
|
|
|
169 |
// User ID is invalid.
|
170 |
-
if (
|
171 |
return $user_id;
|
172 |
}
|
173 |
|
174 |
-
if (
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
33 |
|
34 |
-
foreach (
|
35 |
-
if (
|
36 |
-
unset(
|
37 |
}
|
38 |
}
|
39 |
|
@@ -41,5 +64,5 @@ if ( defined( 'WOOVR_VERSION' ) ) {
|
|
41 |
return $item_data;
|
42 |
}
|
43 |
|
44 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
32 |
|
33 |
-
if (
|
34 |
-
unset(
|
35 |
|
36 |
-
$id = (
|
37 |
|
38 |
-
$base_product = wc_get_product(
|
39 |
|
40 |
-
if (
|
41 |
|
42 |
-
$price = yit_get_display_price(
|
43 |
|
44 |
-
$price_html = wc_price(
|
45 |
|
46 |
$item_data[] = array(
|
47 |
-
'key'
|
48 |
'display' => $price_html,
|
49 |
);
|
50 |
|
51 |
}
|
52 |
-
$type_list = YITH_WAPO_Type::getAllowedGroupTypes(
|
53 |
|
54 |
-
foreach (
|
55 |
|
56 |
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
57 |
|
58 |
-
$value = isset(
|
59 |
|
60 |
-
if (
|
61 |
$value = '';
|
62 |
-
} elseif (
|
63 |
$value = $value['display'][0];
|
64 |
} else {
|
65 |
-
$value = YITH_WAPO_Option::getOptionDataByValueKey(
|
66 |
}
|
67 |
|
68 |
-
unset(
|
69 |
-
if (
|
70 |
$item_data[] = array(
|
71 |
-
'key'
|
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(
|
84 |
} // End if().
|
85 |
|
86 |
-
if (
|
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(
|
|
|
98 |
|
99 |
-
if (
|
100 |
|
101 |
-
$type_list = YITH_WAPO_Type::getAllowedGroupTypes(
|
102 |
|
103 |
-
if (
|
104 |
|
105 |
$addons_total = 0;
|
106 |
|
107 |
-
foreach (
|
108 |
|
109 |
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
110 |
|
111 |
-
$value = isset(
|
112 |
|
113 |
|
114 |
-
if (
|
115 |
continue;
|
116 |
}
|
117 |
|
118 |
-
$addon_price = YITH_WAPO_Option::getOptionDataByValueKey(
|
119 |
|
120 |
-
if (
|
121 |
$addons_total += $addon_price;
|
122 |
}
|
123 |
|
124 |
}
|
125 |
|
126 |
-
$price = wc_price(
|
127 |
}
|
128 |
}
|
129 |
|
130 |
return $price;
|
131 |
}
|
132 |
|
133 |
-
add_filter(
|
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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
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(
|
42 |
} // End if().
|
43 |
|
44 |
-
if (
|
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(
|
57 |
-
|
58 |
-
|
|
|
59 |
$bundled_items = $product->get_bundled_items();
|
60 |
-
foreach (
|
61 |
-
if (
|
62 |
-
if (
|
63 |
continue;
|
64 |
}
|
65 |
}
|
66 |
-
if (
|
67 |
$response = false;
|
68 |
}
|
69 |
}
|
70 |
|
71 |
-
if (
|
72 |
-
$availability
|
73 |
-
'class'
|
74 |
-
'availability' => __(
|
75 |
);
|
76 |
-
$availability_html = '<p class="stock ' . esc_attr(
|
77 |
}
|
78 |
}
|
79 |
|
80 |
return $availability_html;
|
81 |
}
|
82 |
|
83 |
-
add_filter(
|
84 |
} // End if().
|
85 |
|
86 |
-
if (
|
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(
|
95 |
-
|
96 |
-
|
|
|
97 |
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
98 |
-
if (
|
99 |
-
foreach (
|
100 |
$item_quantity = $bundled_item->get_quantity();
|
101 |
-
if (
|
102 |
-
$item_quantity = absint(
|
103 |
}
|
104 |
-
if (
|
105 |
-
if (
|
106 |
$item_quantity = 0;
|
107 |
}
|
108 |
}
|
109 |
-
if (
|
110 |
continue;
|
111 |
}
|
112 |
|
113 |
$product = $bundled_item->get_product();
|
114 |
-
if (
|
115 |
continue;
|
116 |
}
|
117 |
|
118 |
-
$product_url
|
119 |
$product_image = $product->get_image();
|
120 |
-
$product_title = is_callable(
|
121 |
$product,
|
122 |
'get_name'
|
123 |
-
)
|
124 |
$product_price = $product->get_price_html();
|
125 |
-
if (
|
126 |
-
$product_image = sprintf(
|
127 |
-
$product_title = sprintf(
|
128 |
}
|
129 |
-
$product_title .= tinv_wishlist_get_item_data(
|
130 |
|
131 |
-
$availability = (array)
|
132 |
-
if (
|
133 |
$availability['availability'] = '';
|
134 |
}
|
135 |
-
if (
|
136 |
$availability['class'] = '';
|
137 |
}
|
138 |
-
$availability_html = empty(
|
139 |
-
$row_string
|
140 |
-
$row_string
|
141 |
-
if (
|
142 |
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
143 |
}
|
144 |
-
if (
|
145 |
$row_string .= '<td class="product-date"> </td>';
|
146 |
}
|
147 |
-
if (
|
148 |
$row_string .= '<td class="product-stock">%4$s</td>';
|
149 |
}
|
150 |
-
if (
|
151 |
$row_string .= '<td class="product-action"> </td>';
|
152 |
}
|
153 |
$row_string .= '</tr>';
|
154 |
|
155 |
-
echo sprintf(
|
156 |
} // End foreach().
|
157 |
} // End if().
|
158 |
} // End if().
|
159 |
}
|
160 |
|
161 |
-
add_action(
|
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"> </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 × %5$s</td>';
|
168 |
}
|
169 |
+
if (tinv_get_option('product_table', 'colm_date')) {
|
170 |
$row_string .= '<td class="product-date"> </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"> </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 (
|
17 |
-
|
18 |
}
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
32 |
|
33 |
-
foreach (
|
34 |
$prefix = 'yith_';
|
35 |
-
if (
|
36 |
-
unset(
|
37 |
}
|
38 |
}
|
39 |
|
40 |
return $meta;
|
41 |
}
|
42 |
|
43 |
-
add_filter(
|
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.
|
2 |
-
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.
|
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:
|
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:
|
1004 |
msgid "Note"
|
1005 |
msgstr ""
|
1006 |
|
1007 |
-
#: integrations/gift-cards-for-woocommerce.php:
|
1008 |
msgid "To"
|
1009 |
msgstr ""
|
1010 |
|
1011 |
-
#: integrations/gift-cards-for-woocommerce.php:
|
1012 |
msgid "To Email"
|
1013 |
msgstr ""
|
1014 |
|
1015 |
-
#: integrations/gift-cards-for-woocommerce.php:
|
1016 |
msgid "Address"
|
1017 |
msgstr ""
|
1018 |
|
1019 |
-
#: integrations/gift-cards-for-woocommerce.php:
|
1020 |
msgid "Reload existing Gift Card"
|
1021 |
msgstr ""
|
1022 |
|
1023 |
-
#: integrations/mycred.php:
|
1024 |
msgid "WooCommerce Wishlist"
|
1025 |
msgstr ""
|
1026 |
|
1027 |
-
#: integrations/mycred.php:
|
1028 |
msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
|
1029 |
msgstr ""
|
1030 |
|
1031 |
-
#: integrations/mycred.php:
|
1032 |
msgid "Adding Product to Wishlist"
|
1033 |
msgstr ""
|
1034 |
|
1035 |
-
#: integrations/mycred.php:
|
1036 |
msgid "Points"
|
1037 |
msgstr ""
|
1038 |
|
1039 |
-
#: integrations/mycred.php:
|
1040 |
msgid "Limit"
|
1041 |
msgstr ""
|
1042 |
|
1043 |
-
#: integrations/mycred.php:
|
1044 |
msgid "Log Template"
|
1045 |
msgstr ""
|
1046 |
|
1047 |
-
#: integrations/mycred.php:
|
1048 |
msgid "required"
|
1049 |
msgstr ""
|
1050 |
|
1051 |
-
#: integrations/mycred.php:
|
1052 |
msgid "Purchasing Product from Wishlist"
|
1053 |
msgstr ""
|
1054 |
|
1055 |
-
#: integrations/mycred.php:
|
1056 |
msgid "Purchased From Wishlist"
|
1057 |
msgstr ""
|
1058 |
|
1059 |
-
#: integrations/mycred.php:
|
1060 |
msgid "Added To Wishlist"
|
1061 |
msgstr ""
|
1062 |
|
1063 |
-
#: integrations/product-extras-for-woocommerce.php:
|
1064 |
msgid "Flat rate cost"
|
1065 |
msgstr ""
|
1066 |
|
1067 |
-
#: integrations/woo-product-bundle.php:
|
1068 |
msgid "In stock"
|
1069 |
msgstr ""
|
1070 |
|
1071 |
-
#: integrations/woocommerce-gravityforms-product-addons.php:
|
1072 |
msgid "Select options"
|
1073 |
msgstr ""
|
1074 |
|
1075 |
-
#: integrations/wp-grid-builder.php:
|
1076 |
msgid "Wishlist Button"
|
1077 |
msgstr ""
|
1078 |
|
1079 |
-
#: integrations/yith-woocommerce-product-add-ons.php:
|
1080 |
msgid "Base price"
|
1081 |
msgstr ""
|
1082 |
|
1083 |
-
#: integrations/yith-woocommerce-product-bundles.php:
|
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:
|
1100 |
msgid "Create New"
|
1101 |
msgstr ""
|
1102 |
|
1103 |
-
#: public/tinvwl.class.php:
|
1104 |
msgid "Please select some product options before adding this product to your wishlist."
|
1105 |
msgstr ""
|
1106 |
|
1107 |
-
#: public/tinvwl.class.php:
|
1108 |
msgid "No items or actions are selected."
|
1109 |
msgstr ""
|
1110 |
|
1111 |
-
#: public/tinvwl.class.php:
|
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.
|
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.
|
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 (
|
24 |
die;
|
25 |
}
|
26 |
|
27 |
// Define default path.
|
28 |
-
if (
|
29 |
-
define(
|
30 |
}
|
31 |
-
if (
|
32 |
-
define(
|
33 |
}
|
34 |
|
35 |
-
if (
|
36 |
-
define(
|
37 |
}
|
38 |
|
39 |
-
if (
|
40 |
-
define(
|
41 |
}
|
42 |
|
43 |
-
if (
|
44 |
-
define(
|
45 |
}
|
46 |
|
47 |
-
if (
|
48 |
-
define(
|
49 |
}
|
50 |
|
51 |
-
if (
|
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(
|
62 |
-
|
|
|
63 |
return $array1;
|
64 |
}
|
65 |
$args = func_get_args();
|
66 |
-
array_shift(
|
67 |
-
foreach (
|
68 |
-
if (
|
69 |
-
foreach (
|
70 |
-
$array1[
|
71 |
}
|
72 |
}
|
73 |
}
|
@@ -77,7 +78,7 @@ if ( ! function_exists( 'tinv_array_merge' ) ) {
|
|
77 |
}
|
78 |
|
79 |
|
80 |
-
if (
|
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(
|
|
|
90 |
$dir = TINVWL_PATH . 'admin/settings/';
|
91 |
-
if (
|
92 |
return array();
|
93 |
}
|
94 |
-
$files = scandir(
|
95 |
-
foreach (
|
96 |
-
if (
|
97 |
-
$files[
|
98 |
} else {
|
99 |
-
unset(
|
100 |
}
|
101 |
}
|
102 |
$defaults = array();
|
103 |
-
foreach (
|
104 |
-
$class
|
105 |
-
$class
|
106 |
-
$class_methods = get_class_methods(
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
|
|
111 |
}
|
112 |
}
|
113 |
}
|
114 |
-
|
|
|
115 |
return $defaults;
|
116 |
}
|
117 |
-
if (
|
118 |
-
return $defaults[
|
119 |
}
|
120 |
|
121 |
return array();
|
122 |
}
|
123 |
} // End if().
|
124 |
|
125 |
-
if (
|
126 |
|
127 |
/**
|
128 |
* Activation plugin
|
129 |
*/
|
130 |
-
function activation_tinv_wishlist()
|
131 |
-
|
|
|
132 |
TInvWL_Activator::activate();
|
133 |
flush_rewrite_rules();
|
134 |
}
|
135 |
}
|
136 |
}
|
137 |
|
138 |
-
if (
|
139 |
|
140 |
/**
|
141 |
* Deactivation plugin
|
142 |
*/
|
143 |
-
function deactivation_tinv_wishlist()
|
|
|
144 |
flush_rewrite_rules();
|
145 |
}
|
146 |
}
|
147 |
|
148 |
-
if (
|
149 |
|
150 |
/**
|
151 |
* Uninstall plugin
|
152 |
*/
|
153 |
-
function uninstall_tinv_wishlist()
|
154 |
-
|
|
|
155 |
TInvWL_Activator::uninstall();
|
156 |
flush_rewrite_rules();
|
157 |
-
wp_clear_scheduled_hook(
|
158 |
}
|
159 |
}
|
160 |
}
|
161 |
|
162 |
-
if (
|
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(
|
|
|
172 |
$preffix = 'TInvWL';
|
173 |
-
$ext
|
174 |
-
$class
|
175 |
-
$object
|
176 |
-
if (
|
177 |
return false;
|
178 |
}
|
179 |
-
if (
|
180 |
-
$class = array(
|
181 |
}
|
182 |
$basicclass = $class;
|
183 |
-
array_unshift(
|
184 |
$classes = array(
|
185 |
-
TINVWL_PATH . strtolower(
|
186 |
-
TINVWL_PATH . strtolower(
|
187 |
);
|
188 |
|
189 |
-
foreach (
|
190 |
-
foreach (
|
191 |
$filename = $class . $suffix . $ext;
|
192 |
-
if (
|
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(
|
202 |
} // End if().
|
203 |
|
204 |
-
if (
|
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(
|
214 |
-
|
215 |
-
$ext
|
216 |
-
|
|
|
217 |
$ext->run();
|
218 |
}
|
219 |
|
@@ -221,35 +230,40 @@ if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
|
221 |
}
|
222 |
}
|
223 |
|
224 |
-
if (
|
225 |
|
226 |
/**
|
227 |
* Run plugin
|
228 |
*/
|
229 |
-
function run_tinv_wishlist()
|
|
|
|
|
|
|
|
|
|
|
230 |
require_once TINVWL_PATH . 'tinv-wishlists-function.php';
|
231 |
|
232 |
-
foreach (
|
233 |
require_once $file;
|
234 |
}
|
235 |
|
236 |
-
if (
|
237 |
-
require_once(
|
238 |
}
|
239 |
-
if (
|
240 |
-
$redirect = tinv_wishlist_status(
|
241 |
-
if (
|
242 |
-
header(
|
243 |
exit;
|
244 |
}
|
245 |
-
} elseif (
|
246 |
$plugin = new TInvWL();
|
247 |
$plugin->run();
|
248 |
}
|
249 |
}
|
250 |
}
|
251 |
|
252 |
-
register_activation_hook(
|
253 |
-
register_deactivation_hook(
|
254 |
-
register_uninstall_hook(
|
255 |
-
add_action(
|
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);
|