Version Description
Release Date - 12 August 2019
- Added support for WooCommerce 3.7
- Added compatibility with Variations Swatches and Photos plugin
- Added compatibility with Clever Swatches plugin
- Added compatibility with WooCommerce Custom Product Addons (Pro) plugin
- Added compatibility with WooCommerce Rental & Bookings System plugin
- Added compatibility with Booking & Appointment Plugin for WooCommerce
- Refactored all 3rd party integrations code
- Fixed an issue with properly load custom translation files
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.14.0 |
Comparing to | |
See all releases |
Code changes from version 1.13.2 to 1.14.0
- admin/tinvwl.class.php +403 -403
- assets/css/admin.min.css +1 -1
- assets/css/public.min.css +1 -1
- assets/css/theme.min.css +1 -1
- assets/js/admin.min.js +1 -1
- assets/js/public.min.js +1 -1
- includes/tinvwl.class.php +8 -1
- integrations/clever-swatches.php +74 -0
- integrations/comet-cache.php +41 -0
- integrations/duracelltomi-google-tag-manager.php +42 -0
- integrations/gift-cards-for-woocommerce.php +144 -0
- integrations/improved-variable-product-attributes.php +136 -0
- integrations/mycred.php +313 -0
- integrations/oceanwp.php +33 -0
- integrations/sitepress-multilingual-cms.php +80 -0
- integrations/woo-advanced-qty.php +83 -0
- integrations/woo-custom-product-addons.php +101 -0
- integrations/woocommerce-booking.php +105 -0
- integrations/woocommerce-bookings.php +138 -0
- integrations/woocommerce-composite-products.php +176 -0
- integrations/woocommerce-custom-fields.php +149 -0
- integrations/woocommerce-gravityforms-product-addons.php +120 -0
- integrations/woocommerce-mix-and-match-products.php +180 -0
- integrations/woocommerce-multilingual.php +172 -0
- integrations/woocommerce-product-addon.php +178 -0
- integrations/woocommerce-product-addons.php +216 -0
- integrations/woocommerce-product-bundles.php +202 -0
- integrations/woocommerce-rental-and-booking.php +295 -0
- integrations/woocommerce-tm-extra-product-options.php +127 -0
- integrations/woocommerce-variation-swatches-and-photos.php +18 -0
- integrations/wp-fastest-cache.php +88 -0
- integrations/wp-multilang.php +42 -0
- integrations/wp-rocket.php +36 -0
- integrations/yith-woocommerce-product-add-ons.php +134 -0
- integrations/yith-woocommerce-product-bundles.php +159 -0
- languages/ti-woocommerce-wishlist.pot +82 -82
- readme.txt +13 -12
- ti-woocommerce-wishlist.php +255 -253
- tinv-wishlists-function-integration.php +0 -2709
admin/tinvwl.class.php
CHANGED
@@ -1,403 +1,403 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin pages class
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package TInvWishlist\Admin
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Admin pages class
|
16 |
-
*/
|
17 |
-
class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Constructor
|
21 |
-
*
|
22 |
-
* @param string $plugin_name Plugin name.
|
23 |
-
* @param string $version Plugin version.
|
24 |
-
*/
|
25 |
-
function __construct( $plugin_name, $version ) {
|
26 |
-
$this->_name = $plugin_name;
|
27 |
-
$this->_version = $version;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Load functions.
|
32 |
-
* Create Wishlist and Product class.
|
33 |
-
* Load settings classes.
|
34 |
-
*/
|
35 |
-
function load_function() {
|
36 |
-
|
37 |
-
|
38 |
-
$this->load_settings();
|
39 |
-
|
40 |
-
$this->define_hooks();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Load settings classes.
|
45 |
-
*
|
46 |
-
* @return boolean
|
47 |
-
*/
|
48 |
-
function load_settings() {
|
49 |
-
$dir = TINVWL_PATH . 'admin/settings/';
|
50 |
-
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
51 |
-
return false;
|
52 |
-
}
|
53 |
-
$files = scandir( $dir );
|
54 |
-
foreach ( $files as $value ) {
|
55 |
-
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
56 |
-
$file = preg_replace( '/\.class\.php$/i', '', $value );
|
57 |
-
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
58 |
-
$class::instance( $this->_name, $this->_version );
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
return true;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Define hooks
|
67 |
-
*/
|
68 |
-
function define_hooks() {
|
69 |
-
add_action( 'admin_menu', array( $this, 'action_menu' ) );
|
70 |
-
if ( 'skip' === filter_input( INPUT_GET, $this->_name . '-wizard' ) ) {
|
71 |
-
update_option( $this->_name . '_wizard', true );
|
72 |
-
}
|
73 |
-
if ( ! get_option( $this->_name . '_wizard' ) ) {
|
74 |
-
add_action( 'admin_notices', array( $this, 'wizard_run_admin_notice' ) );
|
75 |
-
} elseif ( ! tinv_get_option( 'page', 'wishlist' ) ) {
|
76 |
-
add_action( 'admin_notices', array( $this, 'empty_page_admin_notice' ) );
|
77 |
-
}
|
78 |
-
add_action( 'woocommerce_system_status_report', array( $this, 'system_report_templates' ) );
|
79 |
-
|
80 |
-
add_action( 'switch_theme', array( $this, 'admin_notice_outdated_templates' ) );
|
81 |
-
add_action( 'tinvwl_updated', array( $this, 'admin_notice_outdated_templates' ) );
|
82 |
-
|
83 |
-
// Add a post display state for special WC pages.
|
84 |
-
add_filter( 'display_post_states', array( $this, 'add_display_post_states' ), 10, 2 );
|
85 |
-
|
86 |
-
add_action( 'tinvwl_admin_promo_footer', array( $this, 'promo_footer' ) );
|
87 |
-
add_action( 'tinvwl_remove_without_author_wishlist', array( $this, 'remove_old_wishlists' ) );
|
88 |
-
$this->scheduled_remove_wishlist();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Error notice if wizard didn't run.
|
93 |
-
*/
|
94 |
-
function wizard_run_admin_notice() {
|
95 |
-
printf( '<div class="notice notice-error"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a> <a href="%4$s" class="button-secondary">%5$s</a></p></div>',
|
96 |
-
__( '<strong>Welcome to WooCommerce Wishlist Plugin</strong> – You‘re almost ready to start :)', 'ti-woocommerce-wishlist' ), // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
97 |
-
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
98 |
-
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' ),
|
99 |
-
esc_url( admin_url( 'index.php?page=' . $this->_name . '&' . $this->_name . '-wizard=skip' ) ),
|
100 |
-
esc_html__( 'Skip Setup', 'ti-woocommerce-wishlist' )
|
101 |
-
);
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Error notice if wishlist page not set.
|
106 |
-
*/
|
107 |
-
function empty_page_admin_notice() {
|
108 |
-
printf( '<div class="notice notice-error is-dismissible" style="position: relative;"><h4>%1$s</h4><p>%2$s</p><ol><li>%3$s</li><li>%4$s</li><li>%5$s</li></ol><p><a href="%6$s">%7$s</a>%8$s<a href="%9$s">%10$s</a></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss', 'ti-woocommerce-wishlist' ) . '</span></button></div>', // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
109 |
-
esc_html__( 'WooCommerce Wishlist Plugin is misconfigured!', 'ti-woocommerce-wishlist' ),
|
110 |
-
esc_html__( 'Since the Setup Wizard was skipped, the Wishlist may function improperly.', 'ti-woocommerce-wishlist' ),
|
111 |
-
esc_html__( 'Create a New Page or open to edit a page where the Wishlist should be displayed.', 'ti-woocommerce-wishlist' ),
|
112 |
-
__( 'Add <code>[ti_wishlistsview]</code> shortcode into a page content.', 'ti-woocommerce-wishlist' ),
|
113 |
-
esc_html__( 'In a plugin General Settings section apply this page as a "Wishlist" page.', 'ti-woocommerce-wishlist' ),
|
114 |
-
esc_url( $this->admin_url( '' ) . '#general' ),
|
115 |
-
esc_html__( 'Please apply the Wishlist page', 'ti-woocommerce-wishlist' ),
|
116 |
-
esc_html__( ' or ', 'ti-woocommerce-wishlist' ),
|
117 |
-
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
118 |
-
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' )
|
119 |
-
);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Creation mune and sub-menu
|
124 |
-
*/
|
125 |
-
function action_menu() {
|
126 |
-
global $wp_roles;
|
127 |
-
$page = add_menu_page( 'TI Wishlist', 'TI Wishlist', 'tinvwl_general_settings', $this->_name, null, TINVWL_URL . 'assets/img/icon_menu.png', '55.888' );
|
128 |
-
add_action( "load-$page", array( $this, 'onload' ) );
|
129 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'add_inline_scripts' ) );
|
130 |
-
$menu = apply_filters( 'tinvwl_admin_menu', array() );
|
131 |
-
foreach ( $menu as $item ) {
|
132 |
-
if ( ! array_key_exists( 'page_title', $item ) ) {
|
133 |
-
$item['page_title'] = $item['title'];
|
134 |
-
}
|
135 |
-
if ( ! array_key_exists( 'parent', $item ) ) {
|
136 |
-
$item['parent'] = $this->_name;
|
137 |
-
}
|
138 |
-
if ( ! array_key_exists( 'capability', $item ) ) {
|
139 |
-
$item['capability'] = 'manage_woocommerce';
|
140 |
-
}
|
141 |
-
|
142 |
-
if ( ! array_key_exists( 'roles', $item ) ) {
|
143 |
-
$item['roles'] = array( 'administrator' );
|
144 |
-
}
|
145 |
-
|
146 |
-
foreach ( $item['roles'] as $role ) {
|
147 |
-
$wp_roles->add_cap( $role, $item['capability'] );
|
148 |
-
}
|
149 |
-
|
150 |
-
$item['slug'] = implode( '-', array_filter( array( $this->_name, $item['slug'] ) ) );
|
151 |
-
|
152 |
-
$page = add_submenu_page( $item['parent'], $item['page_title'], $item['title'], $item['capability'], $item['slug'], $item['method'] );
|
153 |
-
add_action( "load-$page", array( $this, 'onload' ) );
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Load style and javascript
|
159 |
-
*/
|
160 |
-
function onload() {
|
161 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
162 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
163 |
-
add_filter( 'admin_footer_text', array( $this, 'footer_admin' ) );
|
164 |
-
add_filter( 'screen_options_show_screen', array( $this, 'screen_options_hide_screen' ), 10, 2 );
|
165 |
-
|
166 |
-
add_filter( 'tinvwl_view_panelstatus', array( $this, 'status_panel' ), 9999 );
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Load style
|
171 |
-
*/
|
172 |
-
function enqueue_styles() {
|
173 |
-
wp_enqueue_style( 'gfonts', ( is_ssl() ? 'https' : 'http' ) . '://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800', '', null, 'all' );
|
174 |
-
wp_enqueue_style( $this->_name, TINVWL_URL . 'assets/css/admin.css', array(), $this->_version, 'all' );
|
175 |
-
wp_enqueue_style( $this->_name . '-form', TINVWL_URL . 'assets/css/admin-form.css', array(), $this->_version, 'all' );
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Load javascript
|
180 |
-
*/
|
181 |
-
function add_inline_scripts() {
|
182 |
-
wp_add_inline_script( 'jquery-blockui', 'jQuery(function(c){c("body").on("click.woo",\'a[href*="woocommerce.com"]\',function(o){var e=(((o||{}).originalEvent||{}).target||{}).href||!1,r=((o||{}).currentTarget||{}).href||!1,t="&";e&&r&&(o.currentTarget.href=e.split("?")[0]+"?utm_source=dashboard"+t+"aff=3955"+t+"utm_campaign=promo"+t+"cid=2034496"+t+"utm_medium=free",setTimeout(function(){o.originalEvent.target.href=e},1)),c("body").off("click.woo",\'a[href*="woocommerce.com"]\')})});' );
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Load javascript
|
187 |
-
*/
|
188 |
-
function enqueue_scripts() {
|
189 |
-
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
190 |
-
wp_enqueue_script( $this->_name . '-bootstrap', TINVWL_URL . 'assets/js/bootstrap' . $suffix . '.js', array( 'jquery' ), $this->_version, 'all' );
|
191 |
-
wp_register_script( $this->_name, TINVWL_URL . 'assets/js/admin' . $suffix . '.js', array(
|
192 |
-
'jquery',
|
193 |
-
'wp-color-picker',
|
194 |
-
), $this->_version, 'all' );
|
195 |
-
wp_localize_script( $this->_name, 'tinvwl_comfirm', array(
|
196 |
-
'text_comfirm_reset' => __( 'Are you sure you want to reset the settings?', 'ti-woocommerce-wishlist' ),
|
197 |
-
) );
|
198 |
-
wp_enqueue_script( $this->_name );
|
199 |
-
|
200 |
-
if ( ! tinv_get_option( 'chat', 'disabled' ) ) {
|
201 |
-
|
202 |
-
$geo = new WC_Geolocation(); // Get WC_Geolocation instance object
|
203 |
-
$user_ip = $geo->get_ip_address(); // Get user IP
|
204 |
-
$user_geo = $geo->geolocate_ip( $user_ip ); // Get geolocated user data.
|
205 |
-
$country_code = $user_geo['country']; // Get the country code
|
206 |
-
$restricted_codes = array( 'BD', 'PK', 'IN', 'NG', 'KE' );
|
207 |
-
|
208 |
-
if ( ! in_array( $country_code, $restricted_codes ) ) {
|
209 |
-
|
210 |
-
$user_id = get_current_user_id();
|
211 |
-
$user_info = get_userdata( $user_id );
|
212 |
-
$current_theme = wp_get_theme();
|
213 |
-
|
214 |
-
$parent_theme = $current_theme->parent();
|
215 |
-
|
216 |
-
wp_add_inline_script( $this->_name, 'window.intercomSettings = {
|
217 |
-
app_id: "wj7rirzi",
|
218 |
-
"Website": "' . get_site_url() . '",
|
219 |
-
"Plugin name": "WooCommerce Wishlist Plugin",
|
220 |
-
"Plugin version":"' . TINVWL_FVERSION . '",
|
221 |
-
"Theme name":"' . $current_theme->get( 'Name' ) . '",
|
222 |
-
"Theme version":"' . $current_theme->get( 'Version' ) . '",
|
223 |
-
"Theme URI":"' . $current_theme->get( 'ThemeURI' ) . '",
|
224 |
-
"Theme author":"' . $current_theme->get( 'Author' ) . '",
|
225 |
-
"Theme author URI":"' . $current_theme->get( 'AuthorURI' ) . '",
|
226 |
-
"Parent theme name":"' . ( ( $parent_theme ) ? $parent_theme->get( 'Name' ) : '' ) . '",
|
227 |
-
"Parent theme version":"' . ( ( $parent_theme ) ? $parent_theme->get( 'Version' ) : '' ) . '",
|
228 |
-
"Parent theme URI":"' . ( ( $parent_theme ) ? $parent_theme->get( 'ThemeURI' ) : '' ) . '",
|
229 |
-
"Parent theme author":"' . ( ( $parent_theme ) ? $parent_theme->get( 'Author' ) : '' ) . '",
|
230 |
-
"Parent theme author URI":"' . ( ( $parent_theme ) ? $parent_theme->get( 'AuthorURI' ) : '' ) . '",
|
231 |
-
};
|
232 |
-
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic("reattach_activator");ic("update",intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement("script");s.type="text/javascript";s.async=true;s.src="https://widget.intercom.io/widget/zyh6v0pc";var x=d.getElementsByTagName("script")[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent("onload",l);}else{w.addEventListener("load",l,false);}}})();
|
233 |
-
Intercom("trackEvent", "wishlist-free-install", {
|
234 |
-
theme_name:"' . ( ( $parent_theme ) ? $parent_theme->get( 'Name' ) : $current_theme->get( 'Name' ) ) . '",
|
235 |
-
theme_uri:"' . ( ( $parent_theme ) ? $parent_theme->get( 'ThemeURI' ) : $current_theme->get( 'ThemeURI' ) ) . '",
|
236 |
-
theme_author:"' . ( ( $parent_theme ) ? $parent_theme->get( 'Author' ) : $current_theme->get( 'Author' ) ) . '",
|
237 |
-
theme_author_uri:"' . ( ( $parent_theme ) ? $parent_theme->get( 'AuthorURI' ) : $current_theme->get( 'AuthorURI' ) ) . '",
|
238 |
-
theme_version:"' . ( ( $parent_theme ) ? $parent_theme->get( 'Version' ) : $current_theme->get( 'Version' ) ) . '",
|
239 |
-
website:"' . get_site_url() . '",
|
240 |
-
user:"' . $user_info->user_email . '",
|
241 |
-
user_name:"' . $user_info->user_nicename . '",
|
242 |
-
plugin_name:"WooCommerce Wishlist Plugin",
|
243 |
-
plugin_version:"' . TINVWL_FVERSION . '",
|
244 |
-
partner:"' . TINVWL_UTM_SOURCE . '"
|
245 |
-
});
|
246 |
-
' );
|
247 |
-
}
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Add plugin footer copywriting
|
253 |
-
*/
|
254 |
-
function footer_admin() {
|
255 |
-
do_action( 'tinvwl_admin_promo_footer' );
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Promo in footer for wishlist
|
260 |
-
*/
|
261 |
-
function promo_footer() {
|
262 |
-
echo 'Made with <i class="ftinvwl ftinvwl-heart2"></i> by <a href="https://templateinvaders.com/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=made_by&partner=' . TINVWL_UTM_SOURCE . '">TemplateInvaders</a><br />If you like WooCommerce Wishlist Plugin please leave us a <a href="https://wordpress.org/support/plugin/ti-woocommerce-wishlist/reviews/#new-post"><span><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i></span></a> rating.'; // WPCS: xss ok.
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Create Upgrade button
|
267 |
-
*
|
268 |
-
* @param array $panel Panel Button.
|
269 |
-
*
|
270 |
-
* @return array
|
271 |
-
*/
|
272 |
-
function status_panel( $panel ) {
|
273 |
-
array_unshift( $panel, sprintf( '<a class="tinvwl-btn red w-icon smaller-txt" href="%s"><i class="ftinvwl ftinvwl-star"></i><span class="tinvwl-txt">%s</span></a>', 'https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpress-plugin/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=header_upgrade&partner=' . TINVWL_UTM_SOURCE, __( 'Upgrade to Premium', 'ti-woocommerce-wishlist' ) ) );
|
274 |
-
|
275 |
-
return $panel;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Templates overriding status check.
|
280 |
-
*
|
281 |
-
* @param boolean $outdated Out date status.
|
282 |
-
*
|
283 |
-
* @return string
|
284 |
-
*/
|
285 |
-
function templates_status_check( $outdated = false ) {
|
286 |
-
|
287 |
-
$found_files = array();
|
288 |
-
|
289 |
-
$scanned_files = WC_Admin_Status::scan_template_files( TINVWL_PATH . '/templates/' );
|
290 |
-
|
291 |
-
foreach ( $scanned_files as $file ) {
|
292 |
-
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
293 |
-
$theme_file = get_stylesheet_directory() . '/' . $file;
|
294 |
-
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
|
295 |
-
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
|
296 |
-
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
297 |
-
$theme_file = get_template_directory() . '/' . $file;
|
298 |
-
} elseif ( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
|
299 |
-
$theme_file = get_template_directory() . '/woocommerce/' . $file;
|
300 |
-
} else {
|
301 |
-
$theme_file = false;
|
302 |
-
}
|
303 |
-
|
304 |
-
if ( ! empty( $theme_file ) ) {
|
305 |
-
$core_version = WC_Admin_Status::get_file_version( TINVWL_PATH . '/templates/' . $file );
|
306 |
-
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
|
307 |
-
|
308 |
-
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
|
309 |
-
if ( $outdated ) {
|
310 |
-
return 'outdated';
|
311 |
-
}
|
312 |
-
$found_files[] = sprintf( __( '<code>%1$s</code> version <strong style="color:red">%2$s</strong> is out of date. The core version is <strong style="color:red">%3$s</strong>', 'ti-woocommerce-wishlist' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
|
313 |
-
} else {
|
314 |
-
$found_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file );
|
315 |
-
}
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
return $found_files;
|
320 |
-
}
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Templates overriding status for WooCommerce Status report page.
|
324 |
-
*/
|
325 |
-
function system_report_templates() {
|
326 |
-
|
327 |
-
TInvWL_View::view( 'templates-status', array( 'found_files' => $this->templates_status_check() ) );
|
328 |
-
}
|
329 |
-
|
330 |
-
/**
|
331 |
-
* Outdated templates notice.
|
332 |
-
*/
|
333 |
-
function admin_notice_outdated_templates() {
|
334 |
-
if ( 'outdated' === $this->templates_status_check( true ) ) {
|
335 |
-
|
336 |
-
$theme = wp_get_theme();
|
337 |
-
|
338 |
-
$html = sprintf( __( '<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href="%2$s">system status page</a>.<br> If in doubt, check with the author of the theme.', 'ti-woocommerce-wishlist' ), esc_html( $theme['Name'] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) );
|
339 |
-
|
340 |
-
WC_Admin_Notices::add_custom_notice( 'outdated_templates', $html );
|
341 |
-
} else {
|
342 |
-
WC_Admin_Notices::remove_notice( 'outdated_templates' );
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
/**
|
347 |
-
* Disable screen option on plugin pages
|
348 |
-
*
|
349 |
-
* @param boolean $show_screen Show screen.
|
350 |
-
* @param \WP_Screen $_this Screen option page.
|
351 |
-
*
|
352 |
-
* @return boolean
|
353 |
-
*/
|
354 |
-
function screen_options_hide_screen( $show_screen, $_this ) {
|
355 |
-
if ( $this->_name === $_this->parent_base || $this->_name === $_this->parent_file ) {
|
356 |
-
return false;
|
357 |
-
}
|
358 |
-
|
359 |
-
return $show_screen;
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Check if there is a hook in the cron
|
364 |
-
*/
|
365 |
-
function scheduled_remove_wishlist() {
|
366 |
-
$timestamp = wp_next_scheduled( 'tinvwl_remove_without_author_wishlist' );
|
367 |
-
if ( ! $timestamp ) {
|
368 |
-
$time = strtotime( '00:00 today +1 HOURS' );
|
369 |
-
wp_schedule_event( $time, 'daily', 'tinvwl_remove_without_author_wishlist' );
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Removing old wishlist without a user older than 34 days
|
375 |
-
*/
|
376 |
-
public function remove_old_wishlists() {
|
377 |
-
$wl = new TInvWL_Wishlist();
|
378 |
-
$wishlists = $wl->get( array(
|
379 |
-
'author' => 0,
|
380 |
-
'type' => 'default',
|
381 |
-
'sql' => 'SELECT * FROM {table} {where} AND `date` < DATE_SUB( CURDATE(), INTERVAL 34 DAY)',
|
382 |
-
) );
|
383 |
-
foreach ( $wishlists as $wishlist ) {
|
384 |
-
$wl->remove( $wishlist['ID'] );
|
385 |
-
}
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Add a post display state for special WC pages in the page list table.
|
390 |
-
*
|
391 |
-
* @param array $post_states An array of post display states.
|
392 |
-
* @param WP_Post $post The current post object.
|
393 |
-
*
|
394 |
-
* @return array
|
395 |
-
*/
|
396 |
-
public function add_display_post_states( $post_states, $post ) {
|
397 |
-
if ( tinv_get_option( 'page', 'wishlist' ) === $post->ID ) {
|
398 |
-
$post_states['tinvwl_page_for_wishlist'] = __( 'Wishlist Page', 'ti-woocommerce-wishlist' );
|
399 |
-
}
|
400 |
-
|
401 |
-
return $post_states;
|
402 |
-
}
|
403 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin pages class
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package TInvWishlist\Admin
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Admin pages class
|
16 |
+
*/
|
17 |
+
class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Constructor
|
21 |
+
*
|
22 |
+
* @param string $plugin_name Plugin name.
|
23 |
+
* @param string $version Plugin version.
|
24 |
+
*/
|
25 |
+
function __construct( $plugin_name, $version ) {
|
26 |
+
$this->_name = $plugin_name;
|
27 |
+
$this->_version = $version;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Load functions.
|
32 |
+
* Create Wishlist and Product class.
|
33 |
+
* Load settings classes.
|
34 |
+
*/
|
35 |
+
function load_function() {
|
36 |
+
TInvWL_Includes_API_Yoasti18n::instance();
|
37 |
+
|
38 |
+
$this->load_settings();
|
39 |
+
|
40 |
+
$this->define_hooks();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Load settings classes.
|
45 |
+
*
|
46 |
+
* @return boolean
|
47 |
+
*/
|
48 |
+
function load_settings() {
|
49 |
+
$dir = TINVWL_PATH . 'admin/settings/';
|
50 |
+
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
$files = scandir( $dir );
|
54 |
+
foreach ( $files as $value ) {
|
55 |
+
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
56 |
+
$file = preg_replace( '/\.class\.php$/i', '', $value );
|
57 |
+
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
58 |
+
$class::instance( $this->_name, $this->_version );
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Define hooks
|
67 |
+
*/
|
68 |
+
function define_hooks() {
|
69 |
+
add_action( 'admin_menu', array( $this, 'action_menu' ) );
|
70 |
+
if ( 'skip' === filter_input( INPUT_GET, $this->_name . '-wizard' ) ) {
|
71 |
+
update_option( $this->_name . '_wizard', true );
|
72 |
+
}
|
73 |
+
if ( ! get_option( $this->_name . '_wizard' ) ) {
|
74 |
+
add_action( 'admin_notices', array( $this, 'wizard_run_admin_notice' ) );
|
75 |
+
} elseif ( ! tinv_get_option( 'page', 'wishlist' ) ) {
|
76 |
+
add_action( 'admin_notices', array( $this, 'empty_page_admin_notice' ) );
|
77 |
+
}
|
78 |
+
add_action( 'woocommerce_system_status_report', array( $this, 'system_report_templates' ) );
|
79 |
+
|
80 |
+
add_action( 'switch_theme', array( $this, 'admin_notice_outdated_templates' ) );
|
81 |
+
add_action( 'tinvwl_updated', array( $this, 'admin_notice_outdated_templates' ) );
|
82 |
+
|
83 |
+
// Add a post display state for special WC pages.
|
84 |
+
add_filter( 'display_post_states', array( $this, 'add_display_post_states' ), 10, 2 );
|
85 |
+
|
86 |
+
add_action( 'tinvwl_admin_promo_footer', array( $this, 'promo_footer' ) );
|
87 |
+
add_action( 'tinvwl_remove_without_author_wishlist', array( $this, 'remove_old_wishlists' ) );
|
88 |
+
$this->scheduled_remove_wishlist();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Error notice if wizard didn't run.
|
93 |
+
*/
|
94 |
+
function wizard_run_admin_notice() {
|
95 |
+
printf( '<div class="notice notice-error"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a> <a href="%4$s" class="button-secondary">%5$s</a></p></div>',
|
96 |
+
__( '<strong>Welcome to WooCommerce Wishlist Plugin</strong> – You‘re almost ready to start :)', 'ti-woocommerce-wishlist' ), // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
97 |
+
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
98 |
+
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' ),
|
99 |
+
esc_url( admin_url( 'index.php?page=' . $this->_name . '&' . $this->_name . '-wizard=skip' ) ),
|
100 |
+
esc_html__( 'Skip Setup', 'ti-woocommerce-wishlist' )
|
101 |
+
);
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Error notice if wishlist page not set.
|
106 |
+
*/
|
107 |
+
function empty_page_admin_notice() {
|
108 |
+
printf( '<div class="notice notice-error is-dismissible" style="position: relative;"><h4>%1$s</h4><p>%2$s</p><ol><li>%3$s</li><li>%4$s</li><li>%5$s</li></ol><p><a href="%6$s">%7$s</a>%8$s<a href="%9$s">%10$s</a></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss', 'ti-woocommerce-wishlist' ) . '</span></button></div>', // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
109 |
+
esc_html__( 'WooCommerce Wishlist Plugin is misconfigured!', 'ti-woocommerce-wishlist' ),
|
110 |
+
esc_html__( 'Since the Setup Wizard was skipped, the Wishlist may function improperly.', 'ti-woocommerce-wishlist' ),
|
111 |
+
esc_html__( 'Create a New Page or open to edit a page where the Wishlist should be displayed.', 'ti-woocommerce-wishlist' ),
|
112 |
+
__( 'Add <code>[ti_wishlistsview]</code> shortcode into a page content.', 'ti-woocommerce-wishlist' ),
|
113 |
+
esc_html__( 'In a plugin General Settings section apply this page as a "Wishlist" page.', 'ti-woocommerce-wishlist' ),
|
114 |
+
esc_url( $this->admin_url( '' ) . '#general' ),
|
115 |
+
esc_html__( 'Please apply the Wishlist page', 'ti-woocommerce-wishlist' ),
|
116 |
+
esc_html__( ' or ', 'ti-woocommerce-wishlist' ),
|
117 |
+
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
118 |
+
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' )
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Creation mune and sub-menu
|
124 |
+
*/
|
125 |
+
function action_menu() {
|
126 |
+
global $wp_roles;
|
127 |
+
$page = add_menu_page( 'TI Wishlist', 'TI Wishlist', 'tinvwl_general_settings', $this->_name, null, TINVWL_URL . 'assets/img/icon_menu.png', '55.888' );
|
128 |
+
add_action( "load-$page", array( $this, 'onload' ) );
|
129 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'add_inline_scripts' ) );
|
130 |
+
$menu = apply_filters( 'tinvwl_admin_menu', array() );
|
131 |
+
foreach ( $menu as $item ) {
|
132 |
+
if ( ! array_key_exists( 'page_title', $item ) ) {
|
133 |
+
$item['page_title'] = $item['title'];
|
134 |
+
}
|
135 |
+
if ( ! array_key_exists( 'parent', $item ) ) {
|
136 |
+
$item['parent'] = $this->_name;
|
137 |
+
}
|
138 |
+
if ( ! array_key_exists( 'capability', $item ) ) {
|
139 |
+
$item['capability'] = 'manage_woocommerce';
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( ! array_key_exists( 'roles', $item ) ) {
|
143 |
+
$item['roles'] = array( 'administrator' );
|
144 |
+
}
|
145 |
+
|
146 |
+
foreach ( $item['roles'] as $role ) {
|
147 |
+
$wp_roles->add_cap( $role, $item['capability'] );
|
148 |
+
}
|
149 |
+
|
150 |
+
$item['slug'] = implode( '-', array_filter( array( $this->_name, $item['slug'] ) ) );
|
151 |
+
|
152 |
+
$page = add_submenu_page( $item['parent'], $item['page_title'], $item['title'], $item['capability'], $item['slug'], $item['method'] );
|
153 |
+
add_action( "load-$page", array( $this, 'onload' ) );
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Load style and javascript
|
159 |
+
*/
|
160 |
+
function onload() {
|
161 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
162 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
163 |
+
add_filter( 'admin_footer_text', array( $this, 'footer_admin' ) );
|
164 |
+
add_filter( 'screen_options_show_screen', array( $this, 'screen_options_hide_screen' ), 10, 2 );
|
165 |
+
|
166 |
+
add_filter( 'tinvwl_view_panelstatus', array( $this, 'status_panel' ), 9999 );
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Load style
|
171 |
+
*/
|
172 |
+
function enqueue_styles() {
|
173 |
+
wp_enqueue_style( 'gfonts', ( is_ssl() ? 'https' : 'http' ) . '://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800', '', null, 'all' );
|
174 |
+
wp_enqueue_style( $this->_name, TINVWL_URL . 'assets/css/admin.css', array(), $this->_version, 'all' );
|
175 |
+
wp_enqueue_style( $this->_name . '-form', TINVWL_URL . 'assets/css/admin-form.css', array(), $this->_version, 'all' );
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Load javascript
|
180 |
+
*/
|
181 |
+
function add_inline_scripts() {
|
182 |
+
wp_add_inline_script( 'jquery-blockui', 'jQuery(function(c){c("body").on("click.woo",\'a[href*="woocommerce.com"]\',function(o){var e=(((o||{}).originalEvent||{}).target||{}).href||!1,r=((o||{}).currentTarget||{}).href||!1,t="&";e&&r&&(o.currentTarget.href=e.split("?")[0]+"?utm_source=dashboard"+t+"aff=3955"+t+"utm_campaign=promo"+t+"cid=2034496"+t+"utm_medium=free",setTimeout(function(){o.originalEvent.target.href=e},1)),c("body").off("click.woo",\'a[href*="woocommerce.com"]\')})});' );
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Load javascript
|
187 |
+
*/
|
188 |
+
function enqueue_scripts() {
|
189 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
190 |
+
wp_enqueue_script( $this->_name . '-bootstrap', TINVWL_URL . 'assets/js/bootstrap' . $suffix . '.js', array( 'jquery' ), $this->_version, 'all' );
|
191 |
+
wp_register_script( $this->_name, TINVWL_URL . 'assets/js/admin' . $suffix . '.js', array(
|
192 |
+
'jquery',
|
193 |
+
'wp-color-picker',
|
194 |
+
), $this->_version, 'all' );
|
195 |
+
wp_localize_script( $this->_name, 'tinvwl_comfirm', array(
|
196 |
+
'text_comfirm_reset' => __( 'Are you sure you want to reset the settings?', 'ti-woocommerce-wishlist' ),
|
197 |
+
) );
|
198 |
+
wp_enqueue_script( $this->_name );
|
199 |
+
|
200 |
+
if ( ! tinv_get_option( 'chat', 'disabled' ) ) {
|
201 |
+
|
202 |
+
$geo = new WC_Geolocation(); // Get WC_Geolocation instance object
|
203 |
+
$user_ip = $geo->get_ip_address(); // Get user IP
|
204 |
+
$user_geo = $geo->geolocate_ip( $user_ip ); // Get geolocated user data.
|
205 |
+
$country_code = $user_geo['country']; // Get the country code
|
206 |
+
$restricted_codes = array( 'BD', 'PK', 'IN', 'NG', 'KE' );
|
207 |
+
|
208 |
+
if ( ! in_array( $country_code, $restricted_codes ) ) {
|
209 |
+
|
210 |
+
$user_id = get_current_user_id();
|
211 |
+
$user_info = get_userdata( $user_id );
|
212 |
+
$current_theme = wp_get_theme();
|
213 |
+
|
214 |
+
$parent_theme = $current_theme->parent();
|
215 |
+
|
216 |
+
wp_add_inline_script( $this->_name, 'window.intercomSettings = {
|
217 |
+
app_id: "wj7rirzi",
|
218 |
+
"Website": "' . get_site_url() . '",
|
219 |
+
"Plugin name": "WooCommerce Wishlist Plugin",
|
220 |
+
"Plugin version":"' . TINVWL_FVERSION . '",
|
221 |
+
"Theme name":"' . $current_theme->get( 'Name' ) . '",
|
222 |
+
"Theme version":"' . $current_theme->get( 'Version' ) . '",
|
223 |
+
"Theme URI":"' . $current_theme->get( 'ThemeURI' ) . '",
|
224 |
+
"Theme author":"' . $current_theme->get( 'Author' ) . '",
|
225 |
+
"Theme author URI":"' . $current_theme->get( 'AuthorURI' ) . '",
|
226 |
+
"Parent theme name":"' . ( ( $parent_theme ) ? $parent_theme->get( 'Name' ) : '' ) . '",
|
227 |
+
"Parent theme version":"' . ( ( $parent_theme ) ? $parent_theme->get( 'Version' ) : '' ) . '",
|
228 |
+
"Parent theme URI":"' . ( ( $parent_theme ) ? $parent_theme->get( 'ThemeURI' ) : '' ) . '",
|
229 |
+
"Parent theme author":"' . ( ( $parent_theme ) ? $parent_theme->get( 'Author' ) : '' ) . '",
|
230 |
+
"Parent theme author URI":"' . ( ( $parent_theme ) ? $parent_theme->get( 'AuthorURI' ) : '' ) . '",
|
231 |
+
};
|
232 |
+
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic("reattach_activator");ic("update",intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement("script");s.type="text/javascript";s.async=true;s.src="https://widget.intercom.io/widget/zyh6v0pc";var x=d.getElementsByTagName("script")[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent("onload",l);}else{w.addEventListener("load",l,false);}}})();
|
233 |
+
Intercom("trackEvent", "wishlist-free-install", {
|
234 |
+
theme_name:"' . ( ( $parent_theme ) ? $parent_theme->get( 'Name' ) : $current_theme->get( 'Name' ) ) . '",
|
235 |
+
theme_uri:"' . ( ( $parent_theme ) ? $parent_theme->get( 'ThemeURI' ) : $current_theme->get( 'ThemeURI' ) ) . '",
|
236 |
+
theme_author:"' . ( ( $parent_theme ) ? $parent_theme->get( 'Author' ) : $current_theme->get( 'Author' ) ) . '",
|
237 |
+
theme_author_uri:"' . ( ( $parent_theme ) ? $parent_theme->get( 'AuthorURI' ) : $current_theme->get( 'AuthorURI' ) ) . '",
|
238 |
+
theme_version:"' . ( ( $parent_theme ) ? $parent_theme->get( 'Version' ) : $current_theme->get( 'Version' ) ) . '",
|
239 |
+
website:"' . get_site_url() . '",
|
240 |
+
user:"' . $user_info->user_email . '",
|
241 |
+
user_name:"' . $user_info->user_nicename . '",
|
242 |
+
plugin_name:"WooCommerce Wishlist Plugin",
|
243 |
+
plugin_version:"' . TINVWL_FVERSION . '",
|
244 |
+
partner:"' . TINVWL_UTM_SOURCE . '"
|
245 |
+
});
|
246 |
+
' );
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Add plugin footer copywriting
|
253 |
+
*/
|
254 |
+
function footer_admin() {
|
255 |
+
do_action( 'tinvwl_admin_promo_footer' );
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Promo in footer for wishlist
|
260 |
+
*/
|
261 |
+
function promo_footer() {
|
262 |
+
echo 'Made with <i class="ftinvwl ftinvwl-heart2"></i> by <a href="https://templateinvaders.com/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=made_by&partner=' . TINVWL_UTM_SOURCE . '">TemplateInvaders</a><br />If you like WooCommerce Wishlist Plugin please leave us a <a href="https://wordpress.org/support/plugin/ti-woocommerce-wishlist/reviews/#new-post"><span><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i><i class="ftinvwl ftinvwl-star"></i></span></a> rating.'; // WPCS: xss ok.
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Create Upgrade button
|
267 |
+
*
|
268 |
+
* @param array $panel Panel Button.
|
269 |
+
*
|
270 |
+
* @return array
|
271 |
+
*/
|
272 |
+
function status_panel( $panel ) {
|
273 |
+
array_unshift( $panel, sprintf( '<a class="tinvwl-btn red w-icon smaller-txt" href="%s"><i class="ftinvwl ftinvwl-star"></i><span class="tinvwl-txt">%s</span></a>', 'https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpress-plugin/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=header_upgrade&partner=' . TINVWL_UTM_SOURCE, __( 'Upgrade to Premium', 'ti-woocommerce-wishlist' ) ) );
|
274 |
+
|
275 |
+
return $panel;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Templates overriding status check.
|
280 |
+
*
|
281 |
+
* @param boolean $outdated Out date status.
|
282 |
+
*
|
283 |
+
* @return string
|
284 |
+
*/
|
285 |
+
function templates_status_check( $outdated = false ) {
|
286 |
+
|
287 |
+
$found_files = array();
|
288 |
+
|
289 |
+
$scanned_files = WC_Admin_Status::scan_template_files( TINVWL_PATH . '/templates/' );
|
290 |
+
|
291 |
+
foreach ( $scanned_files as $file ) {
|
292 |
+
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
293 |
+
$theme_file = get_stylesheet_directory() . '/' . $file;
|
294 |
+
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
|
295 |
+
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
|
296 |
+
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
297 |
+
$theme_file = get_template_directory() . '/' . $file;
|
298 |
+
} elseif ( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
|
299 |
+
$theme_file = get_template_directory() . '/woocommerce/' . $file;
|
300 |
+
} else {
|
301 |
+
$theme_file = false;
|
302 |
+
}
|
303 |
+
|
304 |
+
if ( ! empty( $theme_file ) ) {
|
305 |
+
$core_version = WC_Admin_Status::get_file_version( TINVWL_PATH . '/templates/' . $file );
|
306 |
+
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
|
307 |
+
|
308 |
+
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
|
309 |
+
if ( $outdated ) {
|
310 |
+
return 'outdated';
|
311 |
+
}
|
312 |
+
$found_files[] = sprintf( __( '<code>%1$s</code> version <strong style="color:red">%2$s</strong> is out of date. The core version is <strong style="color:red">%3$s</strong>', 'ti-woocommerce-wishlist' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
|
313 |
+
} else {
|
314 |
+
$found_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file );
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
return $found_files;
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Templates overriding status for WooCommerce Status report page.
|
324 |
+
*/
|
325 |
+
function system_report_templates() {
|
326 |
+
|
327 |
+
TInvWL_View::view( 'templates-status', array( 'found_files' => $this->templates_status_check() ) );
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Outdated templates notice.
|
332 |
+
*/
|
333 |
+
function admin_notice_outdated_templates() {
|
334 |
+
if ( 'outdated' === $this->templates_status_check( true ) ) {
|
335 |
+
|
336 |
+
$theme = wp_get_theme();
|
337 |
+
|
338 |
+
$html = sprintf( __( '<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href="%2$s">system status page</a>.<br> If in doubt, check with the author of the theme.', 'ti-woocommerce-wishlist' ), esc_html( $theme['Name'] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) );
|
339 |
+
|
340 |
+
WC_Admin_Notices::add_custom_notice( 'outdated_templates', $html );
|
341 |
+
} else {
|
342 |
+
WC_Admin_Notices::remove_notice( 'outdated_templates' );
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Disable screen option on plugin pages
|
348 |
+
*
|
349 |
+
* @param boolean $show_screen Show screen.
|
350 |
+
* @param \WP_Screen $_this Screen option page.
|
351 |
+
*
|
352 |
+
* @return boolean
|
353 |
+
*/
|
354 |
+
function screen_options_hide_screen( $show_screen, $_this ) {
|
355 |
+
if ( $this->_name === $_this->parent_base || $this->_name === $_this->parent_file ) {
|
356 |
+
return false;
|
357 |
+
}
|
358 |
+
|
359 |
+
return $show_screen;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Check if there is a hook in the cron
|
364 |
+
*/
|
365 |
+
function scheduled_remove_wishlist() {
|
366 |
+
$timestamp = wp_next_scheduled( 'tinvwl_remove_without_author_wishlist' );
|
367 |
+
if ( ! $timestamp ) {
|
368 |
+
$time = strtotime( '00:00 today +1 HOURS' );
|
369 |
+
wp_schedule_event( $time, 'daily', 'tinvwl_remove_without_author_wishlist' );
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Removing old wishlist without a user older than 34 days
|
375 |
+
*/
|
376 |
+
public function remove_old_wishlists() {
|
377 |
+
$wl = new TInvWL_Wishlist();
|
378 |
+
$wishlists = $wl->get( array(
|
379 |
+
'author' => 0,
|
380 |
+
'type' => 'default',
|
381 |
+
'sql' => 'SELECT * FROM {table} {where} AND `date` < DATE_SUB( CURDATE(), INTERVAL 34 DAY)',
|
382 |
+
) );
|
383 |
+
foreach ( $wishlists as $wishlist ) {
|
384 |
+
$wl->remove( $wishlist['ID'] );
|
385 |
+
}
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Add a post display state for special WC pages in the page list table.
|
390 |
+
*
|
391 |
+
* @param array $post_states An array of post display states.
|
392 |
+
* @param WP_Post $post The current post object.
|
393 |
+
*
|
394 |
+
* @return array
|
395 |
+
*/
|
396 |
+
public function add_display_post_states( $post_states, $post ) {
|
397 |
+
if ( tinv_get_option( 'page', 'wishlist' ) === $post->ID ) {
|
398 |
+
$post_states['tinvwl_page_for_wishlist'] = __( 'Wishlist Page', 'ti-woocommerce-wishlist' );
|
399 |
+
}
|
400 |
+
|
401 |
+
return $post_states;
|
402 |
+
}
|
403 |
+
}
|
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 |
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
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.14.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
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 |
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
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.14.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
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.14.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/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()?n.preventDefault():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.attr("type","checkbox").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(){var t=s(this),n=function(){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),e=c.isChecked.call(t),o=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&o(n,e),"string"==typeof i&&o(i,!e),t};return t.is("input")&&"checkbox"==t.attr("type")?(s(this).on("change",n),n.call(t)):t})},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(){var t=s(this),n=function(e){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),o=e.onClick.call(t),c=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&c(n,o),"string"==typeof i&&c(i,!o),t};return t.is("input")||t.is("select")?(s(this).on("change",function(){n.call(this,i)}),n.call(t,i)):t})};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.14.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()?n.preventDefault():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.attr("type","checkbox").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(){var t=s(this),n=function(){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),e=c.isChecked.call(t),o=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&o(n,e),"string"==typeof i&&o(i,!e),t};return t.is("input")&&"checkbox"==t.attr("type")?(s(this).on("change",n),n.call(t)):t})},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(){var t=s(this),n=function(e){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),o=e.onClick.call(t),c=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&c(n,o),"string"==typeof i&&c(i,!o),t};return t.is("input")||t.is("select")?(s(this).on("change",function(){n.call(this,i)}),n.call(t,i)):t})};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 update_cart_hash(){if(!tinvwl_add_to_wishlist.wc_cart_fragments_refresh)return!1;jQuery(document.body).on("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist",function(){if("undefined"==typeof wc_cart_fragments_params)return!1;var t=wc_cart_fragments_params.cart_hash_key;localStorage.setItem(t,localStorage.getItem(t)+(new Date).getTime()),sessionStorage.setItem(t,sessionStorage.getItem(t)+(new Date).getTime()),jQuery(document.body).off("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist")})}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(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href,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(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):o.onActionProduct.call(this),update_cart_hash()},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var n={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val();"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n["form"+t]=e):n["form"+t]=e}),n=n.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof n)return t.in;var i=parseInt(n);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=o.onPrepareList.call(t)||t,t=o.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var e="";switch(t.length){case 0:break;default:e=r("<ul>");r.each(t,function(t,i){e.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}e.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(o.text_already_in+" ").append(e))},onAction:{redirect:function(t){o.redirectTimer&&clearTimeout(o.redirectTimer),o.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){r(this).attr("data-tinv-wl-list",t)},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer)})},status:function(t){t&&r(this).addClass("tinvwl-product-in-list")},removed:function(t){t&&r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")},make_remove:function(t){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")},fragments:function(t){if("undefined"==typeof wc_cart_fragments_params)return r.each(t,function(t,i){r(t).replaceWith(i)}),!1;var i;try{i="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(t){i=!1}if(i)try{var e=r.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),n=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash",o=sessionStorage.getItem(n),a=Cookies.get("woocommerce_cart_hash"),l=sessionStorage.getItem("wc_cart_created");if(null!=o&&""!==o||(o=""),null!=a&&""!==a||(a=""),o&&(null==l||""===l))throw"No cart_created";if(r.each(t,function(t,i){e[t]=i}),localStorage.setItem(n,localStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(n,sessionStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(e)),!e||!e["div.widget_shopping_cart_content"]||o!==a)throw"No fragment";r.each(e,function(t,i){r(t).replaceWith(i)}),r(document.body).trigger("wc_fragments_loaded")}catch(t){r(document.body).trigger("wc_fragment_refresh")}}},onActionProduct:function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},e=this;r(e).closest("form.cart[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val(),n=10,o=function t(i,e){if("object"!==_typeof(e))return e;for(var n in void 0===i&&(i={}),e)if(""===n){var o=-1;for(o in i)o=o;i[o=parseInt(o)+1]=t(i[n],e[n])}else i[n]=t(i[n],e[n]);return i};if("button"!==i&&void 0!==t&&"attribute_"!=t.substr(0,10)){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<n;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=e,e=l}t=a[1],n--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(e.length||"object"===_typeof(e)||(e=!0),s.form[t]=o(s.form[t],e)):s.form[t]=o(s.form[t],e)}}),s=o.onPrepareDataAction.call(e,e,s)||s,r.post(o.api_url,s,function(t){if(o.onDialogHide.call(e.tinvwl_dialog,e),"object"===_typeof(t))for(var i in t)"function"==typeof o.onAction[i]&&o.onAction[i].call(e,t[i]);else"function"==typeof o.onAction.msg&&o.onAction.msg.call(e,t)})}},o=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(o.dialogbox&&o.dialogbox.length&&(this.tinvwl_dialog=o.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=o.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(o.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){o.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var e=r(this).find(o.class.select).eq(0);r(this).find(o.class.newtitle).hide().val(""),e.html(""),r.each(t,function(t,i){o.onCreateWishList.call(e,i)}),o.text_create&&o.onCreateWishList.call(e,{ID:"",title:o.text_create,in:!1}),o.onMultiProductAlreadyIn.call(e,t),o.onSelectWishList.call(e,t),r(this).find(o.class.newtitle).toggle(""===e.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=o.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),o.onDialogShow.call(this.tinvwl_dialog,this)):o.onActionProduct.call(this)});var n=this;r(this.tinvwl_dialog).find(o.class.dialogbutton).off("click").on("click",function(){var t,i=r(n.tinvwl_dialog).find(o.class.select),e=r(n.tinvwl_dialog).find(o.class.newtitle);i.val()||e.val()?o.onActionProduct.call(n,i.val(),e.val()):((t=e.is(":visible")?e:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",o.onClick),o.onInited.call(this,o)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,e){var n=r(this).find(".tinvwl_add_to_wishlist_button");if(n.length){var o=JSON.parse(n.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in o)o[s].hasOwnProperty("in")&&Array.isArray(o[s].in)&&-1<(o[s].in||[]).indexOf(i.variation_id)&&(a=!0);n.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto"),t.preventDefault(),n.removeClass("disabled-add-wishlist")}})})}(jQuery),function(n){n(document).ready(function(){if(n("#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">'),n(".tinv-lists-nav").each(function(){n.trim(n(this).html()).length||n(this).remove()}),n("body").on("click",".social-buttons .social[title!=email][title!=whatsapp][title!=clipboard]",function(t){var i=window.open(n(this).attr("href"),n(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)}n("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),n("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),n(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),n("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){n(this).data("url")&&(t.preventDefault(),window.location=n(this).data("url"))});var e=n(".tinv-wishlist .navigation-button");e.length&&e.each(function(){var t=n(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),n(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),n(this).closest(".tinv-login").find(".login").toggle()}),n(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){n(this).toggle(!!n(this).children().not(".look_in").length||!!n(this).children(".look_in").children().length)})}),n(document.body).on("wc_fragments_refreshed wc_fragments_loaded",function(){var t=!("0"==n(".wishlist_products_counter_number").html()||""==n(".wishlist_products_counter_number").html());n(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",t)}),update_cart_hash()}(jQuery),function(n){n.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return n(this).val()},rule:function(){var t=n(this).parents("form").eq(0).find(e.selector),i=e.invert;return 0===t.length?e.ifempty:(t.each(function(){i&&!e.invert||!i&&e.invert||(i=Boolean(e.validate.call(n(this))))}),i)}},e=n.extend(!0,{},i,t);return n(this).each(function(){n(this).on("click",function(t){e.rule.call(n(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},n(document).ready(function(){n(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),n(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return n(this).is(":checked")}}),n(".global-cb").on("click",function(){n(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",n(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.14.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 update_cart_hash(){if(!tinvwl_add_to_wishlist.wc_cart_fragments_refresh)return!1;jQuery(document.body).on("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist",function(){if("undefined"==typeof wc_cart_fragments_params)return!1;var t=wc_cart_fragments_params.cart_hash_key;localStorage.setItem(t,localStorage.getItem(t)+(new Date).getTime()),sessionStorage.setItem(t,sessionStorage.getItem(t)+(new Date).getTime()),jQuery(document.body).off("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist")})}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(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href,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(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):o.onActionProduct.call(this),update_cart_hash()},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var n={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val();"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n["form"+t]=e):n["form"+t]=e}),n=n.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof n)return t.in;var i=parseInt(n);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=o.onPrepareList.call(t)||t,t=o.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var e="";switch(t.length){case 0:break;default:e=r("<ul>");r.each(t,function(t,i){e.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}e.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(o.text_already_in+" ").append(e))},onAction:{redirect:function(t){o.redirectTimer&&clearTimeout(o.redirectTimer),o.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){r(this).attr("data-tinv-wl-list",t)},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer)})},status:function(t){t&&r(this).addClass("tinvwl-product-in-list")},removed:function(t){t&&r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")},make_remove:function(t){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")},fragments:function(t){if("undefined"==typeof wc_cart_fragments_params)return r.each(t,function(t,i){r(t).replaceWith(i)}),!1;var i;try{i="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(t){i=!1}if(i)try{var e=r.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),n=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash",o=sessionStorage.getItem(n),a=Cookies.get("woocommerce_cart_hash"),l=sessionStorage.getItem("wc_cart_created");if(null!=o&&""!==o||(o=""),null!=a&&""!==a||(a=""),o&&(null==l||""===l))throw"No cart_created";if(r.each(t,function(t,i){e[t]=i}),localStorage.setItem(n,localStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(n,sessionStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(e)),!e||!e["div.widget_shopping_cart_content"]||o!==a)throw"No fragment";r.each(e,function(t,i){r(t).replaceWith(i)}),r(document.body).trigger("wc_fragments_loaded")}catch(t){r(document.body).trigger("wc_fragment_refresh")}}},onActionProduct:function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},e=this;r(e).closest("form.cart[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val(),n=10,o=function t(i,e){if("object"!==_typeof(e))return e;for(var n in void 0===i&&(i={}),e)if(""===n){var o=-1;for(o in i)o=o;i[o=parseInt(o)+1]=t(i[n],e[n])}else i[n]=t(i[n],e[n]);return i};if("button"!==i&&void 0!==t&&"attribute_"!=t.substr(0,10)){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<n;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=e,e=l}t=a[1],n--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(e.length||"object"===_typeof(e)||(e=!0),s.form[t]=o(s.form[t],e)):s.form[t]=o(s.form[t],e)}}),s=o.onPrepareDataAction.call(e,e,s)||s,r.post(o.api_url,s,function(t){if(o.onDialogHide.call(e.tinvwl_dialog,e),"object"===_typeof(t))for(var i in t)"function"==typeof o.onAction[i]&&o.onAction[i].call(e,t[i]);else"function"==typeof o.onAction.msg&&o.onAction.msg.call(e,t)})}},o=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(o.dialogbox&&o.dialogbox.length&&(this.tinvwl_dialog=o.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=o.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(o.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){o.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var e=r(this).find(o.class.select).eq(0);r(this).find(o.class.newtitle).hide().val(""),e.html(""),r.each(t,function(t,i){o.onCreateWishList.call(e,i)}),o.text_create&&o.onCreateWishList.call(e,{ID:"",title:o.text_create,in:!1}),o.onMultiProductAlreadyIn.call(e,t),o.onSelectWishList.call(e,t),r(this).find(o.class.newtitle).toggle(""===e.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=o.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),o.onDialogShow.call(this.tinvwl_dialog,this)):o.onActionProduct.call(this)});var n=this;r(this.tinvwl_dialog).find(o.class.dialogbutton).off("click").on("click",function(){var t,i=r(n.tinvwl_dialog).find(o.class.select),e=r(n.tinvwl_dialog).find(o.class.newtitle);i.val()||e.val()?o.onActionProduct.call(n,i.val(),e.val()):((t=e.is(":visible")?e:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",o.onClick),o.onInited.call(this,o)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,e){var n=r(this).find(".tinvwl_add_to_wishlist_button");if(n.length){var o=JSON.parse(n.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in o)o[s].hasOwnProperty("in")&&Array.isArray(o[s].in)&&-1<(o[s].in||[]).indexOf(i.variation_id)&&(a=!0);n.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto"),t.preventDefault(),n.removeClass("disabled-add-wishlist")}})})}(jQuery),function(n){n(document).ready(function(){if(n("#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">'),n(".tinv-lists-nav").each(function(){n.trim(n(this).html()).length||n(this).remove()}),n("body").on("click",".social-buttons .social[title!=email][title!=whatsapp][title!=clipboard]",function(t){var i=window.open(n(this).attr("href"),n(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)}n("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),n("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),n(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),n("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){n(this).data("url")&&(t.preventDefault(),window.location=n(this).data("url"))});var e=n(".tinv-wishlist .navigation-button");e.length&&e.each(function(){var t=n(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),n(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),n(this).closest(".tinv-login").find(".login").toggle()}),n(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){n(this).toggle(!!n(this).children().not(".look_in").length||!!n(this).children(".look_in").children().length)})}),n(document.body).on("wc_fragments_refreshed wc_fragments_loaded",function(){var t=!("0"==n(".wishlist_products_counter_number").html()||""==n(".wishlist_products_counter_number").html());n(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",t)}),update_cart_hash()}(jQuery),function(n){n.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return n(this).val()},rule:function(){var t=n(this).parents("form").eq(0).find(e.selector),i=e.invert;return 0===t.length?e.ifempty:(t.each(function(){i&&!e.invert||!i&&e.invert||(i=Boolean(e.validate.call(n(this))))}),i)}},e=n.extend(!0,{},i,t);return n(this).each(function(){n(this).on("click",function(t){e.rule.call(n(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},n(document).ready(function(){n(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),n(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return n(this).is(":checked")}}),n(".global-cb").on("click",function(){n(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",n(this).is(":checked"))})})}(jQuery);
|
includes/tinvwl.class.php
CHANGED
@@ -97,7 +97,14 @@ class TInvWL {
|
|
97 |
* Set localization
|
98 |
*/
|
99 |
private function set_locale() {
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
$mofile = sprintf( '%1$s-%2$s.mo', TINVWL_DOMAIN, $locale );
|
102 |
$mofiles = array();
|
103 |
|
97 |
* Set localization
|
98 |
*/
|
99 |
private function set_locale() {
|
100 |
+
if ( function_exists( 'determine_locale' ) ) {
|
101 |
+
$locale = determine_locale();
|
102 |
+
} else {
|
103 |
+
$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
|
104 |
+
}
|
105 |
+
|
106 |
+
$locale = apply_filters( 'plugin_locale', $locale, TINVWL_DOMAIN );
|
107 |
+
|
108 |
$mofile = sprintf( '%1$s-%2$s.mo', TINVWL_DOMAIN, $locale );
|
109 |
$mofiles = array();
|
110 |
|
integrations/clever-swatches.php
ADDED
@@ -0,0 +1,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 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_meta_support_clever_swatches' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta Improved Product Options for WooCommerce
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function tinv_wishlist_meta_support_clever_swatches( $meta ) {
|
30 |
+
|
31 |
+
if ( class_exists( 'Zoo_Clever_Swatch_Install' ) ) {
|
32 |
+
if ( ! empty( $meta['old_variation_id'] ) ) {
|
33 |
+
unset( $meta['old_variation_id'] );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
return $meta;
|
38 |
+
}
|
39 |
+
|
40 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_clever_swatches' );
|
41 |
+
} // End if().
|
42 |
+
|
43 |
+
function tinv_add_to_wishlist_clever_swatches() {
|
44 |
+
if ( class_exists( 'Zoo_Clever_Swatch_Install' ) ) {
|
45 |
+
|
46 |
+
wp_add_inline_script( 'tinvwl', "
|
47 |
+
jQuery(document).ready(function($){
|
48 |
+
$(document).on('cleverswatch_update_gallery cleverswatch_update_cw_gallery',function (e, data) {
|
49 |
+
if (data.product_id === data.variation_id){
|
50 |
+
$(data.form_add_to_cart).trigger('hide_variation');
|
51 |
+
} else {
|
52 |
+
$(data.form_add_to_cart).trigger('show_variation', data, true);
|
53 |
+
}
|
54 |
+
});
|
55 |
+
$(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
|
56 |
+
var button = $(el);
|
57 |
+
|
58 |
+
var wrapper = button.closest('div.tinv-wraper');
|
59 |
+
|
60 |
+
if (wrapper.hasClass('tinvwl-loop-button-wrapper')){
|
61 |
+
|
62 |
+
var container = wrapper.closest('*.product');
|
63 |
+
|
64 |
+
if (container.find('a.add_to_cart_button').length > 0){
|
65 |
+
data.form.variation_id = container.find('a.add_to_cart_button').data('variation_id');
|
66 |
+
}
|
67 |
+
}
|
68 |
+
});
|
69 |
+
});
|
70 |
+
" );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
add_action( 'wp_enqueue_scripts', 'tinv_add_to_wishlist_clever_swatches', 100, 1 );
|
integrations/comet-cache.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name Comet Cache
|
6 |
+
*
|
7 |
+
* @version 170220
|
8 |
+
*
|
9 |
+
* @slug comet-cache
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/comet-cache/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( function_exists( 'tinvwl_comet_cache_reject' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set define disabled for Comet Cache
|
24 |
+
*
|
25 |
+
* @param mixed $data Any content.
|
26 |
+
*
|
27 |
+
* @return mixed
|
28 |
+
*/
|
29 |
+
function tinvwl_comet_cache_reject( $data = '' ) {
|
30 |
+
define( 'COMET_CACHE_ALLOWED', false );
|
31 |
+
|
32 |
+
return $data;
|
33 |
+
}
|
34 |
+
|
35 |
+
add_filter( 'tinvwl_addtowishlist_return_ajax', 'tinvwl_comet_cache_reject' );
|
36 |
+
add_action( 'tinvwl_before_action_owner', 'tinvwl_comet_cache_reject' );
|
37 |
+
add_action( 'tinvwl_before_action_user', 'tinvwl_comet_cache_reject' );
|
38 |
+
add_action( 'tinvwl_addproduct_tocart', 'tinvwl_comet_cache_reject' );
|
39 |
+
add_action( 'tinvwl_wishlist_addtowishlist_button', 'tinvwl_comet_cache_reject' );
|
40 |
+
add_action( 'tinvwl_wishlist_addtowishlist_dialogbox', 'tinvwl_comet_cache_reject' );
|
41 |
+
}
|
integrations/duracelltomi-google-tag-manager.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name Google Tag Manager for WordPress
|
6 |
+
*
|
7 |
+
* @version 1.10
|
8 |
+
*
|
9 |
+
* @slug duracelltomi-google-tag-manager
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/duracelltomi-google-tag-manager/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
// Google Tag Manager for WordPress compatibility.
|
21 |
+
if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Prepare save meta for WooCommerce - Google Tag Manager for WordPress
|
25 |
+
*
|
26 |
+
* @param array $meta Meta array.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function tinv_wishlist_metaprepare_gtm4wp( $meta ) {
|
31 |
+
|
32 |
+
foreach ( array_keys( $meta ) as $key ) {
|
33 |
+
if ( strpos( $key, 'gtm4wp_' ) === 0 ) {
|
34 |
+
unset( $meta[ $key ] );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return $meta;
|
39 |
+
}
|
40 |
+
|
41 |
+
add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_gtm4wp' );
|
42 |
+
}
|
integrations/gift-cards-for-woocommerce.php
ADDED
@@ -0,0 +1,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 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_gift_card_add' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Support WooCommerce - Gift Cards
|
24 |
+
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
25 |
+
*
|
26 |
+
* @param boolean $redirect Default value to redirect.
|
27 |
+
* @param \WC_Product $product Product data.
|
28 |
+
*
|
29 |
+
* @return boolean
|
30 |
+
*/
|
31 |
+
function tinvwl_gift_card_add( $redirect, $product ) {
|
32 |
+
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
33 |
+
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
34 |
+
|
35 |
+
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
36 |
+
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
37 |
+
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
38 |
+
return true;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
return $redirect;
|
44 |
+
}
|
45 |
+
|
46 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_gift_card_add', 20, 2 );
|
47 |
+
}
|
48 |
+
|
49 |
+
if ( ! function_exists( 'tinvwl_gift_card_add_url' ) ) {
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Support WooCommerce - Gift Cards
|
53 |
+
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
54 |
+
*
|
55 |
+
* @param string $redirect_url Default value to redirect.
|
56 |
+
* @param \WC_Product $product Product data.
|
57 |
+
*
|
58 |
+
* @return boolean
|
59 |
+
*/
|
60 |
+
function tinvwl_gift_card_add_url( $redirect_url, $product ) {
|
61 |
+
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
62 |
+
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
63 |
+
|
64 |
+
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
65 |
+
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
66 |
+
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
67 |
+
return $product->get_permalink();
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $redirect_url;
|
73 |
+
}
|
74 |
+
|
75 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinvwl_gift_card_add_url', 20, 2 );
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( ! function_exists( 'tinv_wishlist_meta_support_rpgiftcards' ) ) {
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Set description for meta WooCommerce - Gift Cards
|
82 |
+
*
|
83 |
+
* @param array $meta Meta array.
|
84 |
+
*
|
85 |
+
* @return array
|
86 |
+
*/
|
87 |
+
function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
|
88 |
+
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
89 |
+
foreach ( $meta as $key => $data ) {
|
90 |
+
switch ( $data['key'] ) {
|
91 |
+
case 'rpgc_note':
|
92 |
+
$meta[ $key ]['key'] = __( 'Note', 'ti-woocommerce-wishlist' );
|
93 |
+
break;
|
94 |
+
case 'rpgc_to':
|
95 |
+
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
|
96 |
+
break;
|
97 |
+
case 'rpgc_to_email':
|
98 |
+
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
|
99 |
+
break;
|
100 |
+
case 'rpgc_address':
|
101 |
+
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
|
102 |
+
break;
|
103 |
+
case 'rpgc_reload_card':
|
104 |
+
$meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'ti-woocommerce-wishlist' );
|
105 |
+
break;
|
106 |
+
case 'rpgc_description':
|
107 |
+
case 'rpgc_reload_check':
|
108 |
+
unset( $meta[ $key ] );
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
return $meta;
|
115 |
+
}
|
116 |
+
|
117 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_rpgiftcards' );
|
118 |
+
} // End if().
|
119 |
+
|
120 |
+
if ( ! function_exists( 'tinv_wishlist_metaprepare_rpgiftcards' ) ) {
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Prepare save meta for WooCommerce - Gift Cards
|
124 |
+
*
|
125 |
+
* @param array $meta Meta array.
|
126 |
+
*
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
|
130 |
+
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
131 |
+
if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
|
132 |
+
foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
|
133 |
+
if ( array_key_exists( $value, $meta ) ) {
|
134 |
+
unset( $meta[ $value ] );
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
return $meta;
|
141 |
+
}
|
142 |
+
|
143 |
+
add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_rpgiftcards' );
|
144 |
+
}
|
integrations/improved-variable-product-attributes.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name Improved Product Options for WooCommerce
|
6 |
+
*
|
7 |
+
* @version 4.5.2
|
8 |
+
*
|
9 |
+
* @slug improved-variable-product-attributes
|
10 |
+
*
|
11 |
+
* @url https://codecanyon.net/item/improved-variable-product-attributes-for-woocommerce/9981757
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_meta_support_ivpa' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta Improved Product Options for WooCommerce
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function tinv_wishlist_meta_support_ivpa( $meta ) {
|
30 |
+
global $product;
|
31 |
+
|
32 |
+
if ( class_exists( 'WC_Improved_Variable_Product_Attributes_Init' ) ) {
|
33 |
+
|
34 |
+
$curr_customizations = WC_Improved_Variable_Product_Attributes::get_custom();
|
35 |
+
|
36 |
+
foreach ( $meta as $k => $v ) {
|
37 |
+
$prefix = 'ivpac_';
|
38 |
+
$k_ivpac = ( 0 === strpos( $k, $prefix ) ) ? substr( $k, strlen( $prefix ) ) : $k;
|
39 |
+
|
40 |
+
$prefix = 'attribute_';
|
41 |
+
$k_ivpac = ( 0 === strpos( $k, $prefix ) ) ? substr( $k, strlen( $prefix ) ) : $k_ivpac;
|
42 |
+
$v = is_array( $v['display'] ) ? implode( ', ', $v['display'] ) : $v['display'];
|
43 |
+
if ( isset( $curr_customizations['ivpa_attr'][ $k_ivpac ] ) ) {
|
44 |
+
if ( $curr_customizations['ivpa_attr'][ $k_ivpac ] == 'ivpa_custom' ) {
|
45 |
+
$meta[ $k ] = array(
|
46 |
+
'key' => $curr_customizations['ivpa_title'][ $k_ivpac ],
|
47 |
+
'display' => $v,
|
48 |
+
);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
if ( in_array( $k_ivpac, $curr_customizations['ivpa_attr'] ) ) {
|
52 |
+
if ( $product->is_type( 'variation' ) && $product->get_attribute( $k_ivpac ) === $v ) {
|
53 |
+
unset( $meta[ $k ] );
|
54 |
+
} else {
|
55 |
+
$meta[ $k ] = array(
|
56 |
+
'key' => wc_attribute_label( $k_ivpac ),
|
57 |
+
'display' => $v,
|
58 |
+
);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
return $meta;
|
65 |
+
}
|
66 |
+
|
67 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_ivpa' );
|
68 |
+
} // End if().
|
69 |
+
|
70 |
+
|
71 |
+
function tinv_add_to_wishlist_ivpa() {
|
72 |
+
if ( class_exists( 'WC_Improved_Variable_Product_Attributes_Init' ) ) {
|
73 |
+
|
74 |
+
wp_add_inline_script( 'tinvwl', "
|
75 |
+
jQuery(document).ready(function($){
|
76 |
+
$(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
|
77 |
+
|
78 |
+
if (!ivpa) {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
var button = $(el);
|
82 |
+
var container = button.closest(ivpa.settings.archive_selector);
|
83 |
+
var find = button.closest('.summary').length > 0 ? '#ivpa-content' : '.ivpa-content';
|
84 |
+
|
85 |
+
if (container.find(find).length > 0) {
|
86 |
+
var var_id = container.find(find).attr('data-selected');
|
87 |
+
|
88 |
+
if (typeof var_id == 'undefined' || var_id == '') {
|
89 |
+
var_id = container.find('[name=\"variation_id\"]').val();
|
90 |
+
}
|
91 |
+
|
92 |
+
if (typeof var_id == 'undefined' || var_id == '') {
|
93 |
+
var_id = container.find(find).attr('data-id');
|
94 |
+
}
|
95 |
+
|
96 |
+
var item = {};
|
97 |
+
container.find(find + ' .ivpa_attribute').each(function () {
|
98 |
+
var attribute = $(this).attr('data-attribute');
|
99 |
+
var attribute_value = $(this).find('.ivpa_term.ivpa_clicked').attr('data-term');
|
100 |
+
|
101 |
+
data.form['attribute_' + attribute] = attribute_value;
|
102 |
+
});
|
103 |
+
|
104 |
+
var ivpac = container.find(find + ' .ivpa_custom_option').length > 0 ? container.find(find + ' .ivpa_custom_option [name^=\"ivpac_\"]').serialize() : '';
|
105 |
+
|
106 |
+
var ivpac_fields = container.find(find + ' .ivpa_custom_option').length > 0 ? container.find(find + ' .ivpa_custom_option [name^=\"ivpac_\"]') : '';
|
107 |
+
|
108 |
+
ivpac_fields.each(function () {
|
109 |
+
|
110 |
+
var name = $(this).attr('name').replace(/\[.*\]/g, '');
|
111 |
+
|
112 |
+
if ($(this).is(':checkbox')) {
|
113 |
+
|
114 |
+
if (!$(this).is(':checked')) return true;
|
115 |
+
|
116 |
+
if (data.form.hasOwnProperty(name) && data.form[name].length) {
|
117 |
+
data.form[name] = (data.form[name] + ', ' + $(this).val()).replace(/^, /, '');
|
118 |
+
} else {
|
119 |
+
data.form[name] = $(this).val();
|
120 |
+
}
|
121 |
+
} else {
|
122 |
+
data.form[name] = $(this).val();
|
123 |
+
}
|
124 |
+
});
|
125 |
+
|
126 |
+
|
127 |
+
data.form.variation_id = var_id;
|
128 |
+
data.ivpac = ivpac;
|
129 |
+
}
|
130 |
+
});
|
131 |
+
});
|
132 |
+
" );
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
add_action( 'wp_enqueue_scripts', 'tinv_add_to_wishlist_ivpa', 100, 1 );
|
integrations/mycred.php
ADDED
@@ -0,0 +1,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 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
// myCred hooks
|
21 |
+
if ( defined( 'myCRED_VERSION' ) ) {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Register Hook
|
25 |
+
*/
|
26 |
+
add_filter( 'mycred_setup_hooks', 'mycred_register_ti_woocommerce_wishlist_hook', 100 );
|
27 |
+
function mycred_register_ti_woocommerce_wishlist_hook( $installed ) {
|
28 |
+
|
29 |
+
$installed['tinvwl'] = array(
|
30 |
+
'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
|
31 |
+
'description' => __( 'Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist.', 'ti-woocommerce-wishlist' ),
|
32 |
+
'callback' => array( 'myCRED_Hook_TinvWL' ),
|
33 |
+
);
|
34 |
+
|
35 |
+
return $installed;
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* TI WooCommerce Wihslist Hook
|
41 |
+
*/
|
42 |
+
add_action( 'mycred_load_hooks', 'mycred_load_ti_woocommerce_wishlist_hook', 100 );
|
43 |
+
function mycred_load_ti_woocommerce_wishlist_hook() {
|
44 |
+
|
45 |
+
// If the hook has been replaced or if plugin is not installed, exit now
|
46 |
+
if ( class_exists( 'myCRED_Hook_TinvWL' ) ) {
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
class myCRED_Hook_TinvWL extends myCRED_Hook {
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Construct
|
54 |
+
*/
|
55 |
+
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
56 |
+
|
57 |
+
parent::__construct( array(
|
58 |
+
'id' => 'tinvwl',
|
59 |
+
'defaults' => array(
|
60 |
+
'tinvwl_added' => array(
|
61 |
+
'creds' => 1,
|
62 |
+
'log' => '%plural% for adding a product to a wishlist',
|
63 |
+
'limit' => '0/x',
|
64 |
+
),
|
65 |
+
'tinvwl_purchased' => array(
|
66 |
+
'creds' => 1,
|
67 |
+
'log' => '%plural% for purchasing a product from a wishlist',
|
68 |
+
'limit' => '0/x',
|
69 |
+
),
|
70 |
+
),
|
71 |
+
), $hook_prefs, $type );
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Run
|
77 |
+
*/
|
78 |
+
public function run() {
|
79 |
+
add_action( 'tinvwl_product_added', array( $this, 'added' ) );
|
80 |
+
add_action( 'tinvwl_product_purchased', array( $this, 'purchased' ), 10, 3 );
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Added product to a wishlist
|
85 |
+
*
|
86 |
+
* @param array $data product data including author and wishlist IDs.
|
87 |
+
*/
|
88 |
+
public function added( $data ) {
|
89 |
+
|
90 |
+
// Must be logged in
|
91 |
+
if ( ! is_user_logged_in() ) {
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
|
95 |
+
$user_id = get_current_user_id();
|
96 |
+
|
97 |
+
// Award the user adding to wishlist
|
98 |
+
if ( $this->prefs['tinvwl_added']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
|
99 |
+
|
100 |
+
// Limit
|
101 |
+
if ( ! $this->over_hook_limit( 'tinvwl_added', 'added_to_wishlist', $user_id ) ) {
|
102 |
+
|
103 |
+
// Make sure this is unique event
|
104 |
+
if ( ! $this->core->has_entry( 'added_to_wishlist', $data['product_id'], $user_id ) ) {
|
105 |
+
|
106 |
+
// Execute
|
107 |
+
$this->core->add_creds(
|
108 |
+
'added_to_wishlist',
|
109 |
+
$user_id,
|
110 |
+
$this->prefs['tinvwl_added']['creds'],
|
111 |
+
$this->prefs['tinvwl_added']['log'],
|
112 |
+
$data['product_id'],
|
113 |
+
array( 'ref_type' => 'post' ),
|
114 |
+
$this->mycred_type
|
115 |
+
);
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Purchased product from a wishlist
|
126 |
+
*
|
127 |
+
* @param WC_order $order Order object.
|
128 |
+
* @param WC_Order_Item_Product $item Order item product object.
|
129 |
+
* @param array $wishlist A wishlist data where product added from.
|
130 |
+
*/
|
131 |
+
public function purchased( $order, $item, $wishlist ) {
|
132 |
+
|
133 |
+
// Must be logged in
|
134 |
+
if ( ! is_user_logged_in() ) {
|
135 |
+
return;
|
136 |
+
}
|
137 |
+
|
138 |
+
$user_id = get_current_user_id();
|
139 |
+
|
140 |
+
// Award the user adding to wishlist
|
141 |
+
if ( $this->prefs['tinvwl_purchased']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
|
142 |
+
|
143 |
+
// Limit
|
144 |
+
if ( ! $this->over_hook_limit( 'tinvwl_purchased', 'purchased_from_wishlist', $user_id ) ) {
|
145 |
+
|
146 |
+
// Make sure this is unique event
|
147 |
+
if ( ! $this->core->has_entry( 'purchased_from_wishlist', $item->get_id(), $user_id ) ) {
|
148 |
+
|
149 |
+
// Execute
|
150 |
+
$this->core->add_creds(
|
151 |
+
'purchased_from_wishlist',
|
152 |
+
$user_id,
|
153 |
+
$this->prefs['tinvwl_purchased']['creds'],
|
154 |
+
$this->prefs['tinvwl_purchased']['log'],
|
155 |
+
$item->get_id(),
|
156 |
+
array( 'ref_type' => 'post' ),
|
157 |
+
$this->mycred_type
|
158 |
+
);
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Preferences
|
170 |
+
*/
|
171 |
+
public function preferences() {
|
172 |
+
|
173 |
+
$prefs = $this->prefs;
|
174 |
+
|
175 |
+
?>
|
176 |
+
<div class="hook-instance">
|
177 |
+
<h3><?php _e( 'Adding Product to Wishlist', 'ti-woocommerce-wishlist' ); ?></h3>
|
178 |
+
<div class="row">
|
179 |
+
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
180 |
+
<div class="form-group">
|
181 |
+
<label
|
182 |
+
for="<?php echo $this->field_id( array( 'tinvwl_added' => 'creds' ) ); ?>"><?php _e( 'Points', 'ti-woocommerce-wishlist' ); ?></label>
|
183 |
+
<input type="text"
|
184 |
+
name="<?php echo $this->field_name( array( 'tinvwl_added' => 'creds' ) ); ?>"
|
185 |
+
id="<?php echo $this->field_id( array( 'tinvwl_added' => 'creds' ) ); ?>"
|
186 |
+
value="<?php echo $this->core->number( $prefs['tinvwl_added']['creds'] ); ?>"
|
187 |
+
class="form-control"/>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
191 |
+
<div class="form-group">
|
192 |
+
<label for="<?php echo $this->field_id( array(
|
193 |
+
'tinvwl_added',
|
194 |
+
'limit',
|
195 |
+
) ); ?>"><?php _e( 'Limit', 'ti-woocommerce-wishlist' ); ?></label>
|
196 |
+
<?php echo $this->hook_limit_setting( $this->field_name( array(
|
197 |
+
'tinvwl_added',
|
198 |
+
'limit',
|
199 |
+
) ), $this->field_id( array(
|
200 |
+
'tinvwl_added',
|
201 |
+
'limit',
|
202 |
+
) ), $prefs['tinvwl_added']['limit'] ); ?>
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
206 |
+
<div class="form-group">
|
207 |
+
<label
|
208 |
+
for="<?php echo $this->field_id( array( 'tinvwl_added' => 'log' ) ); ?>"><?php _e( 'Log Template', 'ti-woocommerce-wishlist' ); ?></label>
|
209 |
+
<input type="text"
|
210 |
+
name="<?php echo $this->field_name( array( 'tinvwl_added' => 'log' ) ); ?>"
|
211 |
+
id="<?php echo $this->field_id( array( 'tinvwl_added' => 'log' ) ); ?>"
|
212 |
+
placeholder="<?php _e( 'required', 'ti-woocommerce-wishlist' ); ?>"
|
213 |
+
value="<?php echo esc_attr( $prefs['tinvwl_added']['log'] ); ?>"
|
214 |
+
class="form-control"/>
|
215 |
+
<span class="description"><?php echo $this->available_template_tags( array(
|
216 |
+
'general',
|
217 |
+
'post',
|
218 |
+
) ); ?></span>
|
219 |
+
</div>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
<h3><?php _e( 'Purchasing Product from Wishlist', 'ti-woocommerce-wishlist' ); ?></h3>
|
223 |
+
<div class="row">
|
224 |
+
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
225 |
+
<div class="form-group">
|
226 |
+
<label
|
227 |
+
for="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'creds' ) ); ?>"><?php _e( 'Points', 'ti-woocommerce-wishlist' ); ?></label>
|
228 |
+
<input type="text"
|
229 |
+
name="<?php echo $this->field_name( array( 'tinvwl_purchased' => 'creds' ) ); ?>"
|
230 |
+
id="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'creds' ) ); ?>"
|
231 |
+
value="<?php echo $this->core->number( $prefs['tinvwl_purchased']['creds'] ); ?>"
|
232 |
+
class="form-control"/>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
236 |
+
<div class="form-group">
|
237 |
+
<label for="<?php echo $this->field_id( array(
|
238 |
+
'tinvwl_purchased',
|
239 |
+
'limit',
|
240 |
+
) ); ?>"><?php _e( 'Limit', 'ti-woocommerce-wishlist' ); ?></label>
|
241 |
+
<?php echo $this->hook_limit_setting( $this->field_name( array(
|
242 |
+
'tinvwl_purchased',
|
243 |
+
'limit',
|
244 |
+
) ), $this->field_id( array(
|
245 |
+
'tinvwl_purchased',
|
246 |
+
'limit',
|
247 |
+
) ), $prefs['tinvwl_purchased']['limit'] ); ?>
|
248 |
+
</div>
|
249 |
+
</div>
|
250 |
+
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
251 |
+
<div class="form-group">
|
252 |
+
<label
|
253 |
+
for="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'log' ) ); ?>"><?php _e( 'Log Template', 'ti-woocommerce-wishlist' ); ?></label>
|
254 |
+
<input type="text"
|
255 |
+
name="<?php echo $this->field_name( array( 'tinvwl_purchased' => 'log' ) ); ?>"
|
256 |
+
id="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'log' ) ); ?>"
|
257 |
+
placeholder="<?php _e( 'required', 'ti-woocommerce-wishlist' ); ?>"
|
258 |
+
value="<?php echo esc_attr( $prefs['tinvwl_purchased']['log'] ); ?>"
|
259 |
+
class="form-control"/>
|
260 |
+
<span class="description"><?php echo $this->available_template_tags( array(
|
261 |
+
'general',
|
262 |
+
'post',
|
263 |
+
) ); ?></span>
|
264 |
+
</div>
|
265 |
+
</div>
|
266 |
+
</div>
|
267 |
+
</div>
|
268 |
+
|
269 |
+
<?php
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Sanitise Preferences
|
275 |
+
*/
|
276 |
+
public function sanitise_preferences( $data ) {
|
277 |
+
|
278 |
+
if ( isset( $data['tinvwl_added']['limit'] ) && isset( $data['tinvwl_added']['limit_by'] ) ) {
|
279 |
+
$limit = sanitize_text_field( $data['tinvwl_added']['limit'] );
|
280 |
+
if ( $limit == '' ) {
|
281 |
+
$limit = 0;
|
282 |
+
}
|
283 |
+
$data['tinvwl_added']['limit'] = $limit . '/' . $data['tinvwl_added']['limit_by'];
|
284 |
+
unset( $data['tinvwl_added']['limit_by'] );
|
285 |
+
}
|
286 |
+
|
287 |
+
if ( isset( $data['tinvwl_purchased']['limit'] ) && isset( $data['tinvwl_purchased']['limit_by'] ) ) {
|
288 |
+
$limit = sanitize_text_field( $data['tinvwl_purchased']['limit'] );
|
289 |
+
if ( $limit == '' ) {
|
290 |
+
$limit = 0;
|
291 |
+
}
|
292 |
+
$data['tinvwl_purchased']['limit'] = $limit . '/' . $data['tinvwl_purchased']['limit_by'];
|
293 |
+
unset( $data['tinvwl_purchased']['limit_by'] );
|
294 |
+
}
|
295 |
+
|
296 |
+
return $data;
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
}
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
add_filter( 'mycred_all_references', 'tinvwl_mycred_references' );
|
305 |
+
|
306 |
+
function tinvwl_mycred_references( $references ) {
|
307 |
+
|
308 |
+
$references['purchased_from_wishlist'] = __( 'Purchased From Wishlist', 'ti-woocommerce-wishlist' );
|
309 |
+
$references['added_to_wishlist'] = __( 'Added To Wishlist', 'ti-woocommerce-wishlist' );
|
310 |
+
|
311 |
+
return $references;
|
312 |
+
}
|
313 |
+
}
|
integrations/oceanwp.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name OceanWP
|
6 |
+
*
|
7 |
+
* @version
|
8 |
+
*
|
9 |
+
* @slug
|
10 |
+
*
|
11 |
+
* @url https://oceanwp.org/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
// OceanWP theme compatibility;
|
21 |
+
if ( ! function_exists( 'oceanwp_fix_archive_markup' ) ) {
|
22 |
+
add_action( 'init', 'oceanwp_fix_archive_markup' );
|
23 |
+
|
24 |
+
/**
|
25 |
+
* OceanWP theme fix for catalog add to wishlist button position
|
26 |
+
*/
|
27 |
+
function oceanwp_fix_archive_markup() {
|
28 |
+
if ( class_exists( 'OceanWP_WooCommerce_Config' ) && 'above_thumb' === tinv_get_option( 'add_to_wishlist_catalog', 'position' ) ) {
|
29 |
+
remove_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 9 );
|
30 |
+
add_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 10 );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
integrations/sitepress-multilingual-cms.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WPML Multilingual CMS
|
6 |
+
*
|
7 |
+
* @version 4.2.7.1
|
8 |
+
*
|
9 |
+
* @slug sitepress-multilingual-cms
|
10 |
+
*
|
11 |
+
* @url https://wpml.org/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_wpml_product_get' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Change product data if product need translate
|
24 |
+
*
|
25 |
+
* @param array $product Wishlistl product.
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function tinvwl_wpml_product_get( $product ) {
|
30 |
+
if ( array_key_exists( 'data', $product ) ) {
|
31 |
+
$_product_id = $product_id = $product['product_id'];
|
32 |
+
$_variation_id = $variation_id = $product['variation_id'];
|
33 |
+
$_product_id = apply_filters( 'wpml_object_id', $_product_id, 'product', true );
|
34 |
+
if ( ! empty( $_variation_id ) ) {
|
35 |
+
$_variation_id = apply_filters( 'wpml_object_id', $_variation_id, 'product', true );
|
36 |
+
}
|
37 |
+
if ( $_product_id !== $product_id || $_variation_id !== $variation_id ) {
|
38 |
+
$product['data'] = wc_get_product( $variation_id ? $_variation_id : $_product_id );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
return $product;
|
43 |
+
}
|
44 |
+
|
45 |
+
add_filter( 'tinvwl_wishlist_product_get', 'tinvwl_wpml_product_get' );
|
46 |
+
}
|
47 |
+
|
48 |
+
if ( ! function_exists( 'tinvwl_wpml_filter_link' ) ) {
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Correct add wishlist key for WPML plugin.
|
52 |
+
*
|
53 |
+
* @param string $full_link Link for page.
|
54 |
+
* @param array $l Language.
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
function tinvwl_wpml_filter_link( $full_link, $l ) {
|
59 |
+
$share_key = get_query_var( 'tinvwlID', null );
|
60 |
+
if ( ! empty( $share_key ) ) {
|
61 |
+
if ( get_option( 'permalink_structure' ) ) {
|
62 |
+
$suffix = '';
|
63 |
+
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $full_link, $_full_link ) ) {
|
64 |
+
$full_link = $_full_link[1];
|
65 |
+
$suffix = $_full_link[2];
|
66 |
+
}
|
67 |
+
if ( ! preg_match( '/\/$/', $full_link ) ) {
|
68 |
+
$full_link .= '/';
|
69 |
+
}
|
70 |
+
$full_link .= $share_key . '/' . $suffix;
|
71 |
+
} else {
|
72 |
+
$full_link .= add_query_arg( 'tinvwlID', $share_key, $full_link );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
return $full_link;
|
77 |
+
}
|
78 |
+
|
79 |
+
add_filter( 'WPML_filter_link', 'tinvwl_wpml_filter_link', 0, 2 );
|
80 |
+
}
|
integrations/woo-advanced-qty.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Advanced Quantity
|
6 |
+
*
|
7 |
+
* @version 2.4.4
|
8 |
+
*
|
9 |
+
* @slug woo-advanced-qty
|
10 |
+
*
|
11 |
+
* @url https://codecanyon.net/item/woocommerce-advanced-quantity/11861326
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
// WooCommerce Advanced Quantity compatibility.
|
21 |
+
if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_qty' ) ) {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Force quantity to minimum.
|
25 |
+
*
|
26 |
+
* @param $quantity
|
27 |
+
* @param $product
|
28 |
+
*
|
29 |
+
* @return mixed
|
30 |
+
*/
|
31 |
+
function tinv_wishlist_qty_woo_advanced_qty( $quantity, $product ) {
|
32 |
+
|
33 |
+
if ( class_exists( 'Woo_Advanced_QTY_Public' ) ) {
|
34 |
+
$advanced_qty = new Woo_Advanced_QTY_Public( null, null );
|
35 |
+
|
36 |
+
$args = $advanced_qty->qty_input_args( array(
|
37 |
+
'min_value' => 1,
|
38 |
+
'max_value' => '',
|
39 |
+
'step' => 1,
|
40 |
+
), $product );
|
41 |
+
|
42 |
+
$quantity = $args['input_value'];
|
43 |
+
}
|
44 |
+
|
45 |
+
return $quantity;
|
46 |
+
}
|
47 |
+
|
48 |
+
add_filter( 'tinvwl_product_add_to_cart_quantity', 'tinv_wishlist_qty_woo_advanced_qty', 10, 2 );
|
49 |
+
}
|
50 |
+
|
51 |
+
// WooCommerce Advanced Quantity compatibility.
|
52 |
+
if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_url' ) ) {
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param $url
|
56 |
+
* @param $product
|
57 |
+
*
|
58 |
+
* @return string|string[]|null
|
59 |
+
*/
|
60 |
+
function tinv_wishlist_qty_woo_advanced_url( $url, $product ) {
|
61 |
+
|
62 |
+
if ( class_exists( 'Woo_Advanced_QTY_Public' ) ) {
|
63 |
+
if ( strpos( $url, 'add-to-cart=' ) ) {
|
64 |
+
$advanced_qty = new Woo_Advanced_QTY_Public( null, null );
|
65 |
+
$args = $advanced_qty->qty_input_args( array(
|
66 |
+
'min_value' => 1,
|
67 |
+
'max_value' => '',
|
68 |
+
'step' => 1,
|
69 |
+
), $product );
|
70 |
+
|
71 |
+
$url = preg_replace( '/&quantity=[0-9.]*/', '', $url );
|
72 |
+
|
73 |
+
$url .= '&quantity=' . $args['input_value'];
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
return $url;
|
78 |
+
}
|
79 |
+
|
80 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_slug_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
|
81 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_url_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
|
82 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
|
83 |
+
}
|
integrations/woo-custom-product-addons.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Custom Product Addons
|
6 |
+
*
|
7 |
+
* @version 2.3.5
|
8 |
+
*
|
9 |
+
* @slug woo-custom-product-addons
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/woo-custom-product-addons/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addons' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Custom Product Addons
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param array $wl_product Wishlist Product.
|
27 |
+
* @param \WC_Product $product Woocommerce Product.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
|
32 |
+
function tinv_wishlist_item_meta_woocommerce_custom_product_addons( $item_data, $product_id, $variation_id ) {
|
33 |
+
if ( function_exists( 'WCPA' ) ) {
|
34 |
+
$form = new WCPA_Form();
|
35 |
+
$frontend = new WCPA_Front_End();
|
36 |
+
$data = array();
|
37 |
+
$post_ids = $form->get_form_ids( $product_id );
|
38 |
+
|
39 |
+
if ( wcpa_get_option( 'form_loading_order_by_date' ) === true ) {
|
40 |
+
if ( is_array( $post_ids ) && count( $post_ids ) ) {
|
41 |
+
$post_ids = get_posts( array(
|
42 |
+
'posts_per_page' => - 1,
|
43 |
+
'include' => $post_ids,
|
44 |
+
'fields' => 'ids',
|
45 |
+
'post_type' => WCPA_POST_TYPE,
|
46 |
+
'posts_per_page' => - 1,
|
47 |
+
) );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
foreach ( $post_ids as $id ) {
|
51 |
+
if ( get_post_status( $id ) == 'publish' ) {
|
52 |
+
$json_string = get_post_meta( $id, WCPA_FORM_META_KEY, true );
|
53 |
+
$json_encoded = json_decode( $json_string );
|
54 |
+
if ( $json_encoded && is_array( $json_encoded ) ) {
|
55 |
+
$data = array_merge( $data, $json_encoded );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
foreach ( $data as $v ) {
|
61 |
+
$form_data = clone $v;
|
62 |
+
unset( $form_data->values ); //avoid saving large number of data
|
63 |
+
unset( $form_data->className ); //avoid saving no use data
|
64 |
+
if ( ! in_array( $v->type, array( 'header', 'paragraph' ) ) ) {
|
65 |
+
if ( isset( $item_data[ $v->name ] ) ) {
|
66 |
+
|
67 |
+
if ( ! is_object( $v ) ) {
|
68 |
+
$value = sanitize_text_field( $v );
|
69 |
+
} else if ( ( isset( $v->name ) ) ) {
|
70 |
+
if ( is_array( $item_data[ $v->name ] ) ) {
|
71 |
+
|
72 |
+
$_values = $item_data[ $v->name ];
|
73 |
+
array_walk( $_values, function ( &$a ) {
|
74 |
+
sanitize_text_field( $a );
|
75 |
+
} ); // using this array_wal method to preserve the keys
|
76 |
+
$value = $_values;
|
77 |
+
} else if ( $v->type == 'textarea' ) {
|
78 |
+
$value = sanitize_textarea_field( wp_unslash( $item_data[ $v->name ] ) );
|
79 |
+
} else {
|
80 |
+
$value = sanitize_text_field( wp_unslash( $item_data[ $v->name ] ) );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$item_data[ $v->name ]['key'] = ( isset( $v->label ) ) ? $v->label : '';
|
84 |
+
$item_data[ $v->name ]['display'] = $frontend->cart_display( array(
|
85 |
+
'type' => $v->type,
|
86 |
+
'name' => $v->name,
|
87 |
+
'label' => ( isset( $v->label ) ) ? $v->label : '',
|
88 |
+
'value' => $value['display'],
|
89 |
+
'price' => false,
|
90 |
+
'form_data' => $form_data,
|
91 |
+
), wc_get_product( $product_id ) );
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $item_data;
|
98 |
+
}
|
99 |
+
|
100 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_product_addons', 10, 3 );
|
101 |
+
}
|
integrations/woocommerce-booking.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name Booking & Appointment Plugin for WooCommerce
|
6 |
+
*
|
7 |
+
* @version 4.14.0
|
8 |
+
*
|
9 |
+
* @slug woocommerce-booking
|
10 |
+
*
|
11 |
+
* @url http://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_booking' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta Booking & Appointment Plugin for WooCommerce
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Priduct ID.
|
27 |
+
* @param integer $variation_id Variation Product ID.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
function tinv_wishlist_metasupport_woocommerce_booking( $meta, $product_id, $variation_id ) {
|
32 |
+
if ( ! class_exists( 'woocommerce_booking' ) ) {
|
33 |
+
return $meta;
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( ! empty( $meta['bkap_price_charged'] ) ) {
|
37 |
+
|
38 |
+
$item_data = array(
|
39 |
+
'bkap_booking' => array(),
|
40 |
+
'product_id' => $product_id,
|
41 |
+
);
|
42 |
+
|
43 |
+
if ( ! empty( $meta['booking_calender'] ) ) {
|
44 |
+
$item_data['bkap_booking'][0]['date'] = $meta['booking_calender']['display'];
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( ! empty( $meta['booking_calender_checkout'] ) ) {
|
48 |
+
$item_data['bkap_booking'][0]['date_checkout'] = $meta['booking_calender_checkout']['display'];
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( ! empty( $meta['time_slot'] ) ) {
|
52 |
+
$item_data['bkap_booking'][0]['time_slot'] = $meta['time_slot']['display'];
|
53 |
+
}
|
54 |
+
if ( ! empty( $meta['bkap_front_resource_selection'] ) ) {
|
55 |
+
$item_data['bkap_booking'][0]['resource_id'] = $meta['bkap_front_resource_selection']['display'];
|
56 |
+
}
|
57 |
+
|
58 |
+
$custom_meta = bkap_cart::bkap_get_item_data_booking( array(), $item_data );
|
59 |
+
|
60 |
+
foreach ( $custom_meta as $key => $item ) {
|
61 |
+
$custom_meta[ $key ]['key'] = $item['name'];
|
62 |
+
unset( $custom_meta[ $key ]['name'] );
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( $custom_meta ) {
|
66 |
+
return $custom_meta;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $meta;
|
71 |
+
}
|
72 |
+
|
73 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_booking', 20, 3 );
|
74 |
+
} // End if().
|
75 |
+
|
76 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_booking' ) ) {
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Modify price for Booking & Appointment Plugin for WooCommerce
|
80 |
+
*
|
81 |
+
* @param string $price Returned price.
|
82 |
+
* @param array $wl_product Wishlist Product.
|
83 |
+
* @param \WC_Product $product Woocommerce Product.
|
84 |
+
*
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
function tinvwl_item_price_woocommerce_booking( $price, $wl_product, $product ) {
|
88 |
+
if ( ! class_exists( 'woocommerce_booking' ) ) {
|
89 |
+
return $price;
|
90 |
+
}
|
91 |
+
|
92 |
+
$meta = $wl_product['meta'];
|
93 |
+
|
94 |
+
if ( ! empty( $meta['bkap_price_charged'] ) ) {
|
95 |
+
|
96 |
+
$price = $meta['bkap_price_charged'];
|
97 |
+
|
98 |
+
return wc_price( $price );
|
99 |
+
}
|
100 |
+
|
101 |
+
return $price;
|
102 |
+
}
|
103 |
+
|
104 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_booking', 20, 3 );
|
105 |
+
} // End if().
|
integrations/woocommerce-bookings.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Bookings
|
6 |
+
*
|
7 |
+
* @version 1.15.1
|
8 |
+
*
|
9 |
+
* @slug woocommerce-bookings
|
10 |
+
*
|
11 |
+
* @url https://woocommerce.com/products/woocommerce-bookings/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_bookings' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Bookings
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Priduct ID.
|
27 |
+
* @param integer $variation_id Variation Product ID.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
function tinv_wishlist_metasupport_woocommerce_bookings( $meta, $product_id, $variation_id ) {
|
32 |
+
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
33 |
+
return $meta;
|
34 |
+
}
|
35 |
+
$product = wc_get_product( $variation_id ? $variation_id : $product_id );
|
36 |
+
if ( is_wc_booking_product( $product ) ) {
|
37 |
+
$booking_form = new WC_Booking_Form( $product );
|
38 |
+
$post_data = array();
|
39 |
+
foreach ( $meta as $data ) {
|
40 |
+
$post_data[ $data['key'] ] = $data['display'];
|
41 |
+
}
|
42 |
+
$booking_data = $booking_form->get_posted_data( $post_data );
|
43 |
+
$meta = array();
|
44 |
+
foreach ( $booking_data as $key => $value ) {
|
45 |
+
if ( ! preg_match( '/^_/', $key ) ) {
|
46 |
+
$meta[ $key ] = array(
|
47 |
+
'key' => get_wc_booking_data_label( $key, $product ),
|
48 |
+
'display' => $value,
|
49 |
+
);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
return $meta;
|
55 |
+
}
|
56 |
+
|
57 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_bookings', 10, 3 );
|
58 |
+
} // End if().
|
59 |
+
|
60 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_bookings' ) ) {
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Modify price for WooCommerce Bookings
|
64 |
+
*
|
65 |
+
* @param string $price Returned price.
|
66 |
+
* @param array $wl_product Wishlist Product.
|
67 |
+
* @param \WC_Product $product Woocommerce Product.
|
68 |
+
*
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
function tinvwl_item_price_woocommerce_bookings( $price, $wl_product, $product ) {
|
72 |
+
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
73 |
+
return $price;
|
74 |
+
}
|
75 |
+
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
76 |
+
$booking_form = new WC_Booking_Form( $product );
|
77 |
+
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
78 |
+
if ( is_wp_error( $cost ) ) {
|
79 |
+
return $price;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
|
83 |
+
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
84 |
+
$display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
|
85 |
+
} else {
|
86 |
+
$display_price = $product->get_price_including_tax( 1, $cost );
|
87 |
+
}
|
88 |
+
} else {
|
89 |
+
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
90 |
+
$display_price = wc_get_price_excluding_tax( $product, array( 'price' => $cost ) );
|
91 |
+
} else {
|
92 |
+
$display_price = $product->get_price_excluding_tax( 1, $cost );
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( version_compare( WC_VERSION, '2.4.0', '>=' ) ) {
|
97 |
+
$price_suffix = $product->get_price_suffix( $cost, 1 );
|
98 |
+
} else {
|
99 |
+
$price_suffix = $product->get_price_suffix();
|
100 |
+
}
|
101 |
+
$price = wc_price( $display_price ) . $price_suffix;
|
102 |
+
}
|
103 |
+
|
104 |
+
return $price;
|
105 |
+
}
|
106 |
+
|
107 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_bookings', 10, 3 );
|
108 |
+
} // End if().
|
109 |
+
|
110 |
+
if ( ! function_exists( 'tinvwl_item_status_woocommerce_bookings' ) ) {
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Modify availability for WooCommerce Bookings
|
114 |
+
*
|
115 |
+
* @param string $status Status availability.
|
116 |
+
* @param string $availability Default availability.
|
117 |
+
* @param array $wl_product Wishlist Product.
|
118 |
+
* @param \WC_Product $product Woocommerce Product.
|
119 |
+
*
|
120 |
+
* @return type
|
121 |
+
*/
|
122 |
+
function tinvwl_item_status_woocommerce_bookings( $status, $availability, $wl_product, $product ) {
|
123 |
+
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
124 |
+
return $status;
|
125 |
+
}
|
126 |
+
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
127 |
+
$booking_form = new WC_Booking_Form( $product );
|
128 |
+
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
129 |
+
if ( is_wp_error( $cost ) ) {
|
130 |
+
return '<p class="stock out-of-stock"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . $cost->get_error_message() . '</span></p>';
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
return $status;
|
135 |
+
}
|
136 |
+
|
137 |
+
add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_woocommerce_bookings', 10, 4 );
|
138 |
+
}
|
integrations/woocommerce-composite-products.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Composite Products
|
6 |
+
*
|
7 |
+
* @version 4.2.0
|
8 |
+
*
|
9 |
+
* @slug woocommerce-composite-products
|
10 |
+
*
|
11 |
+
* @url https://woocommerce.com/products/composite-products/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_composite_products' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Composite Products
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Product ID.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function tinv_wishlist_metasupport_woocommerce_composite_products( $meta, $product_id ) {
|
31 |
+
if ( array_key_exists( 'wccp_component_selection', $meta ) && is_array( $meta['wccp_component_selection'] ) ) {
|
32 |
+
$meta = array();
|
33 |
+
} // End if().
|
34 |
+
|
35 |
+
return $meta;
|
36 |
+
}
|
37 |
+
|
38 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_composite_products', 10, 2 );
|
39 |
+
} // End if().
|
40 |
+
|
41 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_composite_products' ) ) {
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Add rows for sub product for WooCommerce Composite Products
|
45 |
+
*
|
46 |
+
* @param array $wl_product Wishlist Product.
|
47 |
+
* @param \WC_Product_Composite $product Woocommerce Product.
|
48 |
+
*/
|
49 |
+
function tinvwl_row_woocommerce_composite_products( $wl_product, $product ) {
|
50 |
+
if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
|
51 |
+
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
52 |
+
|
53 |
+
$components = $product->get_components();
|
54 |
+
foreach ( $components as $component_id => $component ) {
|
55 |
+
$composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
|
56 |
+
$composited_product_quantity = isset( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) : $component->get_quantity( 'min' );
|
57 |
+
|
58 |
+
$composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
|
59 |
+
|
60 |
+
if ( $composited_product_id ) {
|
61 |
+
|
62 |
+
$composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
|
63 |
+
|
64 |
+
if ( ! $composited_product_wrapper ) {
|
65 |
+
continue;
|
66 |
+
}
|
67 |
+
|
68 |
+
$composited_product = $composited_product_wrapper->get_product();
|
69 |
+
|
70 |
+
if ( $composited_product->is_sold_individually() && $composited_product_quantity > 1 ) {
|
71 |
+
$composited_product_quantity = 1;
|
72 |
+
}
|
73 |
+
|
74 |
+
$product_url = $composited_product->get_permalink();
|
75 |
+
$product_image = $composited_product->get_image();
|
76 |
+
$product_title = $composited_product->get_title();
|
77 |
+
$product_price = $composited_product->get_price_html();
|
78 |
+
|
79 |
+
$component_option = $product->get_component_option( $component_id, $composited_product_id );
|
80 |
+
|
81 |
+
if ( $component_option ) {
|
82 |
+
if ( false === $component_option->is_priced_individually() && $composited_product->get_price() == 0 ) {
|
83 |
+
$product_price = '';
|
84 |
+
} elseif ( false === $component_option->get_component()->is_subtotal_visible( 'cart' ) ) {
|
85 |
+
$product_price = '';
|
86 |
+
} elseif ( apply_filters( 'woocommerce_add_composited_cart_item_prices', true ) ) {
|
87 |
+
if ( $product_price ) {
|
88 |
+
$product_price = '<span class="component_table_item_price">' . $product_price . '</span>';
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( $composited_product->is_visible() ) {
|
94 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
95 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
96 |
+
}
|
97 |
+
$product_title .= tinv_wishlist_get_item_data( $composited_product, $wl_product );
|
98 |
+
|
99 |
+
$availability = (array) $composited_product->get_availability();
|
100 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
101 |
+
$availability['availability'] = '';
|
102 |
+
}
|
103 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
104 |
+
$availability['class'] = '';
|
105 |
+
}
|
106 |
+
$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>';
|
107 |
+
$row_string = '<tr>';
|
108 |
+
$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>';
|
109 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
110 |
+
$row_string .= ( $product_price ) ? '<td class="product-price">%4$s × %6$s</td>' : '<td class="product-price">%4$s</td>';
|
111 |
+
}
|
112 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
113 |
+
$row_string .= '<td class="product-date"> </td>';
|
114 |
+
}
|
115 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
116 |
+
$row_string .= '<td class="product-stock">%5$s</td>';
|
117 |
+
}
|
118 |
+
if ( tinv_get_option( 'product_table', 'colm_quantity' ) ) {
|
119 |
+
$row_string .= '<td class="product-quantity"> </td>';
|
120 |
+
}
|
121 |
+
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
122 |
+
$row_string .= '<td class="product-action"> </td>';
|
123 |
+
}
|
124 |
+
$row_string .= '</tr>';
|
125 |
+
|
126 |
+
echo sprintf( $row_string, $component->get_title(), $product_image, $product_title, $product_price, $availability_html, $composited_product_quantity * $product_quantity ); // WPCS: xss ok.
|
127 |
+
} // End if().
|
128 |
+
} // End foreach().
|
129 |
+
} // End if().
|
130 |
+
}
|
131 |
+
|
132 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_composite_products', 10, 2 );
|
133 |
+
} // End if().
|
134 |
+
|
135 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_composite_products' ) ) {
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Modify price for WooCommerce Composite Products
|
139 |
+
*
|
140 |
+
* @param string $price Returned price.
|
141 |
+
* @param array $wl_product Wishlist Product.
|
142 |
+
* @param \WC_Product $product Woocommerce Product.
|
143 |
+
*
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
function tinvwl_item_price_woocommerce_composite_products( $price, $wl_product, $product ) {
|
147 |
+
if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
|
148 |
+
$components = $product->get_components();
|
149 |
+
$_price = $product->get_price();
|
150 |
+
$regular_price = $product->get_regular_price();
|
151 |
+
foreach ( $components as $component_id => $component ) {
|
152 |
+
$composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
|
153 |
+
$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' );
|
154 |
+
|
155 |
+
$composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
|
156 |
+
|
157 |
+
if ( $composited_product_id ) {
|
158 |
+
$composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
|
159 |
+
if ( $component->is_priced_individually() ) {
|
160 |
+
$_price += $composited_product_wrapper->get_price() * $composited_product_quantity;
|
161 |
+
$regular_price += $composited_product_wrapper->get_regular_price() * $composited_product_quantity;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
if ( $_price == $regular_price ) {
|
166 |
+
$price = wc_price( $_price ) . $product->get_price_suffix();
|
167 |
+
} else {
|
168 |
+
$price = wc_format_sale_price( $regular_price, $_price ) . $product->get_price_suffix();
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
return $price;
|
173 |
+
}
|
174 |
+
|
175 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_composite_products', 10, 3 );
|
176 |
+
} // End if().
|
integrations/woocommerce-custom-fields.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Custom Fields
|
6 |
+
*
|
7 |
+
* @version 2.3.2
|
8 |
+
*
|
9 |
+
* @slug woocommerce-custom-fields
|
10 |
+
*
|
11 |
+
* @url https://codecanyon.net/item/woocommerce-custom-fields/11332742
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_fields' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Modify price for WooCommerce Custom Fields.
|
24 |
+
*
|
25 |
+
* @param string $price Returned price.
|
26 |
+
* @param array $wl_product Wishlist Product.
|
27 |
+
* @param \WC_Product $product Woocommerce Product.
|
28 |
+
*
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
function tinvwl_item_price_woocommerce_custom_fields( $price, $wl_product, $product ) {
|
32 |
+
|
33 |
+
if ( class_exists( 'WCCF' ) && isset( $wl_product['meta']['wccf']['product_field'] ) ) {
|
34 |
+
|
35 |
+
$posted = array();
|
36 |
+
|
37 |
+
foreach ( $wl_product['meta']['wccf']['product_field'] as $key => $value ) {
|
38 |
+
$posted[ $key ] = array( 'value' => $value );
|
39 |
+
}
|
40 |
+
|
41 |
+
$price = wc_price( WCCF_Pricing::get_adjusted_price( $product->get_price(), $wl_product['product_id'], $wl_product['variation_id'], $posted, 1, false, false, $product, false ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
return $price;
|
45 |
+
}
|
46 |
+
|
47 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_fields', 10, 3 );
|
48 |
+
} // End if().
|
49 |
+
|
50 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) ) {
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Set description for meta WooCommerce Custom Fields
|
54 |
+
*
|
55 |
+
* @param array $meta Meta array.
|
56 |
+
* @param array $wl_product Wishlist Product.
|
57 |
+
* @param \WC_Product $product Woocommerce Product.
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
function tinv_wishlist_item_meta_woocommerce_custom_fields( $item_data, $product_id, $variation_id ) {
|
62 |
+
|
63 |
+
if ( class_exists( 'WCCF' ) && isset( $item_data['wccf'] ) ) {
|
64 |
+
|
65 |
+
$id = ( $variation_id ) ? $variation_id : $product_id;
|
66 |
+
$product = wc_get_product( $id );
|
67 |
+
if ( $product ) {
|
68 |
+
|
69 |
+
// Get fields to save values for
|
70 |
+
$fields = WCCF_Product_Field_Controller::get_filtered( null, array(
|
71 |
+
'item_id' => $product_id,
|
72 |
+
'child_id' => $variation_id,
|
73 |
+
) );
|
74 |
+
|
75 |
+
// Set quantity
|
76 |
+
$quantity = 1;
|
77 |
+
$quantity_index = null;
|
78 |
+
$display_pricing = null;
|
79 |
+
|
80 |
+
// Check if pricing can be displayed for this product
|
81 |
+
if ( $display_pricing === null ) {
|
82 |
+
$display_pricing = ! WCCF_WC_Product::skip_pricing( $product );
|
83 |
+
}
|
84 |
+
|
85 |
+
foreach ( $fields as $field ) {
|
86 |
+
|
87 |
+
// Check how many times to iterate the same field (used for quantity-based product fields)
|
88 |
+
if ( $quantity_index !== null ) {
|
89 |
+
$iterations = ( $quantity_index + 1 );
|
90 |
+
$i = $quantity_index;
|
91 |
+
} else {
|
92 |
+
$iterations = ( $field->is_quantity_based() && $quantity ) ? $quantity : 1;
|
93 |
+
$i = 0;
|
94 |
+
}
|
95 |
+
|
96 |
+
// Start iteration of the same field
|
97 |
+
for ( $i = $i; $i < $iterations; $i ++ ) {
|
98 |
+
|
99 |
+
// Get field id
|
100 |
+
$field_id = $field->get_id() . ( $i ? ( '_' . $i ) : '' );
|
101 |
+
|
102 |
+
// Special handling for files
|
103 |
+
if ( $field->field_type_is( 'file' ) ) {
|
104 |
+
//just skip this field type because we can't save uploaded data.
|
105 |
+
} // Handle other field values
|
106 |
+
else {
|
107 |
+
|
108 |
+
// Check if any data for this field was posted or is available in request query vars for GET requests
|
109 |
+
if ( isset( $item_data['wccf']['display']['product_field'][ $field_id ] ) ) {
|
110 |
+
|
111 |
+
// Get field value
|
112 |
+
if ( isset( $item_data['wccf']['display']['product_field'][ $field_id ] ) ) {
|
113 |
+
$field_value = $item_data['wccf']['display']['product_field'][ $field_id ];
|
114 |
+
}
|
115 |
+
|
116 |
+
// Prepare multiselect field values
|
117 |
+
if ( $field->accepts_multiple_values() ) {
|
118 |
+
|
119 |
+
// Ensure that value is array
|
120 |
+
$value = ! RightPress_Help::is_empty( $field_value ) ? (array) $field_value : array();
|
121 |
+
|
122 |
+
// Filter out hidden placeholder input value
|
123 |
+
$value = array_filter( (array) $value, function ( $test_value ) {
|
124 |
+
return trim( $test_value ) !== '';
|
125 |
+
} );
|
126 |
+
} else {
|
127 |
+
$value = stripslashes( trim( $field_value ) );
|
128 |
+
}
|
129 |
+
|
130 |
+
$item_data[] = array(
|
131 |
+
'key' => $field->get_label(),
|
132 |
+
'display' => $field->format_display_value( array( 'value' => $value ), $display_pricing ),
|
133 |
+
);
|
134 |
+
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
unset( $item_data['wccf'] );
|
141 |
+
unset( $item_data['wccf_ignore'] );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
return $item_data;
|
146 |
+
}
|
147 |
+
|
148 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_fields', 10, 3 );
|
149 |
+
} // End if().
|
integrations/woocommerce-gravityforms-product-addons.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Gravity Forms Product Add-Ons
|
6 |
+
*
|
7 |
+
* @version 3.3.8
|
8 |
+
*
|
9 |
+
* @slug woocommerce-gravityforms-product-addons
|
10 |
+
*
|
11 |
+
* @url https://woocommerce.com/products/gravity-forms-add-ons/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
24 |
+
*/
|
25 |
+
function gf_productaddon_support() {
|
26 |
+
if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
if ( ! function_exists( 'gf_productaddon_text_button' ) ) {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Change text for button add to cart
|
33 |
+
*
|
34 |
+
* @param string $text_add_to_cart Text "Add to cart".
|
35 |
+
* @param array $wl_product Wishlist product.
|
36 |
+
* @param object $product WooCommerce Product.
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
function gf_productaddon_text_button( $text_add_to_cart, $wl_product, $product ) {
|
41 |
+
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
42 |
+
|
43 |
+
return ( $gravity_form_data ) ? __( 'Select options', 'ti-woocommerce-wishlist' ) : $text_add_to_cart;
|
44 |
+
}
|
45 |
+
|
46 |
+
add_filter( 'tinvwl_wishlist_item_add_to_cart', 'gf_productaddon_text_button', 10, 3 );
|
47 |
+
}
|
48 |
+
|
49 |
+
if ( ! function_exists( 'gf_productaddon_run_action_button' ) ) {
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Check for make redirect to url
|
53 |
+
*
|
54 |
+
* @param boolean $need Need redirect or not.
|
55 |
+
* @param object $product WooCommerce Product.
|
56 |
+
*
|
57 |
+
* @return boolean
|
58 |
+
*/
|
59 |
+
function gf_productaddon_run_action_button( $need, $product ) {
|
60 |
+
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
61 |
+
|
62 |
+
return ( $gravity_form_data ) ? true : $need;
|
63 |
+
}
|
64 |
+
|
65 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'gf_productaddon_run_action_button', 10, 2 );
|
66 |
+
}
|
67 |
+
|
68 |
+
if ( ! function_exists( 'gf_productaddon_action_button' ) ) {
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Redirect url
|
72 |
+
*
|
73 |
+
* @param string $url Redirect URL.
|
74 |
+
* @param object $product WooCommerce Product.
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
function gf_productaddon_action_button( $url, $product ) {
|
79 |
+
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
80 |
+
|
81 |
+
return ( $gravity_form_data ) ? $product->get_permalink() : $url;
|
82 |
+
}
|
83 |
+
|
84 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'gf_productaddon_action_button', 10, 2 );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
add_action( 'init', 'gf_productaddon_support' );
|
89 |
+
} // End if().
|
90 |
+
|
91 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Set description for meta WooCommerce - Gravity Forms Product Add-Ons
|
95 |
+
*
|
96 |
+
* @param array $meta Meta array.
|
97 |
+
*
|
98 |
+
* @return array
|
99 |
+
*/
|
100 |
+
function tinv_wishlist_metasupport_wc_gf_addons( $meta ) {
|
101 |
+
if ( array_key_exists( 'wc_gforms_form_id', $meta ) && class_exists( 'RGFormsModel' ) ) {
|
102 |
+
$form_meta = RGFormsModel::get_form_meta( $meta['wc_gforms_form_id']['display'] );
|
103 |
+
if ( array_key_exists( 'fields', $form_meta ) ) {
|
104 |
+
$_meta = array();
|
105 |
+
foreach ( $form_meta['fields'] as $field ) {
|
106 |
+
$field_name = $field->get_first_input_id( array( 'id' => 0 ) );
|
107 |
+
if ( array_key_exists( $field_name, $meta ) ) {
|
108 |
+
$meta[ $field_name ]['key'] = $field->label;
|
109 |
+
$_meta[ $field_name ] = $meta[ $field_name ];
|
110 |
+
}
|
111 |
+
}
|
112 |
+
$meta = $_meta;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
return $meta;
|
117 |
+
}
|
118 |
+
|
119 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_wc_gf_addons' );
|
120 |
+
}
|
integrations/woocommerce-mix-and-match-products.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Mix and Match
|
6 |
+
*
|
7 |
+
* @version 1.6.0
|
8 |
+
*
|
9 |
+
* @slug woocommerce-mix-and-match-products
|
10 |
+
*
|
11 |
+
* @url https://woocommerce.com/products/woocommerce-mix-and-match-products/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Mix and Match
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Product ID.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function tinv_wishlist_metasupport_woocommerce_mix_and_match_products( $meta, $product_id ) {
|
31 |
+
if ( array_key_exists( 'mnm_quantity', $meta ) ) {
|
32 |
+
$product = wc_get_product( $product_id );
|
33 |
+
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) ) {
|
34 |
+
$meta = array();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return $meta;
|
39 |
+
}
|
40 |
+
|
41 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products', 10, 2 );
|
42 |
+
} // End if().
|
43 |
+
|
44 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_mix_and_match_products' ) ) {
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Add rows for sub product for WooCommerce Mix and Match
|
48 |
+
*
|
49 |
+
* @param array $wl_product Wishlist Product.
|
50 |
+
* @param \WC_Product $product Woocommerce Product.
|
51 |
+
*/
|
52 |
+
function tinvwl_row_woocommerce_mix_and_match_products( $wl_product, $product ) {
|
53 |
+
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && array_key_exists( 'mnm_quantity', $wl_product['meta'] ) ) {
|
54 |
+
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
55 |
+
$mnm_items = $product->get_children();
|
56 |
+
if ( ! empty( $mnm_items ) ) {
|
57 |
+
foreach ( $mnm_items as $id => $mnm_item ) {
|
58 |
+
$item_quantity = 0;
|
59 |
+
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
60 |
+
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
61 |
+
}
|
62 |
+
if ( 0 >= $item_quantity ) {
|
63 |
+
continue;
|
64 |
+
}
|
65 |
+
|
66 |
+
$product_url = $mnm_item->get_permalink();
|
67 |
+
$product_image = $mnm_item->get_image();
|
68 |
+
$product_title = $mnm_item->get_title();
|
69 |
+
$product_price = $mnm_item->get_price_html();
|
70 |
+
if ( $mnm_item->is_visible() ) {
|
71 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
72 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
73 |
+
}
|
74 |
+
$product_title .= tinv_wishlist_get_item_data( $mnm_item, $wl_product );
|
75 |
+
|
76 |
+
$availability = (array) $mnm_item->get_availability();
|
77 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
78 |
+
$availability['availability'] = '';
|
79 |
+
}
|
80 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
81 |
+
$availability['class'] = '';
|
82 |
+
}
|
83 |
+
$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>';
|
84 |
+
$row_string = '<tr>';
|
85 |
+
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
86 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
87 |
+
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
88 |
+
}
|
89 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
90 |
+
$row_string .= '<td class="product-date"> </td>';
|
91 |
+
}
|
92 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
93 |
+
$row_string .= '<td class="product-stock">%4$s</td>';
|
94 |
+
}
|
95 |
+
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
96 |
+
$row_string .= '<td class="product-action"> </td>';
|
97 |
+
}
|
98 |
+
$row_string .= '</tr>';
|
99 |
+
|
100 |
+
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
|
101 |
+
} // End foreach().
|
102 |
+
} // End if().
|
103 |
+
} // End if().
|
104 |
+
}
|
105 |
+
|
106 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_mix_and_match_products', 10, 2 );
|
107 |
+
} // End if().
|
108 |
+
|
109 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' ) ) {
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Modify price for WooCommerce Mix and Match
|
113 |
+
*
|
114 |
+
* @param string $price Returned price.
|
115 |
+
* @param array $wl_product Wishlist Product.
|
116 |
+
* @param \WC_Product $product Woocommerce Product.
|
117 |
+
*
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
function tinvwl_item_price_woocommerce_mix_and_match_products( $price, $wl_product, $product ) {
|
121 |
+
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && $product->is_priced_per_product() ) {
|
122 |
+
$mnm_items = $product->get_children();
|
123 |
+
if ( ! empty( $mnm_items ) ) {
|
124 |
+
$_price = 0;
|
125 |
+
foreach ( $mnm_items as $id => $mnm_item ) {
|
126 |
+
$item_quantity = 0;
|
127 |
+
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
128 |
+
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
129 |
+
}
|
130 |
+
if ( 0 >= $item_quantity ) {
|
131 |
+
continue;
|
132 |
+
}
|
133 |
+
$_price += wc_get_price_to_display( $mnm_item, array( 'qty' => $item_quantity ) );
|
134 |
+
}
|
135 |
+
if ( 0 < $_price ) {
|
136 |
+
if ( $product->is_on_sale() ) {
|
137 |
+
$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();
|
138 |
+
} else {
|
139 |
+
$price = wc_price( $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
|
140 |
+
}
|
141 |
+
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
return $price;
|
147 |
+
}
|
148 |
+
|
149 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_mix_and_match_products', 10, 3 );
|
150 |
+
} // End if().
|
151 |
+
|
152 |
+
if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) ) {
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Remove empty meta for WooCommerce Mix and Match
|
156 |
+
*
|
157 |
+
* @param array $form Post form data.
|
158 |
+
*
|
159 |
+
* @return array
|
160 |
+
*/
|
161 |
+
function tinvwl_add_form_woocommerce_mix_and_match_products( $form = array() ) {
|
162 |
+
if ( array_key_exists( 'mnm_quantity', $form ) ) {
|
163 |
+
if ( is_array( $form['mnm_quantity'] ) && ! empty( $form['mnm_quantity'] ) ) {
|
164 |
+
foreach ( $form['mnm_quantity'] as $key => $value ) {
|
165 |
+
$value = absint( $value );
|
166 |
+
if ( empty( $value ) ) {
|
167 |
+
unset( $form['mnm_quantity'][ $key ] );
|
168 |
+
}
|
169 |
+
}
|
170 |
+
if ( empty( $form['mnm_quantity'] ) ) {
|
171 |
+
unset( $form['mnm_quantity'] );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return $form;
|
177 |
+
}
|
178 |
+
|
179 |
+
add_filter( 'tinvwl_addtowishlist_add_form', 'tinvwl_add_form_woocommerce_mix_and_match_products' );
|
180 |
+
} // End if().
|
integrations/woocommerce-multilingual.php
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Multilingual
|
6 |
+
*
|
7 |
+
* @version 4.6.5
|
8 |
+
*
|
9 |
+
* @slug woocommerce-multilingual
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/woocommerce-multilingual/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Change product data if product need translate in WooCommerce Multilingual
|
24 |
+
*
|
25 |
+
* @param array $post_data Data for wishlist.
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function tinvwl_wpml_addtowishlist_prepare( $post_data ) {
|
30 |
+
if ( class_exists( 'woocommerce_wpml' ) ) {
|
31 |
+
|
32 |
+
global $woocommerce_wpml, $sitepress, $wpdb;
|
33 |
+
|
34 |
+
// Reload products class.
|
35 |
+
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
36 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
37 |
+
} else {
|
38 |
+
global $wpml_post_translations;
|
39 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) ) {
|
43 |
+
$post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id( $post_data['product_id'] );
|
44 |
+
}
|
45 |
+
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'] ) ) {
|
46 |
+
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $post_data['product_id'] );
|
47 |
+
$post_data['product_variation'] = apply_filters( 'translate_object_id', $post_data['product_variation'], 'product_variation', true, $original_product_language );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
return $post_data;
|
52 |
+
}
|
53 |
+
|
54 |
+
add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_wpml_addtowishlist_prepare' );
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare' ) ) {
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Change product data if product need translate in WooCommerce Multilingual
|
61 |
+
*
|
62 |
+
* @param array $attr Data for wishlist.
|
63 |
+
*
|
64 |
+
* @return array
|
65 |
+
*/
|
66 |
+
function tinvwl_wpml_addtowishlist_out_prepare( $attr ) {
|
67 |
+
if ( class_exists( 'woocommerce_wpml' ) ) {
|
68 |
+
|
69 |
+
global $woocommerce_wpml, $sitepress, $wpdb;
|
70 |
+
|
71 |
+
// Reload products class.
|
72 |
+
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
73 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
74 |
+
} else {
|
75 |
+
global $wpml_post_translations;
|
76 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
77 |
+
}
|
78 |
+
|
79 |
+
if ( array_key_exists( 'product_id', $attr ) && ! empty( $attr['product_id'] ) ) {
|
80 |
+
$attr['product_id'] = $woocommerce_wpml->products->get_original_product_id( $attr['product_id'] );
|
81 |
+
}
|
82 |
+
if ( array_key_exists( 'product_id', $attr ) && ! empty( $attr['product_id'] ) && array_key_exists( 'variation_id', $attr ) && ! empty( $attr['variation_id'] ) ) {
|
83 |
+
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $attr['product_id'] );
|
84 |
+
$attr['variation_id'] = apply_filters( 'translate_object_id', $attr['variation_id'], 'product_variation', true, $original_product_language );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
return $attr;
|
89 |
+
}
|
90 |
+
|
91 |
+
add_filter( 'tinvwl_addtowishlist_out_prepare_attr', 'tinvwl_wpml_addtowishlist_out_prepare' );
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare_product' ) ) {
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Change product if product need translate in WooCommerce Multilingual
|
98 |
+
*
|
99 |
+
* @param \WC_Product $product WooCommerce Product.
|
100 |
+
*
|
101 |
+
* @return \WC_Product
|
102 |
+
*/
|
103 |
+
function tinvwl_wpml_addtowishlist_out_prepare_product( $product ) {
|
104 |
+
if ( class_exists( 'woocommerce_wpml' ) && is_object( $product ) ) {
|
105 |
+
|
106 |
+
global $woocommerce_wpml, $sitepress, $wpdb;
|
107 |
+
|
108 |
+
// Reload products class.
|
109 |
+
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
110 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
111 |
+
} else {
|
112 |
+
global $wpml_post_translations;
|
113 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
114 |
+
}
|
115 |
+
|
116 |
+
$product_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->get_id() : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() );
|
117 |
+
$variation_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 );
|
118 |
+
|
119 |
+
if ( ! empty( $product_id ) ) {
|
120 |
+
$product_id = $woocommerce_wpml->products->get_original_product_id( $product_id );
|
121 |
+
}
|
122 |
+
if ( ! empty( $product_id ) && ! empty( $variation_id ) ) {
|
123 |
+
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $product_id );
|
124 |
+
$variation_id = apply_filters( 'translate_object_id', $variation_id, 'product_variation', true, $original_product_language );
|
125 |
+
}
|
126 |
+
if ( ! empty( $product_id ) ) {
|
127 |
+
$product = wc_get_product( $variation_id ? $variation_id : $product_id );
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
return $product;
|
132 |
+
}
|
133 |
+
|
134 |
+
add_filter( 'tinvwl_addtowishlist_out_prepare_product', 'tinvwl_wpml_addtowishlist_out_prepare_product' );
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare_form' ) ) {
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Change product form data if product need translate in WooCommerce Multilingual
|
141 |
+
*
|
142 |
+
* @param array $post_data Data for wishlist.
|
143 |
+
*
|
144 |
+
* @return array
|
145 |
+
*/
|
146 |
+
function tinvwl_wpml_addtowishlist_prepare_form( $post_data ) {
|
147 |
+
if ( class_exists( 'woocommerce_wpml' ) && is_array( $post_data ) ) {
|
148 |
+
|
149 |
+
global $woocommerce_wpml, $sitepress, $wpdb;
|
150 |
+
|
151 |
+
// Reload products class.
|
152 |
+
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
153 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
154 |
+
} else {
|
155 |
+
global $wpml_post_translations;
|
156 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) ) {
|
160 |
+
$post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id( $post_data['product_id'] );
|
161 |
+
}
|
162 |
+
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'] ) ) {
|
163 |
+
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $post_data['product_id'] );
|
164 |
+
$post_data['variation_id'] = apply_filters( 'translate_object_id', $post_data['variation_id'], 'product_variation', true, $original_product_language );
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
return $post_data;
|
169 |
+
}
|
170 |
+
|
171 |
+
add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_wpml_addtowishlist_prepare_form' );
|
172 |
+
}
|
integrations/woocommerce-product-addon.php
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name PPOM for WooCommerce
|
6 |
+
*
|
7 |
+
* @version 18.4
|
8 |
+
*
|
9 |
+
* @slug woocommerce-product-addon
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/woocommerce-product-addon/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_add_on' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Product Add-on
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Product ID.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function tinv_wishlist_metasupport_woocommerce_product_add_on( $meta, $product_id ) {
|
31 |
+
if ( isset( $meta['ppom'] ) ) {
|
32 |
+
$meta = array();
|
33 |
+
}
|
34 |
+
|
35 |
+
return $meta;
|
36 |
+
}
|
37 |
+
|
38 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_add_on', 10, 2 );
|
39 |
+
} // End if().
|
40 |
+
|
41 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_add_on' ) ) {
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Set description for meta WooCommerce Product Add-on
|
45 |
+
*
|
46 |
+
* @param array $meta Meta array.
|
47 |
+
* @param array $wl_product Wishlist Product.
|
48 |
+
* @param \WC_Product $product Woocommerce Product.
|
49 |
+
*
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
function tinv_wishlist_item_meta_woocommerce_product_add_on( $meta, $wl_product, $product ) {
|
53 |
+
if ( isset( $wl_product['meta'] ) && isset( $wl_product['meta']['ppom'] ) && class_exists( 'NM_PersonalizedProduct' ) ) {
|
54 |
+
$product_meta = ( isset( $wl_product['meta']['ppom'] ) ) ? $wl_product['meta']['ppom']['fields'] : '';
|
55 |
+
|
56 |
+
$item_meta = array();
|
57 |
+
|
58 |
+
if ( $product_meta ) {
|
59 |
+
|
60 |
+
foreach ( $product_meta as $key => $value ) {
|
61 |
+
|
62 |
+
if ( empty( $value ) ) {
|
63 |
+
continue;
|
64 |
+
}
|
65 |
+
|
66 |
+
$product_id = $wl_product['product_id'];
|
67 |
+
$field_meta = ppom_get_field_meta_by_dataname( $product_id, $key );
|
68 |
+
|
69 |
+
if ( empty( $field_meta ) ) {
|
70 |
+
continue;
|
71 |
+
}
|
72 |
+
|
73 |
+
$field_type = $field_meta['type'];
|
74 |
+
$field_title = $field_meta['title'];
|
75 |
+
|
76 |
+
|
77 |
+
switch ( $field_type ) {
|
78 |
+
case 'quantities':
|
79 |
+
$total_qty = 0;
|
80 |
+
foreach ( $value as $label => $qty ) {
|
81 |
+
if ( ! empty( $qty ) ) {
|
82 |
+
$item_meta[] = array(
|
83 |
+
'key' => $label,
|
84 |
+
'display' => $qty,
|
85 |
+
);
|
86 |
+
$total_qty += $qty;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
break;
|
90 |
+
|
91 |
+
case 'file':
|
92 |
+
$file_thumbs_html = '';
|
93 |
+
foreach ( $value as $file_id => $file_uploaded ) {
|
94 |
+
$file_name = $file_uploaded['org'];
|
95 |
+
$file_thumbs_html .= ppom_show_file_thumb( $file_name );
|
96 |
+
}
|
97 |
+
$item_meta[] = array(
|
98 |
+
'key' => $field_title,
|
99 |
+
'display' => $file_thumbs_html,
|
100 |
+
);
|
101 |
+
|
102 |
+
break;
|
103 |
+
|
104 |
+
case 'cropper':
|
105 |
+
$file_thumbs_html = '';
|
106 |
+
foreach ( $value as $file_id => $file_cropped ) {
|
107 |
+
|
108 |
+
$file_name = $file_cropped['org'];
|
109 |
+
$file_thumbs_html .= ppom_show_file_thumb( $file_name, true );
|
110 |
+
}
|
111 |
+
$item_meta[] = array(
|
112 |
+
'key' => $field_title,
|
113 |
+
'display' => $file_thumbs_html,
|
114 |
+
);
|
115 |
+
break;
|
116 |
+
|
117 |
+
case 'image':
|
118 |
+
if ( $value ) {
|
119 |
+
foreach ( $value as $id => $images_meta ) {
|
120 |
+
$images_meta = json_decode( stripslashes( $images_meta ), true );
|
121 |
+
$image_url = stripslashes( $images_meta['link'] );
|
122 |
+
$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'] ) . '">';
|
123 |
+
$meta_key = $field_title . '(' . $images_meta['title'] . ')';
|
124 |
+
$item_meta[] = array(
|
125 |
+
'key' => $meta_key,
|
126 |
+
'display' => $image_html,
|
127 |
+
);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
break;
|
131 |
+
|
132 |
+
case 'audio':
|
133 |
+
if ( $value ) {
|
134 |
+
$ppom_file_count = 1;
|
135 |
+
foreach ( $value as $id => $audio_meta ) {
|
136 |
+
$audio_meta = json_decode( stripslashes( $audio_meta ), true );
|
137 |
+
$audio_url = stripslashes( $audio_meta['link'] );
|
138 |
+
$audio_html = '<a href="' . esc_url( $audio_url ) . '" title="' . esc_attr( $audio_meta['title'] ) . '">' . $audio_meta['title'] . '</a>';
|
139 |
+
$meta_key = $field_title . ': ' . $ppom_file_count ++;
|
140 |
+
$item_meta[] = array(
|
141 |
+
'key' => $meta_key,
|
142 |
+
'display' => $audio_html,
|
143 |
+
);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
break;
|
147 |
+
|
148 |
+
case 'bulkquantity':
|
149 |
+
$item_meta[] = array(
|
150 |
+
'key' => $key,
|
151 |
+
'display' => $value['option'] . ' (' . $value['qty'] . ')',
|
152 |
+
);
|
153 |
+
break;
|
154 |
+
|
155 |
+
default:
|
156 |
+
$value = is_array( $value ) ? implode( ",", $value ) : $value;
|
157 |
+
$item_meta[] = array(
|
158 |
+
'key' => $field_title,
|
159 |
+
'display' => stripcslashes( $value ),
|
160 |
+
);
|
161 |
+
break;
|
162 |
+
}
|
163 |
+
|
164 |
+
} // End foreach().
|
165 |
+
} // End if().
|
166 |
+
|
167 |
+
if ( 0 < count( $item_meta ) ) {
|
168 |
+
ob_start();
|
169 |
+
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_meta ) );
|
170 |
+
$meta .= ob_get_clean();
|
171 |
+
}
|
172 |
+
} // End if().
|
173 |
+
|
174 |
+
return $meta;
|
175 |
+
}
|
176 |
+
|
177 |
+
add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlist_item_meta_woocommerce_product_add_on', 10, 3 );
|
178 |
+
} // End if().
|
integrations/woocommerce-product-addons.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Product Add-ons
|
6 |
+
*
|
7 |
+
* @version 3.0.14
|
8 |
+
*
|
9 |
+
* @slug woocommerce-product-addons
|
10 |
+
*
|
11 |
+
* @url https://woocommerce.com/products/product-add-ons/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Product Addons
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param array $wl_product Wishlist Product.
|
27 |
+
* @param \WC_Product $product Woocommerce Product.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
function tinv_wishlist_item_meta_woocommerce_product_addons( $item_data, $product_id, $variation_id ) {
|
32 |
+
|
33 |
+
if ( class_exists( 'WC_Product_Addons' ) ) {
|
34 |
+
|
35 |
+
$id = ( $variation_id ) ? $variation_id : $product_id;
|
36 |
+
|
37 |
+
if ( function_exists( 'get_product_addons' ) ) {
|
38 |
+
$product_addons = get_product_addons( $id );
|
39 |
+
} else {
|
40 |
+
$product_addons = WC_Product_Addons_Helper::get_product_addons( $id );
|
41 |
+
}
|
42 |
+
|
43 |
+
if ( $product_addons ) {
|
44 |
+
|
45 |
+
foreach ( $product_addons as $addon ) {
|
46 |
+
foreach ( $addon['options'] as $option ) {
|
47 |
+
$original_data = 'addon-' . $addon['field_name'];
|
48 |
+
|
49 |
+
if ( 'file_upload' === $addon['type'] ) {
|
50 |
+
$original_data = 'addon-' . $addon['field_name'] . '-' . sanitize_title( $option['label'] );
|
51 |
+
}
|
52 |
+
|
53 |
+
$value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ]['display'] : '';
|
54 |
+
|
55 |
+
if ( $value == '' ) {
|
56 |
+
continue;
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( is_array( $value ) ) {
|
60 |
+
$value = array_map( 'stripslashes', $value );
|
61 |
+
} else {
|
62 |
+
$value = stripslashes( $value );
|
63 |
+
}
|
64 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
|
65 |
+
switch ( $addon['type'] ) {
|
66 |
+
case 'checkbox':
|
67 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
68 |
+
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
69 |
+
break;
|
70 |
+
case 'multiple_choice':
|
71 |
+
switch ( $addon['display'] ) {
|
72 |
+
case 'radiobutton':
|
73 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
74 |
+
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
75 |
+
break;
|
76 |
+
case 'images':
|
77 |
+
case 'select':
|
78 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php' );
|
79 |
+
$field = new WC_Product_Addons_Field_Select( $addon, $value );
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
break;
|
83 |
+
case 'custom_text':
|
84 |
+
case 'custom_textarea':
|
85 |
+
case 'custom_price':
|
86 |
+
case 'input_multiplier':
|
87 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php' );
|
88 |
+
$field = new WC_Product_Addons_Field_Custom( $addon, $value );
|
89 |
+
break;
|
90 |
+
case 'file_upload':
|
91 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
|
92 |
+
$field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
|
93 |
+
break;
|
94 |
+
default:
|
95 |
+
// Continue to the next field in case the type is not recognized (instead of causing a fatal error)
|
96 |
+
break;
|
97 |
+
}
|
98 |
+
|
99 |
+
$data = $field->get_cart_item_data();
|
100 |
+
|
101 |
+
unset( $item_data[ $original_data ] );
|
102 |
+
foreach ( $data as $option ) {
|
103 |
+
$name = $option['name'];
|
104 |
+
|
105 |
+
if ( $option['price'] && apply_filters( 'woocommerce_addons_add_price_to_name', '__return_true' ) ) {
|
106 |
+
$name .= ' (' . wc_price( get_product_addon_price_for_display( $option['price'] ) ) . ')';
|
107 |
+
}
|
108 |
+
|
109 |
+
$item_data[] = array(
|
110 |
+
'key' => $name,
|
111 |
+
'display' => $option['value'],
|
112 |
+
);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
return $item_data;
|
120 |
+
}
|
121 |
+
|
122 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_product_addons', 10, 3 );
|
123 |
+
} // End if().
|
124 |
+
|
125 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Modify price for WooCommerce Product Addons.
|
129 |
+
*
|
130 |
+
* @param string $price Returned price.
|
131 |
+
* @param array $wl_product Wishlist Product.
|
132 |
+
* @param \WC_Product $product Woocommerce Product.
|
133 |
+
*
|
134 |
+
* @return string
|
135 |
+
*/
|
136 |
+
function tinvwl_item_price_woocommerce_product_addons( $price, $wl_product, $product ) {
|
137 |
+
|
138 |
+
if ( class_exists( 'WC_Product_Addons' ) ) {
|
139 |
+
|
140 |
+
if ( function_exists( 'get_product_addons' ) ) {
|
141 |
+
$product_addons = get_product_addons( $product->get_id() );
|
142 |
+
} else {
|
143 |
+
$product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( $product_addons ) {
|
147 |
+
|
148 |
+
$price = 0;
|
149 |
+
|
150 |
+
foreach ( $product_addons as $addon ) {
|
151 |
+
|
152 |
+
$original_data = 'addon-' . $addon['field_name'];
|
153 |
+
|
154 |
+
$value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
|
155 |
+
if ( $value == '' ) {
|
156 |
+
continue;
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( is_array( $value ) ) {
|
160 |
+
$value = array_map( 'stripslashes', $value );
|
161 |
+
} else {
|
162 |
+
$value = stripslashes( $value );
|
163 |
+
}
|
164 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
|
165 |
+
switch ( $addon['type'] ) {
|
166 |
+
case 'checkbox':
|
167 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
168 |
+
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
169 |
+
break;
|
170 |
+
case 'multiple_choice':
|
171 |
+
switch ( $addon['display'] ) {
|
172 |
+
case 'radiobutton':
|
173 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
174 |
+
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
175 |
+
break;
|
176 |
+
case 'images':
|
177 |
+
case 'select':
|
178 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php' );
|
179 |
+
$field = new WC_Product_Addons_Field_Select( $addon, $value );
|
180 |
+
break;
|
181 |
+
}
|
182 |
+
break;
|
183 |
+
case 'custom_text':
|
184 |
+
case 'custom_textarea':
|
185 |
+
case 'custom_price':
|
186 |
+
case 'input_multiplier':
|
187 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php' );
|
188 |
+
$field = new WC_Product_Addons_Field_Custom( $addon, $value );
|
189 |
+
break;
|
190 |
+
case 'file_upload':
|
191 |
+
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
|
192 |
+
$field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
|
193 |
+
break;
|
194 |
+
default:
|
195 |
+
// Continue to the next field in case the type is not recognized (instead of causing a fatal error)
|
196 |
+
break;
|
197 |
+
}
|
198 |
+
|
199 |
+
$data = $field->get_cart_item_data();
|
200 |
+
foreach ( $data as $option ) {
|
201 |
+
if ( $option['price'] ) {
|
202 |
+
$price += (float) $option['price'];
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
$price = wc_price( $product->get_price() + $price );
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
return $price;
|
213 |
+
}
|
214 |
+
|
215 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_addons', 10, 3 );
|
216 |
+
} // End if().
|
integrations/woocommerce-product-bundles.php
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Product Bundles
|
6 |
+
*
|
7 |
+
* @version 5.12.0
|
8 |
+
*
|
9 |
+
* @slug woocommerce-product-bundles
|
10 |
+
*
|
11 |
+
* @url https://woocommerce.com/products/product-bundles/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_bundles' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Product Bundles
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Product ID.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function tinv_wishlist_metasupport_woocommerce_product_bundles( $meta, $product_id ) {
|
31 |
+
$product = wc_get_product( $product_id );
|
32 |
+
|
33 |
+
if ( is_object( $product ) && $product->is_type( 'bundle' ) && empty( $meta['bkap_price_charged'] ) ) {
|
34 |
+
$meta = array();
|
35 |
+
}
|
36 |
+
|
37 |
+
return $meta;
|
38 |
+
}
|
39 |
+
|
40 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_bundles', 10, 2 );
|
41 |
+
} // End if().
|
42 |
+
|
43 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Add rows for sub product for WooCommerce Product Bundles
|
47 |
+
*
|
48 |
+
* @param array $wl_product Wishlist Product.
|
49 |
+
* @param \WC_Product $product Woocommerce Product.
|
50 |
+
*/
|
51 |
+
function tinvwl_row_woocommerce_product_bundles( $wl_product, $product ) {
|
52 |
+
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
53 |
+
|
54 |
+
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
55 |
+
$bundled_items = $product->get_bundled_items();
|
56 |
+
if ( ! empty( $bundled_items ) ) {
|
57 |
+
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
58 |
+
|
59 |
+
$bundled_item_variation_id_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_variation_id_' . $bundled_item_id;
|
60 |
+
$bundled_variation_id = absint( isset( $wl_product['meta'][ $bundled_item_variation_id_request_key ] ) ? $wl_product['meta'][ $bundled_item_variation_id_request_key ] : 0 );
|
61 |
+
if ( ! empty( $bundled_variation_id ) ) {
|
62 |
+
$bundled_item->product = wc_get_product( $bundled_variation_id );
|
63 |
+
}
|
64 |
+
|
65 |
+
$is_optional = $bundled_item->is_optional();
|
66 |
+
|
67 |
+
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
68 |
+
$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();
|
69 |
+
|
70 |
+
if ( $is_optional ) {
|
71 |
+
|
72 |
+
/** Documented in method 'get_posted_bundle_configuration'. */
|
73 |
+
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
74 |
+
|
75 |
+
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
76 |
+
$bundled_product_qty = 0;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
if ( 0 === $bundled_product_qty || 'visible' != $bundled_item->cart_visibility ) {
|
80 |
+
continue;
|
81 |
+
}
|
82 |
+
|
83 |
+
$product_url = $bundled_item->product->get_permalink();
|
84 |
+
$product_image = $bundled_item->product->get_image();
|
85 |
+
$product_title = $bundled_item->has_title_override() ? $bundled_item->get_title() : $bundled_item->get_raw_title();
|
86 |
+
|
87 |
+
$product_price = $bundled_item->product->get_price_html();
|
88 |
+
$product_price_raw = $bundled_item->product->get_regular_price();
|
89 |
+
$discount = $bundled_item->get_discount();
|
90 |
+
$product_price = empty( $discount ) ? $product_price : wc_price( WC_PB_Product_Prices::get_discounted_price( $product_price_raw, $discount ) );
|
91 |
+
|
92 |
+
if ( $bundled_item->product->is_visible() ) {
|
93 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
94 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
95 |
+
}
|
96 |
+
$product_title .= tinv_wishlist_get_item_data( $bundled_item->product, $wl_product );
|
97 |
+
|
98 |
+
$availability = (array) $bundled_item->product->get_availability();
|
99 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
100 |
+
$availability['availability'] = '';
|
101 |
+
}
|
102 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
103 |
+
$availability['class'] = '';
|
104 |
+
}
|
105 |
+
$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>';
|
106 |
+
$row_string = '<tr>';
|
107 |
+
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
108 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) && $bundled_item->is_priced_individually() ) {
|
109 |
+
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
110 |
+
} elseif ( ! $bundled_item->is_priced_individually() ) {
|
111 |
+
$row_string .= '<td class="product-price"></td>';
|
112 |
+
}
|
113 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
114 |
+
$row_string .= '<td class="product-date"> </td>';
|
115 |
+
}
|
116 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
117 |
+
$row_string .= '<td class="product-stock">%4$s</td>';
|
118 |
+
}
|
119 |
+
|
120 |
+
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
121 |
+
$row_string .= '<td class="product-action"> </td>';
|
122 |
+
}
|
123 |
+
$row_string .= '</tr>';
|
124 |
+
|
125 |
+
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty ); // WPCS: xss ok.
|
126 |
+
} // End foreach().
|
127 |
+
} // End if().
|
128 |
+
} // End if().
|
129 |
+
}
|
130 |
+
|
131 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_product_bundles', 10, 2 );
|
132 |
+
} // End if().
|
133 |
+
|
134 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Modify price for WooCommerce Product Bundles
|
138 |
+
*
|
139 |
+
* @param string $price Returned price.
|
140 |
+
* @param array $wl_product Wishlist Product.
|
141 |
+
* @param \WC_Product $product Woocommerce Product.
|
142 |
+
*
|
143 |
+
* @return string
|
144 |
+
*/
|
145 |
+
function tinvwl_item_price_woocommerce_product_bundles( $price, $wl_product, $product ) {
|
146 |
+
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
147 |
+
|
148 |
+
$bundle_price = $product->get_price();
|
149 |
+
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
150 |
+
$bundled_items = $product->get_bundled_items();
|
151 |
+
|
152 |
+
if ( ! empty( $bundled_items ) ) {
|
153 |
+
|
154 |
+
$bundled_items_price = 0.0;
|
155 |
+
|
156 |
+
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
157 |
+
|
158 |
+
$bundled_item_variation_id_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_variation_id_' . $bundled_item_id;
|
159 |
+
$bundled_variation_id = absint( isset( $wl_product['meta'][ $bundled_item_variation_id_request_key ] ) ? $wl_product['meta'][ $bundled_item_variation_id_request_key ] : 0 );
|
160 |
+
if ( ! empty( $bundled_variation_id ) ) {
|
161 |
+
$_bundled_product = wc_get_product( $bundled_variation_id );
|
162 |
+
} else {
|
163 |
+
$_bundled_product = $bundled_item->product;
|
164 |
+
}
|
165 |
+
|
166 |
+
$is_optional = $bundled_item->is_optional();
|
167 |
+
|
168 |
+
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
169 |
+
$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();
|
170 |
+
|
171 |
+
if ( $is_optional ) {
|
172 |
+
|
173 |
+
/** Documented in method 'get_posted_bundle_configuration'. */
|
174 |
+
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
175 |
+
|
176 |
+
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
177 |
+
$bundled_product_qty = 0;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
if ( $bundled_item->is_priced_individually() ) {
|
182 |
+
$product_price = $_bundled_product->get_regular_price();
|
183 |
+
|
184 |
+
$discount = $bundled_item->get_discount();
|
185 |
+
$product_price = empty( $discount ) ? $product_price : WC_PB_Product_Prices::get_discounted_price( $product_price, $discount );
|
186 |
+
|
187 |
+
$bundled_item_price = $product_price * $bundled_product_qty;
|
188 |
+
|
189 |
+
$bundled_items_price += (double) $bundled_item_price;
|
190 |
+
}
|
191 |
+
|
192 |
+
} // End foreach().
|
193 |
+
$price = wc_price( (double) $bundle_price + $bundled_items_price );
|
194 |
+
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
195 |
+
} // End if().
|
196 |
+
} // End if().
|
197 |
+
|
198 |
+
return $price;
|
199 |
+
}
|
200 |
+
|
201 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_bundles', 10, 3 );
|
202 |
+
} // End if().
|
integrations/woocommerce-rental-and-booking.php
ADDED
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Rental & Bookings System
|
6 |
+
*
|
7 |
+
* @version 7.0.3
|
8 |
+
*
|
9 |
+
* @slug woocommerce-rental-and-booking
|
10 |
+
*
|
11 |
+
* @url https://codecanyon.net/item/rnb-woocommerce-rental-booking-system/14835145
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_woocommerce_rental_and_booking_product_type' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Force product type selection.
|
24 |
+
*
|
25 |
+
* @param array $product_types Array of product types.
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function tinvwl_woocommerce_rental_and_booking_product_type( $product_types ) {
|
30 |
+
|
31 |
+
if ( class_exists( 'RedQ_Rental_And_Bookings' ) ) {
|
32 |
+
$product_types['redq_rental'] = __( 'Rental Product', 'redq-rental' );
|
33 |
+
}
|
34 |
+
|
35 |
+
return $product_types;
|
36 |
+
}
|
37 |
+
|
38 |
+
add_filter( 'product_type_selector', 'tinvwl_woocommerce_rental_and_booking_product_type' );
|
39 |
+
}
|
40 |
+
|
41 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_rental_and_booking' ) ) {
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Set description for meta WooCommerce Rental & Bookings System
|
45 |
+
*
|
46 |
+
* @param array $meta Meta array.
|
47 |
+
* @param integer $product_id Priduct ID.
|
48 |
+
* @param integer $variation_id Variation Product ID.
|
49 |
+
*
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
function tinv_wishlist_metasupport_woocommerce_rental_and_booking( $meta, $product_id, $variation_id ) {
|
53 |
+
if ( ! class_exists( 'RedQ_Rental_And_Bookings' ) ) {
|
54 |
+
return $meta;
|
55 |
+
}
|
56 |
+
|
57 |
+
$product_type = wc_get_product( $product_id )->get_type();
|
58 |
+
|
59 |
+
if ( isset( $product_type ) && $product_type === 'redq_rental' ) {
|
60 |
+
|
61 |
+
$custom_data = array();
|
62 |
+
|
63 |
+
$options_data = array();
|
64 |
+
$options_data['quote_id'] = '';
|
65 |
+
|
66 |
+
$get_labels = reddq_rental_get_settings( $product_id, 'labels', array(
|
67 |
+
'pickup_location',
|
68 |
+
'return_location',
|
69 |
+
'pickup_date',
|
70 |
+
'return_date',
|
71 |
+
'resources',
|
72 |
+
'categories',
|
73 |
+
'person',
|
74 |
+
'deposites'
|
75 |
+
) );
|
76 |
+
$labels = $get_labels['labels'];
|
77 |
+
$get_displays = reddq_rental_get_settings( $product_id, 'display' );
|
78 |
+
$displays = $get_displays['display'];
|
79 |
+
|
80 |
+
$get_conditions = reddq_rental_get_settings( $product_id, 'conditions' );
|
81 |
+
$conditional_data = $get_conditions['conditions'];
|
82 |
+
|
83 |
+
$get_general = reddq_rental_get_settings( $product_id, 'general' );
|
84 |
+
$general_data = $get_general['general'];
|
85 |
+
|
86 |
+
if ( isset( $meta['quote_id'] ) ) {
|
87 |
+
$custom_data[] = array(
|
88 |
+
'key' => $options_data['quote_id'] ? $options_data['quote_id'] : __( 'Quote Request', 'redq-rental' ),
|
89 |
+
'display' => '#' . $meta['quote_id']['display'],
|
90 |
+
|
91 |
+
);
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( isset( $meta['pickup_location'] ) ) {
|
95 |
+
$custom_data[] = array(
|
96 |
+
'key' => $labels['pickup_location'],
|
97 |
+
'display' => $meta['pickup_location']['display']['address'],
|
98 |
+
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( isset( $meta['pickup_location'] ) && ! empty( $meta['pickup_location']['cost'] ) ) {
|
103 |
+
$custom_data[] = array(
|
104 |
+
'key' => $labels['pickup_location'] . __( ' Cost', 'redq-rental' ),
|
105 |
+
'display' => wc_price( $meta['pickup_location']['display']['cost'] ),
|
106 |
+
|
107 |
+
);
|
108 |
+
}
|
109 |
+
|
110 |
+
if ( isset( $meta['dropoff_location'] ) ) {
|
111 |
+
$custom_data[] = array(
|
112 |
+
'key' => $labels['return_location'],
|
113 |
+
'display' => $meta['dropoff_location']['display']['address'],
|
114 |
+
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( isset( $meta['dropoff_location'] ) && ! empty( $meta['dropoff_location']['cost'] ) ) {
|
119 |
+
$custom_data[] = array(
|
120 |
+
'key' => $labels['return_location'] . __( ' Cost', 'redq-rental' ),
|
121 |
+
'display' => wc_price( $meta['dropoff_location']['display']['cost'] ),
|
122 |
+
|
123 |
+
);
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( isset( $meta['location_cost'] ) ) {
|
127 |
+
$custom_data[] = array(
|
128 |
+
'key' => esc_html__( 'Location Cost', 'redq-rental' ),
|
129 |
+
'display' => wc_price( $meta['location_cost']['display'] ),
|
130 |
+
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
if ( isset( $meta['payable_cat'] ) ) {
|
135 |
+
$cat_name = '';
|
136 |
+
foreach ( $meta['payable_cat']['display'] as $key => $value ) {
|
137 |
+
if ( $value['multiply'] === 'per_day' ) {
|
138 |
+
$cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price( $value['cost'] ) . ' - ' . __( 'Per Day', 'redq-rental' ) . ' )' . ' , <br> ';
|
139 |
+
} else {
|
140 |
+
$cat_name .= $value['key'] . '×' . $value['quantity'] . ' ( ' . wc_price( $value['cost'] ) . ' - ' . __( 'One Time', 'redq-rental' ) . ' )' . ' , <br> ';
|
141 |
+
}
|
142 |
+
}
|
143 |
+
$custom_data[] = array(
|
144 |
+
'key' => $labels['categories'],
|
145 |
+
'display' => $cat_name,
|
146 |
+
|
147 |
+
);
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( isset( $meta['payable_resource'] ) ) {
|
151 |
+
$resource_name = '';
|
152 |
+
foreach ( $meta['payable_resource']['display'] as $key => $value ) {
|
153 |
+
if ( $value['cost_multiply'] === 'per_day' ) {
|
154 |
+
$resource_name .= $value['resource_name'] . ' ( ' . wc_price( $value['resource_cost'] ) . ' - ' . __( 'Per Day', 'redq-rental' ) . ' )' . ' , <br> ';
|
155 |
+
} else {
|
156 |
+
$resource_name .= $value['resource_name'] . ' ( ' . wc_price( $value['resource_cost'] ) . ' - ' . __( 'One Time', 'redq-rental' ) . ' )' . ' , <br> ';
|
157 |
+
}
|
158 |
+
}
|
159 |
+
$custom_data[] = array(
|
160 |
+
'key' => $labels['resource'],
|
161 |
+
'display' => $resource_name,
|
162 |
+
|
163 |
+
);
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( isset( $meta['payable_security_deposites'] ) ) {
|
167 |
+
$security_deposite_name = '';
|
168 |
+
foreach ( $meta['payable_security_deposites']['display'] as $key => $value ) {
|
169 |
+
if ( $value['cost_multiply'] === 'per_day' ) {
|
170 |
+
$security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price( $value['security_deposite_cost'] ) . ' - ' . __( 'Per Day', 'redq-rental' ) . ' )' . ' , <br> ';
|
171 |
+
} else {
|
172 |
+
$security_deposite_name .= $value['security_deposite_name'] . ' ( ' . wc_price( $value['security_deposite_cost'] ) . ' - ' . __( 'One Time', 'redq-rental' ) . ' )' . ' , <br> ';
|
173 |
+
}
|
174 |
+
}
|
175 |
+
$custom_data[] = array(
|
176 |
+
'key' => $labels['deposite'],
|
177 |
+
'display' => $security_deposite_name,
|
178 |
+
|
179 |
+
);
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( isset( $meta['adults_info'] ) ) {
|
183 |
+
$custom_data[] = array(
|
184 |
+
'key' => $labels['adults'],
|
185 |
+
'display' => $meta['adults_info']['display']['person_count'],
|
186 |
+
|
187 |
+
);
|
188 |
+
}
|
189 |
+
|
190 |
+
if ( isset( $meta['childs_info'] ) ) {
|
191 |
+
$custom_data[] = array(
|
192 |
+
'key' => $labels['childs'],
|
193 |
+
'display' => $meta['childs_info']['display']['person_count'],
|
194 |
+
|
195 |
+
);
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
if ( isset( $meta['pickup_date'] ) && $displays['pickup_date'] === 'open' ) {
|
200 |
+
|
201 |
+
$pickup_date_time = convert_to_output_format( $meta['pickup_date']['display'], $conditional_data['date_format'] );
|
202 |
+
|
203 |
+
if ( isset( $meta['pickup_time'] ) ) {
|
204 |
+
$pickup_date_time = $pickup_date_time . ' ' . esc_html__( 'at', 'redq-rental' ) . ' ' . $meta['pickup_time']['display'];
|
205 |
+
}
|
206 |
+
$custom_data[] = array(
|
207 |
+
'key' => $labels['pickup_datetime'],
|
208 |
+
'display' => $pickup_date_time,
|
209 |
+
|
210 |
+
);
|
211 |
+
}
|
212 |
+
|
213 |
+
if ( isset( $meta['dropoff_date'] ) && $displays['return_date'] === 'open' ) {
|
214 |
+
|
215 |
+
$return_date_time = convert_to_output_format( $meta['dropoff_date']['display'], $conditional_data['date_format'] );
|
216 |
+
|
217 |
+
if ( isset( $meta['dropoff_time'] ) ) {
|
218 |
+
$return_date_time = $return_date_time . ' ' . esc_html__( 'at', 'redq-rental' ) . ' ' . $meta['dropoff_time']['display'];
|
219 |
+
}
|
220 |
+
|
221 |
+
$custom_data[] = array(
|
222 |
+
'key' => $labels['return_datetime'],
|
223 |
+
'display' => $return_date_time,
|
224 |
+
|
225 |
+
);
|
226 |
+
}
|
227 |
+
|
228 |
+
if ( isset( $meta['rental_days_and_costs'] ) ) {
|
229 |
+
if ( $meta['rental_days_and_costs']['display']['days'] > 0 ) {
|
230 |
+
$custom_data[] = array(
|
231 |
+
'key' => $general_data['total_days'] ? $general_data['total_days'] : esc_html__( 'Total Days', 'redq-rental' ),
|
232 |
+
'display' => $meta['rental_days_and_costs']['display']['days'],
|
233 |
+
|
234 |
+
);
|
235 |
+
} else {
|
236 |
+
$custom_data[] = array(
|
237 |
+
'key' => $general_data['total_hours'] ? $general_data['total_hours'] : esc_html__( 'Total Hours', 'redq-rental' ),
|
238 |
+
'display' => $meta['rental_days_and_costs']['display']['hours'],
|
239 |
+
|
240 |
+
);
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( ! empty( $meta['rental_days_and_costs']['due_payment'] ) ) {
|
244 |
+
$custom_data[] = array(
|
245 |
+
'key' => $general_data['payment_due'] ? $general_data['payment_due'] : esc_html__( 'Due Payment', 'redq-rental' ),
|
246 |
+
'display' => wc_price( $meta['rental_days_and_costs']['display']['due_payment'] ),
|
247 |
+
|
248 |
+
);
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
return $custom_data;
|
253 |
+
}
|
254 |
+
|
255 |
+
return $meta;
|
256 |
+
}
|
257 |
+
|
258 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_rental_and_booking', 20, 3 );
|
259 |
+
} // End if().
|
260 |
+
|
261 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_rental_and_booking' ) ) {
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Modify price for WooCommerce Rental & Bookings System
|
265 |
+
*
|
266 |
+
* @param string $price Returned price.
|
267 |
+
* @param array $wl_product Wishlist Product.
|
268 |
+
* @param \WC_Product $product Woocommerce Product.
|
269 |
+
*
|
270 |
+
* @return string
|
271 |
+
*/
|
272 |
+
function tinvwl_item_price_woocommerce_rental_and_booking( $price, $wl_product, $product ) {
|
273 |
+
if ( ! class_exists( 'RedQ_Rental_And_Bookings' ) ) {
|
274 |
+
return $price;
|
275 |
+
}
|
276 |
+
|
277 |
+
$product_type = $product->get_type();
|
278 |
+
|
279 |
+
if ( isset( $product_type ) && $product_type === 'redq_rental' ) {
|
280 |
+
$meta = $wl_product['meta'];
|
281 |
+
|
282 |
+
if ( ! empty( $meta['quote_price'] ) ) {
|
283 |
+
|
284 |
+
$price = $meta['quote_price'];
|
285 |
+
|
286 |
+
return wc_price( $price );
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
return $price;
|
292 |
+
}
|
293 |
+
|
294 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_rental_and_booking', 20, 3 );
|
295 |
+
} // End if().
|
integrations/woocommerce-tm-extra-product-options.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce TM Extra Product Options
|
6 |
+
*
|
7 |
+
* @version 4.9.6
|
8 |
+
*
|
9 |
+
* @slug woocommerce-tm-extra-product-options
|
10 |
+
*
|
11 |
+
* @url https://codecanyon.net/item/woocommerce-extra-product-options/7908619
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce TM Extra Product Options
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Product ID.
|
27 |
+
* @param integer $variation_id Product variation ID.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
function tinv_wishlist_metasupport_woocommerce_tm_extra_product_options( $meta, $product_id, $variation_id ) {
|
32 |
+
if ( array_key_exists( 'tcaddtocart', $meta ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
33 |
+
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
34 |
+
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
35 |
+
$version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
|
36 |
+
$cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_CART() : TM_EPO_CART();
|
37 |
+
|
38 |
+
$has_epo = $api->has_options( $product_id );
|
39 |
+
if ( $api->is_valid_options( $has_epo ) ) {
|
40 |
+
$post_data = array();
|
41 |
+
foreach ( $meta as $key => $value ) {
|
42 |
+
$post_data[ $key ] = $value['display'];
|
43 |
+
}
|
44 |
+
|
45 |
+
$cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
|
46 |
+
|
47 |
+
$cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $post_data );
|
48 |
+
|
49 |
+
if ( 'normal' == $core->tm_epo_hide_options_in_cart && 'advanced' != $core->tm_epo_cart_field_display && ! empty( $cart_item['tmcartepo'] ) ) {
|
50 |
+
$cart_item['quantity'] = 1;
|
51 |
+
$cart_item['data'] = wc_get_product( $variation_id ? $variation_id : $product_id );
|
52 |
+
$cart_item['tm_cart_item_key'] = '';
|
53 |
+
$item_data = $cart_class->get_item_data_array( array(), $cart_item );
|
54 |
+
|
55 |
+
foreach ( $item_data as $key => $data ) {
|
56 |
+
// Set hidden to true to not display meta on cart.
|
57 |
+
if ( ! empty( $data['hidden'] ) ) {
|
58 |
+
unset( $item_data[ $key ] );
|
59 |
+
continue;
|
60 |
+
}
|
61 |
+
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
|
62 |
+
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
|
63 |
+
}
|
64 |
+
|
65 |
+
return $item_data;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
return array();
|
70 |
+
}
|
71 |
+
|
72 |
+
return $meta;
|
73 |
+
}
|
74 |
+
|
75 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options', 10, 3 );
|
76 |
+
} // End if().
|
77 |
+
|
78 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options' ) ) {
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Modify price for WooCommerce TM Extra Product Options
|
82 |
+
*
|
83 |
+
* @param string $price Returned price.
|
84 |
+
* @param array $wl_product Wishlist Product.
|
85 |
+
* @param \WC_Product $product Woocommerce Product.
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
function tinvwl_item_price_woocommerce_tm_extra_product_options( $price, $wl_product, $product ) {
|
90 |
+
if ( array_key_exists( 'tcaddtocart', (array) @$wl_product['meta'] ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
91 |
+
|
92 |
+
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
93 |
+
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
94 |
+
$version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
|
95 |
+
$cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_CART() : TM_EPO_CART();
|
96 |
+
if ( $core->tm_epo_hide_options_in_cart == 'normal' ) {
|
97 |
+
$product_id = $wl_product['product_id'];
|
98 |
+
$has_epo = $api->has_options( $product_id );
|
99 |
+
if ( $api->is_valid_options( $has_epo ) ) {
|
100 |
+
|
101 |
+
$cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
|
102 |
+
|
103 |
+
$cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $wl_product['meta'] );
|
104 |
+
$cart_item['quantity'] = 1;
|
105 |
+
$cart_item['data'] = $product;
|
106 |
+
|
107 |
+
$product_price = apply_filters( 'wc_epo_add_cart_item_original_price', $cart_item['data']->get_price(), $cart_item );
|
108 |
+
if ( ! empty( $cart_item['tmcartepo'] ) ) {
|
109 |
+
$to_currency = version_compare( $version, '4.9.0', '<' ) ? tc_get_woocommerce_currency() : themecomplete_get_woocommerce_currency();
|
110 |
+
foreach ( $cart_item['tmcartepo'] as $value ) {
|
111 |
+
if ( array_key_exists( $to_currency, $value['price_per_currency'] ) ) {
|
112 |
+
$value = floatval( $value['price_per_currency'][ $to_currency ] );
|
113 |
+
$product_price += $value;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
$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 );
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return $price;
|
124 |
+
}
|
125 |
+
|
126 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3 );
|
127 |
+
} // End if().
|
integrations/woocommerce-variation-swatches-and-photos.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WP Fastest Cache
|
6 |
+
*
|
7 |
+
* @version 0.8.9.6
|
8 |
+
*
|
9 |
+
* @slug wp-fastest-cache
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/wp-fastest-cache/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_wp_fastest_cache_reject' ) ) {
|
21 |
+
/**
|
22 |
+
* Disable cache for WP Fastest Cache
|
23 |
+
*/
|
24 |
+
function tinvwl_wp_fastest_cache_reject() {
|
25 |
+
if ( defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
|
26 |
+
if ( $rules_json = get_option( 'WpFastestCacheExclude' ) ) {
|
27 |
+
if ( 'null' !== $rules_json ) {
|
28 |
+
$ids = array(
|
29 |
+
tinv_get_option( 'page', 'wishlist' ),
|
30 |
+
tinv_get_option( 'page', 'manage' ),
|
31 |
+
);
|
32 |
+
$pages = $ids;
|
33 |
+
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
34 |
+
'skip_missing' => 0,
|
35 |
+
'orderby' => 'code',
|
36 |
+
) );
|
37 |
+
if ( ! empty( $languages ) ) {
|
38 |
+
foreach ( $ids as $id ) {
|
39 |
+
foreach ( $languages as $l ) {
|
40 |
+
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
$pages = array_unique( $pages );
|
44 |
+
}
|
45 |
+
$pages = array_filter( $pages );
|
46 |
+
if ( ! empty( $pages ) ) {
|
47 |
+
foreach ( $pages as $i => $page ) {
|
48 |
+
$pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
49 |
+
}
|
50 |
+
}
|
51 |
+
$pages = array_unique( $pages );
|
52 |
+
$pages = array_filter( $pages );
|
53 |
+
|
54 |
+
$rules_std = json_decode( $rules_json, true );
|
55 |
+
$ex_pages = array();
|
56 |
+
foreach ( $rules_std as $value ) {
|
57 |
+
$value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
|
58 |
+
if ( 'page' === $value['type'] ) {
|
59 |
+
$ex_pages[] = $value['content'];
|
60 |
+
}
|
61 |
+
}
|
62 |
+
$ex_pages = array_unique( $ex_pages );
|
63 |
+
$ex_pages = array_filter( $ex_pages );
|
64 |
+
$changed = false;
|
65 |
+
|
66 |
+
foreach ( $pages as $page ) {
|
67 |
+
$page = preg_replace( '/\/$/', '', $page );
|
68 |
+
|
69 |
+
if ( ! in_array( $page, $ex_pages ) ) {
|
70 |
+
$changed = true;
|
71 |
+
$rules_std[] = array(
|
72 |
+
'prefix' => 'startwith',
|
73 |
+
'content' => $page,
|
74 |
+
'type' => 'page',
|
75 |
+
);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
if ( $changed ) {
|
79 |
+
$data = json_encode( $rules_std );
|
80 |
+
update_option( 'WpFastestCacheExclude', $data );
|
81 |
+
}
|
82 |
+
} // End if().
|
83 |
+
} // End if().
|
84 |
+
} // End if().
|
85 |
+
}
|
86 |
+
|
87 |
+
add_action( 'admin_init', 'tinvwl_wp_fastest_cache_reject' );
|
88 |
+
} // End if().
|
integrations/wp-multilang.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WP Multilang
|
6 |
+
*
|
7 |
+
* @version 2.3.0
|
8 |
+
*
|
9 |
+
* @slug wp-multilang
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/wp-multilang/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
// WP Multilang string translations.
|
21 |
+
if ( function_exists( 'wpm_translate_string' ) ) {
|
22 |
+
|
23 |
+
add_filter( 'tinvwl_default_wishlist_title', 'wpm_translate_string' );
|
24 |
+
add_filter( 'tinvwl_view_wishlist_text', 'wpm_translate_string' );
|
25 |
+
add_filter( 'tinvwl_added_to_wishlist_text', 'wpm_translate_string' );
|
26 |
+
add_filter( 'tinvwl_already_in_wishlist_text', 'wpm_translate_string' );
|
27 |
+
add_filter( 'tinvwl_removed_from_wishlist_text', 'wpm_translate_string' );
|
28 |
+
add_filter( 'tinvwl_remove_from_wishlist_text', 'wpm_translate_string' );
|
29 |
+
|
30 |
+
add_filter( 'tinvwl_added_to_wishlist_text_loop', 'wpm_translate_string' );
|
31 |
+
add_filter( 'tinvwl_remove_from_wishlist_text_loop', 'wpm_translate_string' );
|
32 |
+
|
33 |
+
add_filter( 'tinvwl_add_to_cart_text', 'wpm_translate_string' );
|
34 |
+
|
35 |
+
add_filter( 'tinvwl_add_selected_to_cart_text', 'wpm_translate_string' );
|
36 |
+
add_filter( 'tinvwl_add_all_to_cart_text', 'wpm_translate_string' );
|
37 |
+
|
38 |
+
add_filter( 'tinvwl_share_on_text', 'wpm_translate_string' );
|
39 |
+
|
40 |
+
add_filter( 'tinvwl_wishlist_products_counter_text', 'wpm_translate_string' );
|
41 |
+
|
42 |
+
} // End if().
|
integrations/wp-rocket.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WP Rocket
|
6 |
+
*
|
7 |
+
* @version 3.3.6
|
8 |
+
*
|
9 |
+
* @slug wp-rocket
|
10 |
+
*
|
11 |
+
* @url https://wp-rocket.me/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinvwl_rocket_reject_cookies' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Disable cache for WP Rocket
|
24 |
+
*
|
25 |
+
* @param array $cookies Cookies.
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function tinvwl_rocket_reject_cookies( $cookies = array() ) {
|
30 |
+
$cookies[] = 'tinv_wishlist';
|
31 |
+
|
32 |
+
return $cookies;
|
33 |
+
}
|
34 |
+
|
35 |
+
add_filter( 'rocket_cache_reject_cookies', 'tinvwl_rocket_reject_cookies' );
|
36 |
+
}
|
integrations/yith-woocommerce-product-add-ons.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name YITH WooCommerce Product Add-Ons
|
6 |
+
*
|
7 |
+
* @version 1.5.20
|
8 |
+
*
|
9 |
+
* @slug yith-woocommerce-product-add-ons
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/yith-woocommerce-product-add-ons/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta YITH WooCommerce Product Add-on
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param array $wl_product Wishlist Product.
|
27 |
+
* @param \WC_Product $product Woocommerce Product.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
function tinv_wishlist_item_meta_yith_woocommerce_product_add_on( $item_data, $product_id, $variation_id ) {
|
32 |
+
|
33 |
+
if ( isset( $item_data['yith_wapo_is_single'] ) && class_exists( 'YITH_WAPO' ) ) {
|
34 |
+
unset( $item_data['yith_wapo_is_single'] );
|
35 |
+
|
36 |
+
$id = ( $variation_id ) ? $variation_id : $product_id;
|
37 |
+
|
38 |
+
$base_product = wc_get_product( $id );
|
39 |
+
|
40 |
+
if ( ( is_object( $base_product ) && get_option( 'yith_wapo_settings_show_product_price_cart' ) == 'yes' ) ) {
|
41 |
+
|
42 |
+
$price = yit_get_display_price( $base_product );
|
43 |
+
|
44 |
+
$price_html = wc_price( $price );
|
45 |
+
|
46 |
+
$item_data[] = array(
|
47 |
+
'key' => __( 'Base price', 'ti-woocommerce-wishlist' ),
|
48 |
+
'display' => $price_html,
|
49 |
+
);
|
50 |
+
|
51 |
+
}
|
52 |
+
$type_list = YITH_WAPO_Type::getAllowedGroupTypes( $id );
|
53 |
+
|
54 |
+
foreach ( $type_list as $single_type ) {
|
55 |
+
|
56 |
+
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
57 |
+
|
58 |
+
$value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ] : '';
|
59 |
+
|
60 |
+
if ( ! $value || ! is_array( $value ) || ! isset( $value['display'] ) ) {
|
61 |
+
$value = '';
|
62 |
+
} elseif ( is_array( $value ) && isset( $value['display'] ) && ! ctype_digit( strval( $value['display'][0] ) ) ) {
|
63 |
+
$value = $value['display'][0];
|
64 |
+
} else {
|
65 |
+
$value = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, $value['display'][0], 'label' );
|
66 |
+
}
|
67 |
+
|
68 |
+
unset( $item_data[ $original_data ] );
|
69 |
+
if ( $value ) {
|
70 |
+
$item_data[] = array(
|
71 |
+
'key' => $single_type->label,
|
72 |
+
'display' => $value,
|
73 |
+
);
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
return $item_data;
|
81 |
+
}
|
82 |
+
|
83 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on', 10, 3 );
|
84 |
+
} // End if().
|
85 |
+
|
86 |
+
if ( ! function_exists( 'tinvwl_item_price_yith_woocommerce_product_add_on' ) ) {
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Modify price for YITH WooCommerce product Addons.
|
90 |
+
*
|
91 |
+
* @param string $price Returned price.
|
92 |
+
* @param array $wl_product Wishlist Product.
|
93 |
+
* @param \WC_Product $product Woocommerce Product.
|
94 |
+
*
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
function tinvwl_item_price_yith_woocommerce_product_add_on( $price, $wl_product, $product ) {
|
98 |
+
|
99 |
+
if ( class_exists( 'YITH_WAPO' ) ) {
|
100 |
+
|
101 |
+
$type_list = YITH_WAPO_Type::getAllowedGroupTypes( $product->get_id() );
|
102 |
+
|
103 |
+
if ( $type_list ) {
|
104 |
+
|
105 |
+
$addons_total = 0;
|
106 |
+
|
107 |
+
foreach ( $type_list as $single_type ) {
|
108 |
+
|
109 |
+
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
110 |
+
|
111 |
+
$value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
|
112 |
+
|
113 |
+
|
114 |
+
if ( ! is_array( $value ) || ! ctype_digit( strval( $value[0] ) ) ) {
|
115 |
+
continue;
|
116 |
+
}
|
117 |
+
|
118 |
+
$addon_price = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, $value[0], 'price' );
|
119 |
+
|
120 |
+
if ( is_numeric( $addon_price ) ) {
|
121 |
+
$addons_total += $addon_price;
|
122 |
+
}
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
$price = wc_price( $product->get_price() + $addons_total );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
return $price;
|
131 |
+
}
|
132 |
+
|
133 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_yith_woocommerce_product_add_on', 10, 3 );
|
134 |
+
} // End if().
|
integrations/yith-woocommerce-product-bundles.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name YITH WooCommerce Product Bundles
|
6 |
+
*
|
7 |
+
* @version 1.1.15
|
8 |
+
*
|
9 |
+
* @slug yith-woocommerce-product-bundles
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/yith-woocommerce-product-bundles/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta WooCommerce Mix and Match
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param integer $product_id Product ID.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function tinv_wishlist_metasupport_yith_woocommerce_product_bundles( $meta, $product_id ) {
|
31 |
+
if ( array_key_exists( 'yith_bundle_quantity_1', $meta ) ) {
|
32 |
+
$product = wc_get_product( $product_id );
|
33 |
+
if ( is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
|
34 |
+
$meta = array();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return $meta;
|
39 |
+
}
|
40 |
+
|
41 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles', 10, 2 );
|
42 |
+
} // End if().
|
43 |
+
|
44 |
+
if ( ! function_exists( 'tinvwl_item_status_yith_woocommerce_product_bundles' ) ) {
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Modify status for YITH WooCommerce Product Bundles
|
48 |
+
*
|
49 |
+
* @param string $availability_html Returned availability status.
|
50 |
+
* @param string $availability Availability status.
|
51 |
+
* @param array $wl_product Wishlist Product.
|
52 |
+
* @param \WC_Product $product Woocommerce Product.
|
53 |
+
*
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
function tinvwl_item_status_yith_woocommerce_product_bundles( $availability_html, $availability, $wl_product, $product ) {
|
57 |
+
if ( empty( $availability ) && is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
|
58 |
+
$response = true;
|
59 |
+
$bundled_items = $product->get_bundled_items();
|
60 |
+
foreach ( $bundled_items as $key => $bundled_item ) {
|
61 |
+
if ( method_exists( $bundled_item, 'is_optional' ) ) {
|
62 |
+
if ( $bundled_item->is_optional() && ! array_key_exists( 'yith_bundle_optional_' . $key, $wl_product['meta'] ) ) {
|
63 |
+
continue;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
if ( ! $bundled_item->get_product()->is_in_stock() ) {
|
67 |
+
$response = false;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
if ( ! $response ) {
|
72 |
+
$availability = array(
|
73 |
+
'class' => 'out-of-stock',
|
74 |
+
'availability' => __( 'Out of stock', 'ti-woocommerce-wishlist' ),
|
75 |
+
);
|
76 |
+
$availability_html = '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
return $availability_html;
|
81 |
+
}
|
82 |
+
|
83 |
+
add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_yith_woocommerce_product_bundles', 10, 4 );
|
84 |
+
} // End if().
|
85 |
+
|
86 |
+
if ( ! function_exists( 'tinvwl_row_yith_woocommerce_product_bundles' ) ) {
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Add rows for sub product for YITH WooCommerce Product Bundles
|
90 |
+
*
|
91 |
+
* @param array $wl_product Wishlist Product.
|
92 |
+
* @param \WC_Product $product Woocommerce Product.
|
93 |
+
*/
|
94 |
+
function tinvwl_row_yith_woocommerce_product_bundles( $wl_product, $product ) {
|
95 |
+
if ( is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
|
96 |
+
$bundled_items = $product->get_bundled_items();
|
97 |
+
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
98 |
+
if ( ! empty( $bundled_items ) ) {
|
99 |
+
foreach ( $bundled_items as $key => $bundled_item ) {
|
100 |
+
$item_quantity = $bundled_item->get_quantity();
|
101 |
+
if ( array_key_exists( 'yith_bundle_quantity_' . $key, $wl_product['meta'] ) ) {
|
102 |
+
$item_quantity = absint( $wl_product['meta'][ 'yith_bundle_quantity_' . $key ] );
|
103 |
+
}
|
104 |
+
if ( method_exists( $bundled_item, 'is_optional' ) ) {
|
105 |
+
if ( $bundled_item->is_optional() && ! array_key_exists( 'yith_bundle_optional_' . $key, $wl_product['meta'] ) ) {
|
106 |
+
$item_quantity = 0;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
if ( 0 >= $item_quantity ) {
|
110 |
+
continue;
|
111 |
+
}
|
112 |
+
|
113 |
+
$product = $bundled_item->get_product();
|
114 |
+
if ( ! is_object( $product ) ) {
|
115 |
+
continue;
|
116 |
+
}
|
117 |
+
|
118 |
+
$product_url = $product->get_permalink();
|
119 |
+
$product_image = $product->get_image();
|
120 |
+
$product_title = $product->get_title();
|
121 |
+
$product_price = $product->get_price_html();
|
122 |
+
if ( $product->is_visible() ) {
|
123 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
124 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
125 |
+
}
|
126 |
+
$product_title .= tinv_wishlist_get_item_data( $product, $wl_product );
|
127 |
+
|
128 |
+
$availability = (array) $product->get_availability();
|
129 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
130 |
+
$availability['availability'] = '';
|
131 |
+
}
|
132 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
133 |
+
$availability['class'] = '';
|
134 |
+
}
|
135 |
+
$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>';
|
136 |
+
$row_string = '<tr>';
|
137 |
+
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
138 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
139 |
+
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
140 |
+
}
|
141 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
142 |
+
$row_string .= '<td class="product-date"> </td>';
|
143 |
+
}
|
144 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
145 |
+
$row_string .= '<td class="product-stock">%4$s</td>';
|
146 |
+
}
|
147 |
+
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
148 |
+
$row_string .= '<td class="product-action"> </td>';
|
149 |
+
}
|
150 |
+
$row_string .= '</tr>';
|
151 |
+
|
152 |
+
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
|
153 |
+
} // End foreach().
|
154 |
+
} // End if().
|
155 |
+
} // End if().
|
156 |
+
}
|
157 |
+
|
158 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_yith_woocommerce_product_bundles', 10, 2 );
|
159 |
+
} // End if().
|
languages/ti-woocommerce-wishlist.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
# Copyright (C) 2019 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"
|
@@ -820,15 +820,15 @@ msgstr ""
|
|
820 |
msgid "%1$s %3$s is required. Please activate it before activating this plugin."
|
821 |
msgstr ""
|
822 |
|
823 |
-
#: includes/tinvwl.class.php:
|
824 |
msgid "Settings"
|
825 |
msgstr ""
|
826 |
|
827 |
-
#: includes/tinvwl.class.php:
|
828 |
msgid "Premium Version"
|
829 |
msgstr ""
|
830 |
|
831 |
-
#: includes/tinvwl.class.php:
|
832 |
msgid "Live Demo"
|
833 |
msgstr ""
|
834 |
|
@@ -892,6 +892,82 @@ msgstr ""
|
|
892 |
msgid "Ready!"
|
893 |
msgstr ""
|
894 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
895 |
#: public/addtowishlist.class.php:180
|
896 |
msgid "Please, login to add products to Wishlist"
|
897 |
msgstr ""
|
@@ -1045,82 +1121,6 @@ msgstr ""
|
|
1045 |
msgid "Select for bulk action"
|
1046 |
msgstr ""
|
1047 |
|
1048 |
-
#: templates/ti-wishlist-user.php:136, templates/ti-wishlist.php:144, tinv-wishlists-function-integration.php:777, tinv-wishlists-function-integration.php:933, tinv-wishlists-function-integration.php:1095, tinv-wishlists-function-integration.php:1309
|
1049 |
-
msgid "In stock"
|
1050 |
-
msgstr ""
|
1051 |
-
|
1052 |
-
#: tinv-wishlists-function-integration.php:149
|
1053 |
-
msgid "Select options"
|
1054 |
-
msgstr ""
|
1055 |
-
|
1056 |
-
#: tinv-wishlists-function-integration.php:485
|
1057 |
-
msgid "Note"
|
1058 |
-
msgstr ""
|
1059 |
-
|
1060 |
-
#: tinv-wishlists-function-integration.php:488
|
1061 |
-
msgid "To"
|
1062 |
-
msgstr ""
|
1063 |
-
|
1064 |
-
#: tinv-wishlists-function-integration.php:491
|
1065 |
-
msgid "To Email"
|
1066 |
-
msgstr ""
|
1067 |
-
|
1068 |
-
#: tinv-wishlists-function-integration.php:494
|
1069 |
-
msgid "Address"
|
1070 |
-
msgstr ""
|
1071 |
-
|
1072 |
-
#: tinv-wishlists-function-integration.php:497
|
1073 |
-
msgid "Reload existing Gift Card"
|
1074 |
-
msgstr ""
|
1075 |
-
|
1076 |
-
#: tinv-wishlists-function-integration.php:1248
|
1077 |
-
msgid "Out of stock"
|
1078 |
-
msgstr ""
|
1079 |
-
|
1080 |
-
#: tinv-wishlists-function-integration.php:1671
|
1081 |
-
msgid "Base price"
|
1082 |
-
msgstr ""
|
1083 |
-
|
1084 |
-
#: tinv-wishlists-function-integration.php:2425
|
1085 |
-
msgid "WooCommerce Wishlist"
|
1086 |
-
msgstr ""
|
1087 |
-
|
1088 |
-
#: tinv-wishlists-function-integration.php:2426
|
1089 |
-
msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
|
1090 |
-
msgstr ""
|
1091 |
-
|
1092 |
-
#: tinv-wishlists-function-integration.php:2572
|
1093 |
-
msgid "Adding Product to Wishlist"
|
1094 |
-
msgstr ""
|
1095 |
-
|
1096 |
-
#: tinv-wishlists-function-integration.php:2577, tinv-wishlists-function-integration.php:2622
|
1097 |
-
msgid "Points"
|
1098 |
-
msgstr ""
|
1099 |
-
|
1100 |
-
#: tinv-wishlists-function-integration.php:2590, tinv-wishlists-function-integration.php:2635
|
1101 |
-
msgid "Limit"
|
1102 |
-
msgstr ""
|
1103 |
-
|
1104 |
-
#: tinv-wishlists-function-integration.php:2603, tinv-wishlists-function-integration.php:2648
|
1105 |
-
msgid "Log Template"
|
1106 |
-
msgstr ""
|
1107 |
-
|
1108 |
-
#: tinv-wishlists-function-integration.php:2607, tinv-wishlists-function-integration.php:2652
|
1109 |
-
msgid "required"
|
1110 |
-
msgstr ""
|
1111 |
-
|
1112 |
-
#: tinv-wishlists-function-integration.php:2617
|
1113 |
-
msgid "Purchasing Product from Wishlist"
|
1114 |
-
msgstr ""
|
1115 |
-
|
1116 |
-
#: tinv-wishlists-function-integration.php:2703
|
1117 |
-
msgid "Purchased From Wishlist"
|
1118 |
-
msgstr ""
|
1119 |
-
|
1120 |
-
#: tinv-wishlists-function-integration.php:2704
|
1121 |
-
msgid "Added To Wishlist"
|
1122 |
-
msgstr ""
|
1123 |
-
|
1124 |
#: views/admin/premium-features.php:21
|
1125 |
msgid "Premium version"
|
1126 |
msgstr ""
|
1 |
+
# Copyright (C) 2019 TI WooCommerce Wishlist Plugin - 1.14.0
|
2 |
+
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.14.0 package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.14.0\n"
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
820 |
msgid "%1$s %3$s is required. Please activate it before activating this plugin."
|
821 |
msgstr ""
|
822 |
|
823 |
+
#: includes/tinvwl.class.php:167
|
824 |
msgid "Settings"
|
825 |
msgstr ""
|
826 |
|
827 |
+
#: includes/tinvwl.class.php:168
|
828 |
msgid "Premium Version"
|
829 |
msgstr ""
|
830 |
|
831 |
+
#: includes/tinvwl.class.php:169
|
832 |
msgid "Live Demo"
|
833 |
msgstr ""
|
834 |
|
892 |
msgid "Ready!"
|
893 |
msgstr ""
|
894 |
|
895 |
+
#: integrations/gift-cards-for-woocommerce.php:92
|
896 |
+
msgid "Note"
|
897 |
+
msgstr ""
|
898 |
+
|
899 |
+
#: integrations/gift-cards-for-woocommerce.php:95
|
900 |
+
msgid "To"
|
901 |
+
msgstr ""
|
902 |
+
|
903 |
+
#: integrations/gift-cards-for-woocommerce.php:98
|
904 |
+
msgid "To Email"
|
905 |
+
msgstr ""
|
906 |
+
|
907 |
+
#: integrations/gift-cards-for-woocommerce.php:101
|
908 |
+
msgid "Address"
|
909 |
+
msgstr ""
|
910 |
+
|
911 |
+
#: integrations/gift-cards-for-woocommerce.php:104
|
912 |
+
msgid "Reload existing Gift Card"
|
913 |
+
msgstr ""
|
914 |
+
|
915 |
+
#: integrations/mycred.php:30
|
916 |
+
msgid "WooCommerce Wishlist"
|
917 |
+
msgstr ""
|
918 |
+
|
919 |
+
#: integrations/mycred.php:31
|
920 |
+
msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
|
921 |
+
msgstr ""
|
922 |
+
|
923 |
+
#: integrations/mycred.php:177
|
924 |
+
msgid "Adding Product to Wishlist"
|
925 |
+
msgstr ""
|
926 |
+
|
927 |
+
#: integrations/mycred.php:182, integrations/mycred.php:227
|
928 |
+
msgid "Points"
|
929 |
+
msgstr ""
|
930 |
+
|
931 |
+
#: integrations/mycred.php:195, integrations/mycred.php:240
|
932 |
+
msgid "Limit"
|
933 |
+
msgstr ""
|
934 |
+
|
935 |
+
#: integrations/mycred.php:208, integrations/mycred.php:253
|
936 |
+
msgid "Log Template"
|
937 |
+
msgstr ""
|
938 |
+
|
939 |
+
#: integrations/mycred.php:212, integrations/mycred.php:257
|
940 |
+
msgid "required"
|
941 |
+
msgstr ""
|
942 |
+
|
943 |
+
#: integrations/mycred.php:222
|
944 |
+
msgid "Purchasing Product from Wishlist"
|
945 |
+
msgstr ""
|
946 |
+
|
947 |
+
#: integrations/mycred.php:308
|
948 |
+
msgid "Purchased From Wishlist"
|
949 |
+
msgstr ""
|
950 |
+
|
951 |
+
#: integrations/mycred.php:309
|
952 |
+
msgid "Added To Wishlist"
|
953 |
+
msgstr ""
|
954 |
+
|
955 |
+
#: integrations/woocommerce-composite-products.php:106, integrations/woocommerce-mix-and-match-products.php:83, integrations/woocommerce-product-bundles.php:105, integrations/yith-woocommerce-product-bundles.php:135, templates/ti-wishlist-user.php:136, templates/ti-wishlist.php:144
|
956 |
+
msgid "In stock"
|
957 |
+
msgstr ""
|
958 |
+
|
959 |
+
#: integrations/woocommerce-gravityforms-product-addons.php:43
|
960 |
+
msgid "Select options"
|
961 |
+
msgstr ""
|
962 |
+
|
963 |
+
#: integrations/yith-woocommerce-product-add-ons.php:47
|
964 |
+
msgid "Base price"
|
965 |
+
msgstr ""
|
966 |
+
|
967 |
+
#: integrations/yith-woocommerce-product-bundles.php:74
|
968 |
+
msgid "Out of stock"
|
969 |
+
msgstr ""
|
970 |
+
|
971 |
#: public/addtowishlist.class.php:180
|
972 |
msgid "Please, login to add products to Wishlist"
|
973 |
msgstr ""
|
1121 |
msgid "Select for bulk action"
|
1122 |
msgstr ""
|
1123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1124 |
#: views/admin/premium-features.php:21
|
1125 |
msgid "Premium version"
|
1126 |
msgstr ""
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: templateinvaders
|
|
3 |
Tags: wishlist, woocommerce, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.2
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -157,6 +157,18 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
|
|
157 |
|
158 |
|
159 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
= 1.13.2 =
|
161 |
*Release Date - 30 July 2019*
|
162 |
|
@@ -230,16 +242,5 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
|
|
230 |
* [WooCommerce PPOM](https://wordpress.org/plugins/woocommerce-product-addon/) plugin integration updated
|
231 |
* Fixed analytics purchase count issue
|
232 |
|
233 |
-
= 1.10.0 =
|
234 |
-
*Release Date - 9 April 2019*
|
235 |
-
|
236 |
-
* Added Force permalinks rewrite feature
|
237 |
-
* Added numeric pagination on a Wishlist page
|
238 |
-
* Added analytic tracking feature for compatibility with the premium version of plugin
|
239 |
-
* Improved compatibility with TM Extra Product Options plugin
|
240 |
-
* Fixed pagination issue on a Wishlist page for all actions
|
241 |
-
* Fixed minor PHP issues
|
242 |
-
* Fixed minor CSS issues
|
243 |
-
|
244 |
[See changelog for all versions](https://templateinvaders.com/changelogs/ti-woocommerce-wishlist-plugin-free-changelog/?utm_source=wordpressorg&utm_content=changelog).
|
245 |
|
3 |
Tags: wishlist, woocommerce, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.2
|
6 |
+
Stable tag: 1.14.0
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
157 |
|
158 |
|
159 |
== Changelog ==
|
160 |
+
= 1.14.0 =
|
161 |
+
*Release Date - 12 August 2019*
|
162 |
+
|
163 |
+
* Added support for WooCommerce 3.7
|
164 |
+
* Added compatibility with [Variations Swatches and Photos](https://woocommerce.com/products/variation-swatches-and-photos/?aff=3955) plugin
|
165 |
+
* Added compatibility with Clever Swatches plugin
|
166 |
+
* Added compatibility with WooCommerce Custom Product Addons (Pro) plugin
|
167 |
+
* Added compatibility with WooCommerce Rental & Bookings System plugin
|
168 |
+
* Added compatibility with Booking & Appointment Plugin for WooCommerce
|
169 |
+
* Refactored all 3rd party integrations code
|
170 |
+
* Fixed an issue with properly load custom translation files
|
171 |
+
|
172 |
= 1.13.2 =
|
173 |
*Release Date - 30 July 2019*
|
174 |
|
242 |
* [WooCommerce PPOM](https://wordpress.org/plugins/woocommerce-product-addon/) plugin integration updated
|
243 |
* Fixed analytics purchase count issue
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
[See changelog for all versions](https://templateinvaders.com/changelogs/ti-woocommerce-wishlist-plugin-free-changelog/?utm_source=wordpressorg&utm_content=changelog).
|
246 |
|
ti-woocommerce-wishlist.php
CHANGED
@@ -1,253 +1,255 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* TI WooCommerce Wishlist Plugin.
|
4 |
-
* Plugin Name: TI WooCommerce Wishlist Plugin
|
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.5
|
9 |
-
* Tested up to: 5.2
|
10 |
-
* WC requires at least: 2.6
|
11 |
-
* WC tested up to: 3.
|
12 |
-
* Author: TemplateInvaders
|
13 |
-
* Author URI: https://templateinvaders.com/
|
14 |
-
* License: GPL-2.0+
|
15 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
16 |
-
* Text Domain: ti-woocommerce-wishlist
|
17 |
-
* Domain Path: /languages
|
18 |
-
*
|
19 |
-
* @package TInvWishlist
|
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.
|
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
|
55 |
-
*
|
56 |
-
* @param array $array1 Array.
|
57 |
-
* @param array $_ Array.
|
58 |
-
*
|
59 |
-
* @return array
|
60 |
-
*/
|
61 |
-
function tinv_array_merge( $array1, $_ = null ) {
|
62 |
-
if ( ! is_array( $array1 ) ) {
|
63 |
-
return $array1;
|
64 |
-
}
|
65 |
-
$args = func_get_args();
|
66 |
-
array_shift( $args );
|
67 |
-
foreach ( $args as $array2 ) {
|
68 |
-
if ( is_array( $array2 ) ) {
|
69 |
-
foreach ( $array2 as $key => $value ) {
|
70 |
-
$array1[ $key ] = $value;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
return $array1;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
if ( ! function_exists( 'tinv_get_option_defaults' ) ) {
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Extract default options from settings class
|
84 |
-
*
|
85 |
-
* @param string $category Name category settings.
|
86 |
-
*
|
87 |
-
* @return array
|
88 |
-
*/
|
89 |
-
function tinv_get_option_defaults( $category ) {
|
90 |
-
$dir = TINVWL_PATH . 'admin/settings/';
|
91 |
-
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
92 |
-
return array();
|
93 |
-
}
|
94 |
-
$files = scandir( $dir );
|
95 |
-
foreach ( $files as $key => $value ) {
|
96 |
-
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
97 |
-
$files[ $key ] = preg_replace( '/\.class\.php$/i', '', $value );
|
98 |
-
} else {
|
99 |
-
unset( $files[ $key ] );
|
100 |
-
}
|
101 |
-
}
|
102 |
-
$defaults = array();
|
103 |
-
foreach ( $files as $file ) {
|
104 |
-
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
105 |
-
$class = $class::instance();
|
106 |
-
$class_methods = get_class_methods( $class );
|
107 |
-
foreach ( $class_methods as $method ) {
|
108 |
-
if ( preg_match( '/_data$/i', $method ) ) {
|
109 |
-
$settings = $class->get_defaults( $class->$method() );
|
110 |
-
$defaults = tinv_array_merge( $defaults, $settings );
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
if ( 'all' === $category ) {
|
115 |
-
return $defaults;
|
116 |
-
}
|
117 |
-
if ( array_key_exists( $category, $defaults ) ) {
|
118 |
-
return $defaults[ $category ];
|
119 |
-
}
|
120 |
-
|
121 |
-
return array();
|
122 |
-
}
|
123 |
-
} // End if().
|
124 |
-
|
125 |
-
if ( ! function_exists( 'activation_tinv_wishlist' ) ) {
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Activation plugin
|
129 |
-
*/
|
130 |
-
function activation_tinv_wishlist() {
|
131 |
-
if ( dependency_tinv_wishlist( false ) ) {
|
132 |
-
TInvWL_Activator::activate();
|
133 |
-
flush_rewrite_rules();
|
134 |
-
}
|
135 |
-
}
|
136 |
-
}
|
137 |
-
|
138 |
-
if ( ! function_exists( 'deactivation_tinv_wishlist' ) ) {
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Deactivation plugin
|
142 |
-
*/
|
143 |
-
function deactivation_tinv_wishlist() {
|
144 |
-
flush_rewrite_rules();
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Uninstall plugin
|
152 |
-
*/
|
153 |
-
function uninstall_tinv_wishlist() {
|
154 |
-
if ( ! defined( 'TINVWL_LOAD_PREMIUM' ) ) {
|
155 |
-
TInvWL_Activator::uninstall();
|
156 |
-
flush_rewrite_rules();
|
157 |
-
wp_clear_scheduled_hook( 'tinvwl_remove_without_author_wishlist' );
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
if ( function_exists( 'spl_autoload_register' ) && ! function_exists( 'autoload_tinv_wishlist' ) ) {
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Autoloader class. If no function spl_autoload_register, then all the files will be required
|
166 |
-
*
|
167 |
-
* @param string $_class Required class name.
|
168 |
-
*
|
169 |
-
* @return boolean
|
170 |
-
*/
|
171 |
-
function autoload_tinv_wishlist( $_class ) {
|
172 |
-
$preffix = 'TInvWL';
|
173 |
-
$ext = '.php';
|
174 |
-
$class = explode( '_', $_class );
|
175 |
-
$object = array_shift( $class );
|
176 |
-
if ( $preffix !== $object ) {
|
177 |
-
return false;
|
178 |
-
}
|
179 |
-
if ( empty( $class ) ) {
|
180 |
-
$class = array( $preffix );
|
181 |
-
}
|
182 |
-
$basicclass = $class;
|
183 |
-
array_unshift( $class, 'includes' );
|
184 |
-
$
|
185 |
-
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $basicclass ) ),
|
186 |
-
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $class ) ),
|
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 |
-
$ext
|
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 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist Plugin.
|
4 |
+
* Plugin Name: TI WooCommerce Wishlist Plugin
|
5 |
+
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
+
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
+
* Version: 1.14.0
|
8 |
+
* Requires at least: 4.5
|
9 |
+
* Tested up to: 5.2
|
10 |
+
* WC requires at least: 2.6
|
11 |
+
* WC tested up to: 3.7.0
|
12 |
+
* Author: TemplateInvaders
|
13 |
+
* Author URI: https://templateinvaders.com/
|
14 |
+
* License: GPL-2.0+
|
15 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
16 |
+
* Text Domain: ti-woocommerce-wishlist
|
17 |
+
* Domain Path: /languages
|
18 |
+
*
|
19 |
+
* @package TInvWishlist
|
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.14.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
|
55 |
+
*
|
56 |
+
* @param array $array1 Array.
|
57 |
+
* @param array $_ Array.
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
function tinv_array_merge( $array1, $_ = null ) {
|
62 |
+
if ( ! is_array( $array1 ) ) {
|
63 |
+
return $array1;
|
64 |
+
}
|
65 |
+
$args = func_get_args();
|
66 |
+
array_shift( $args );
|
67 |
+
foreach ( $args as $array2 ) {
|
68 |
+
if ( is_array( $array2 ) ) {
|
69 |
+
foreach ( $array2 as $key => $value ) {
|
70 |
+
$array1[ $key ] = $value;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
return $array1;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
if ( ! function_exists( 'tinv_get_option_defaults' ) ) {
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Extract default options from settings class
|
84 |
+
*
|
85 |
+
* @param string $category Name category settings.
|
86 |
+
*
|
87 |
+
* @return array
|
88 |
+
*/
|
89 |
+
function tinv_get_option_defaults( $category ) {
|
90 |
+
$dir = TINVWL_PATH . 'admin/settings/';
|
91 |
+
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
92 |
+
return array();
|
93 |
+
}
|
94 |
+
$files = scandir( $dir );
|
95 |
+
foreach ( $files as $key => $value ) {
|
96 |
+
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
97 |
+
$files[ $key ] = preg_replace( '/\.class\.php$/i', '', $value );
|
98 |
+
} else {
|
99 |
+
unset( $files[ $key ] );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
$defaults = array();
|
103 |
+
foreach ( $files as $file ) {
|
104 |
+
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
105 |
+
$class = $class::instance();
|
106 |
+
$class_methods = get_class_methods( $class );
|
107 |
+
foreach ( $class_methods as $method ) {
|
108 |
+
if ( preg_match( '/_data$/i', $method ) ) {
|
109 |
+
$settings = $class->get_defaults( $class->$method() );
|
110 |
+
$defaults = tinv_array_merge( $defaults, $settings );
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
if ( 'all' === $category ) {
|
115 |
+
return $defaults;
|
116 |
+
}
|
117 |
+
if ( array_key_exists( $category, $defaults ) ) {
|
118 |
+
return $defaults[ $category ];
|
119 |
+
}
|
120 |
+
|
121 |
+
return array();
|
122 |
+
}
|
123 |
+
} // End if().
|
124 |
+
|
125 |
+
if ( ! function_exists( 'activation_tinv_wishlist' ) ) {
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Activation plugin
|
129 |
+
*/
|
130 |
+
function activation_tinv_wishlist() {
|
131 |
+
if ( dependency_tinv_wishlist( false ) ) {
|
132 |
+
TInvWL_Activator::activate();
|
133 |
+
flush_rewrite_rules();
|
134 |
+
}
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( ! function_exists( 'deactivation_tinv_wishlist' ) ) {
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Deactivation plugin
|
142 |
+
*/
|
143 |
+
function deactivation_tinv_wishlist() {
|
144 |
+
flush_rewrite_rules();
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Uninstall plugin
|
152 |
+
*/
|
153 |
+
function uninstall_tinv_wishlist() {
|
154 |
+
if ( ! defined( 'TINVWL_LOAD_PREMIUM' ) ) {
|
155 |
+
TInvWL_Activator::uninstall();
|
156 |
+
flush_rewrite_rules();
|
157 |
+
wp_clear_scheduled_hook( 'tinvwl_remove_without_author_wishlist' );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
if ( function_exists( 'spl_autoload_register' ) && ! function_exists( 'autoload_tinv_wishlist' ) ) {
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Autoloader class. If no function spl_autoload_register, then all the files will be required
|
166 |
+
*
|
167 |
+
* @param string $_class Required class name.
|
168 |
+
*
|
169 |
+
* @return boolean
|
170 |
+
*/
|
171 |
+
function autoload_tinv_wishlist( $_class ) {
|
172 |
+
$preffix = 'TInvWL';
|
173 |
+
$ext = '.php';
|
174 |
+
$class = explode( '_', $_class );
|
175 |
+
$object = array_shift( $class );
|
176 |
+
if ( $preffix !== $object ) {
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
if ( empty( $class ) ) {
|
180 |
+
$class = array( $preffix );
|
181 |
+
}
|
182 |
+
$basicclass = $class;
|
183 |
+
array_unshift( $class, 'includes' );
|
184 |
+
$classes = array(
|
185 |
+
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $basicclass ) ),
|
186 |
+
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $class ) ),
|
187 |
+
);
|
188 |
+
|
189 |
+
foreach ( $classes as $class ) {
|
190 |
+
foreach ( array( '.class', '.helper' ) as $suffix ) {
|
191 |
+
$filename = $class . $suffix . $ext;
|
192 |
+
if ( file_exists( $filename ) ) {
|
193 |
+
require_once $filename;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
spl_autoload_register( 'autoload_tinv_wishlist' );
|
202 |
+
} // End if().
|
203 |
+
|
204 |
+
if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Dependency plugin
|
208 |
+
*
|
209 |
+
* @param boolean $run For run hooks dependency or return error message.
|
210 |
+
*
|
211 |
+
* @return boolean
|
212 |
+
*/
|
213 |
+
function dependency_tinv_wishlist( $run = true ) {
|
214 |
+
$ext = new TInvWL_PluginExtend( null, __FILE__, TINVWL_PREFIX );
|
215 |
+
$ext->set_dependency( 'woocommerce/woocommerce.php', 'WooCommerce' )->need();
|
216 |
+
if ( $run ) {
|
217 |
+
$ext->run();
|
218 |
+
}
|
219 |
+
|
220 |
+
return $ext->status_dependency();
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
if ( ! function_exists( 'run_tinv_wishlist' ) ) {
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Run plugin
|
228 |
+
*/
|
229 |
+
function run_tinv_wishlist() {
|
230 |
+
require_once TINVWL_PATH . 'tinv-wishlists-function.php';
|
231 |
+
|
232 |
+
foreach ( glob( TINVWL_PATH . 'integrations' . DIRECTORY_SEPARATOR . '*.php' ) as $file ) {
|
233 |
+
require_once $file;
|
234 |
+
}
|
235 |
+
|
236 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
237 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
238 |
+
}
|
239 |
+
if ( defined( 'TINVWL_LOAD_PREMIUM' ) && defined( 'TINVWL_LOAD_FREE' ) || defined( 'TINVWL_LOAD_PREMIUM' ) && is_plugin_active_for_network( TINVWL_LOAD_PREMIUM ) || defined( 'TINVWL_LOAD_FREE' ) && is_plugin_active_for_network( TINVWL_LOAD_FREE ) ) {
|
240 |
+
$redirect = tinv_wishlist_status( plugin_basename( __FILE__ ) );
|
241 |
+
if ( $redirect ) {
|
242 |
+
header( 'Location: ' . $redirect );
|
243 |
+
exit;
|
244 |
+
}
|
245 |
+
} elseif ( dependency_tinv_wishlist() ) {
|
246 |
+
$plugin = new TInvWL();
|
247 |
+
$plugin->run();
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
register_activation_hook( __FILE__, 'activation_tinv_wishlist' );
|
253 |
+
register_deactivation_hook( __FILE__, 'deactivation_tinv_wishlist' );
|
254 |
+
register_uninstall_hook( __FILE__, 'uninstall_tinv_wishlist' );
|
255 |
+
add_action( 'plugins_loaded', 'run_tinv_wishlist', 20 );
|
tinv-wishlists-function-integration.php
DELETED
@@ -1,2709 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Support functions for other plugins
|
4 |
-
*
|
5 |
-
* @since 1.5.0
|
6 |
-
* @package TInvWishlist
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
if ( ! function_exists( 'tinvwl_rocket_reject_cookies' ) ) {
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Disable cache for WP Rocket
|
18 |
-
*
|
19 |
-
* @param array $cookies Cookies.
|
20 |
-
*
|
21 |
-
* @return array
|
22 |
-
*/
|
23 |
-
function tinvwl_rocket_reject_cookies( $cookies = array() ) {
|
24 |
-
$cookies[] = 'tinv_wishlist';
|
25 |
-
|
26 |
-
return $cookies;
|
27 |
-
}
|
28 |
-
|
29 |
-
add_filter( 'rocket_cache_reject_cookies', 'tinvwl_rocket_reject_cookies' );
|
30 |
-
}
|
31 |
-
|
32 |
-
if ( ! function_exists( 'tinvwl_wp_fastest_cache_reject' ) ) {
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Disable cache for WP Fastest Cache
|
36 |
-
*/
|
37 |
-
function tinvwl_wp_fastest_cache_reject() {
|
38 |
-
if ( defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
|
39 |
-
if ( $rules_json = get_option( 'WpFastestCacheExclude' ) ) {
|
40 |
-
if ( 'null' !== $rules_json ) {
|
41 |
-
$ids = array(
|
42 |
-
tinv_get_option( 'page', 'wishlist' ),
|
43 |
-
tinv_get_option( 'page', 'manage' ),
|
44 |
-
);
|
45 |
-
$pages = $ids;
|
46 |
-
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
47 |
-
'skip_missing' => 0,
|
48 |
-
'orderby' => 'code',
|
49 |
-
) );
|
50 |
-
if ( ! empty( $languages ) ) {
|
51 |
-
foreach ( $ids as $id ) {
|
52 |
-
foreach ( $languages as $l ) {
|
53 |
-
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
54 |
-
}
|
55 |
-
}
|
56 |
-
$pages = array_unique( $pages );
|
57 |
-
}
|
58 |
-
$pages = array_filter( $pages );
|
59 |
-
if ( ! empty( $pages ) ) {
|
60 |
-
foreach ( $pages as $i => $page ) {
|
61 |
-
$pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
62 |
-
}
|
63 |
-
}
|
64 |
-
$pages = array_unique( $pages );
|
65 |
-
$pages = array_filter( $pages );
|
66 |
-
|
67 |
-
$rules_std = json_decode( $rules_json, true );
|
68 |
-
$ex_pages = array();
|
69 |
-
foreach ( $rules_std as $value ) {
|
70 |
-
$value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
|
71 |
-
if ( 'page' === $value['type'] ) {
|
72 |
-
$ex_pages[] = $value['content'];
|
73 |
-
}
|
74 |
-
}
|
75 |
-
$ex_pages = array_unique( $ex_pages );
|
76 |
-
$ex_pages = array_filter( $ex_pages );
|
77 |
-
$changed = false;
|
78 |
-
|
79 |
-
foreach ( $pages as $page ) {
|
80 |
-
$page = preg_replace( '/\/$/', '', $page );
|
81 |
-
|
82 |
-
if ( ! in_array( $page, $ex_pages ) ) {
|
83 |
-
$changed = true;
|
84 |
-
$rules_std[] = array(
|
85 |
-
'prefix' => 'startwith',
|
86 |
-
'content' => $page,
|
87 |
-
'type' => 'page',
|
88 |
-
);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
if ( $changed ) {
|
92 |
-
$data = json_encode( $rules_std );
|
93 |
-
update_option( 'WpFastestCacheExclude', $data );
|
94 |
-
}
|
95 |
-
} // End if().
|
96 |
-
} // End if().
|
97 |
-
} // End if().
|
98 |
-
}
|
99 |
-
|
100 |
-
add_action( 'admin_init', 'tinvwl_wp_fastest_cache_reject' );
|
101 |
-
} // End if().
|
102 |
-
|
103 |
-
if ( function_exists( 'tinvwl_comet_cache_reject' ) ) {
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Set define disabled for Comet Cache
|
107 |
-
*
|
108 |
-
* @param mixed $data Any content.
|
109 |
-
*
|
110 |
-
* @return mixed
|
111 |
-
*/
|
112 |
-
function tinvwl_comet_cache_reject( $data = '' ) {
|
113 |
-
define( 'COMET_CACHE_ALLOWED', false );
|
114 |
-
|
115 |
-
return $data;
|
116 |
-
}
|
117 |
-
|
118 |
-
add_filter( 'tinvwl_addtowishlist_return_ajax', 'tinvwl_comet_cache_reject' );
|
119 |
-
add_action( 'tinvwl_before_action_owner', 'tinvwl_comet_cache_reject' );
|
120 |
-
add_action( 'tinvwl_before_action_user', 'tinvwl_comet_cache_reject' );
|
121 |
-
add_action( 'tinvwl_addproduct_tocart', 'tinvwl_comet_cache_reject' );
|
122 |
-
add_action( 'tinvwl_wishlist_addtowishlist_button', 'tinvwl_comet_cache_reject' );
|
123 |
-
add_action( 'tinvwl_wishlist_addtowishlist_dialogbox', 'tinvwl_comet_cache_reject' );
|
124 |
-
}
|
125 |
-
|
126 |
-
if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
130 |
-
*/
|
131 |
-
function gf_productaddon_support() {
|
132 |
-
if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
|
133 |
-
return false;
|
134 |
-
}
|
135 |
-
if ( ! function_exists( 'gf_productaddon_text_button' ) ) {
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Change text for button add to cart
|
139 |
-
*
|
140 |
-
* @param string $text_add_to_cart Text "Add to cart".
|
141 |
-
* @param array $wl_product Wishlist product.
|
142 |
-
* @param object $product WooCommerce Product.
|
143 |
-
*
|
144 |
-
* @return string
|
145 |
-
*/
|
146 |
-
function gf_productaddon_text_button( $text_add_to_cart, $wl_product, $product ) {
|
147 |
-
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
148 |
-
|
149 |
-
return ( $gravity_form_data ) ? __( 'Select options', 'ti-woocommerce-wishlist' ) : $text_add_to_cart;
|
150 |
-
}
|
151 |
-
|
152 |
-
add_filter( 'tinvwl_wishlist_item_add_to_cart', 'gf_productaddon_text_button', 10, 3 );
|
153 |
-
}
|
154 |
-
|
155 |
-
if ( ! function_exists( 'gf_productaddon_run_action_button' ) ) {
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Check for make redirect to url
|
159 |
-
*
|
160 |
-
* @param boolean $need Need redirect or not.
|
161 |
-
* @param object $product WooCommerce Product.
|
162 |
-
*
|
163 |
-
* @return boolean
|
164 |
-
*/
|
165 |
-
function gf_productaddon_run_action_button( $need, $product ) {
|
166 |
-
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
167 |
-
|
168 |
-
return ( $gravity_form_data ) ? true : $need;
|
169 |
-
}
|
170 |
-
|
171 |
-
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'gf_productaddon_run_action_button', 10, 2 );
|
172 |
-
}
|
173 |
-
|
174 |
-
if ( ! function_exists( 'gf_productaddon_action_button' ) ) {
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Redirect url
|
178 |
-
*
|
179 |
-
* @param string $url Redirect URL.
|
180 |
-
* @param object $product WooCommerce Product.
|
181 |
-
*
|
182 |
-
* @return string
|
183 |
-
*/
|
184 |
-
function gf_productaddon_action_button( $url, $product ) {
|
185 |
-
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
186 |
-
|
187 |
-
return ( $gravity_form_data ) ? $product->get_permalink() : $url;
|
188 |
-
}
|
189 |
-
|
190 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'gf_productaddon_action_button', 10, 2 );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
add_action( 'init', 'gf_productaddon_support' );
|
195 |
-
} // End if().
|
196 |
-
|
197 |
-
if ( ! function_exists( 'tinvwl_wpml_product_get' ) ) {
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Change product data if product need translate
|
201 |
-
*
|
202 |
-
* @param array $product Wishlistl product.
|
203 |
-
*
|
204 |
-
* @return array
|
205 |
-
*/
|
206 |
-
function tinvwl_wpml_product_get( $product ) {
|
207 |
-
if ( array_key_exists( 'data', $product ) ) {
|
208 |
-
$_product_id = $product_id = $product['product_id'];
|
209 |
-
$_variation_id = $variation_id = $product['variation_id'];
|
210 |
-
$_product_id = apply_filters( 'wpml_object_id', $_product_id, 'product', true );
|
211 |
-
if ( ! empty( $_variation_id ) ) {
|
212 |
-
$_variation_id = apply_filters( 'wpml_object_id', $_variation_id, 'product', true );
|
213 |
-
}
|
214 |
-
if ( $_product_id !== $product_id || $_variation_id !== $variation_id ) {
|
215 |
-
$product['data'] = wc_get_product( $variation_id ? $_variation_id : $_product_id );
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
return $product;
|
220 |
-
}
|
221 |
-
|
222 |
-
add_filter( 'tinvwl_wishlist_product_get', 'tinvwl_wpml_product_get' );
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare' ) ) {
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Change product data if product need translate in WooCommerce Multilingual
|
229 |
-
*
|
230 |
-
* @param array $post_data Data for wishlist.
|
231 |
-
*
|
232 |
-
* @return array
|
233 |
-
*/
|
234 |
-
function tinvwl_wpml_addtowishlist_prepare( $post_data ) {
|
235 |
-
if ( class_exists( 'woocommerce_wpml' ) ) {
|
236 |
-
|
237 |
-
global $woocommerce_wpml, $sitepress, $wpdb;
|
238 |
-
|
239 |
-
// Reload products class.
|
240 |
-
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
241 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
242 |
-
} else {
|
243 |
-
global $wpml_post_translations;
|
244 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
245 |
-
}
|
246 |
-
|
247 |
-
if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) ) {
|
248 |
-
$post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id( $post_data['product_id'] );
|
249 |
-
}
|
250 |
-
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'] ) ) {
|
251 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $post_data['product_id'] );
|
252 |
-
$post_data['product_variation'] = apply_filters( 'translate_object_id', $post_data['product_variation'], 'product_variation', true, $original_product_language );
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
return $post_data;
|
257 |
-
}
|
258 |
-
|
259 |
-
add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_wpml_addtowishlist_prepare' );
|
260 |
-
}
|
261 |
-
|
262 |
-
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare' ) ) {
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Change product data if product need translate in WooCommerce Multilingual
|
266 |
-
*
|
267 |
-
* @param array $attr Data for wishlist.
|
268 |
-
*
|
269 |
-
* @return array
|
270 |
-
*/
|
271 |
-
function tinvwl_wpml_addtowishlist_out_prepare( $attr ) {
|
272 |
-
if ( class_exists( 'woocommerce_wpml' ) ) {
|
273 |
-
|
274 |
-
global $woocommerce_wpml, $sitepress, $wpdb;
|
275 |
-
|
276 |
-
// Reload products class.
|
277 |
-
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
278 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
279 |
-
} else {
|
280 |
-
global $wpml_post_translations;
|
281 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
282 |
-
}
|
283 |
-
|
284 |
-
if ( array_key_exists( 'product_id', $attr ) && ! empty( $attr['product_id'] ) ) {
|
285 |
-
$attr['product_id'] = $woocommerce_wpml->products->get_original_product_id( $attr['product_id'] );
|
286 |
-
}
|
287 |
-
if ( array_key_exists( 'product_id', $attr ) && ! empty( $attr['product_id'] ) && array_key_exists( 'variation_id', $attr ) && ! empty( $attr['variation_id'] ) ) {
|
288 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $attr['product_id'] );
|
289 |
-
$attr['variation_id'] = apply_filters( 'translate_object_id', $attr['variation_id'], 'product_variation', true, $original_product_language );
|
290 |
-
}
|
291 |
-
}
|
292 |
-
|
293 |
-
return $attr;
|
294 |
-
}
|
295 |
-
|
296 |
-
add_filter( 'tinvwl_addtowishlist_out_prepare_attr', 'tinvwl_wpml_addtowishlist_out_prepare' );
|
297 |
-
}
|
298 |
-
|
299 |
-
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare_product' ) ) {
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Change product if product need translate in WooCommerce Multilingual
|
303 |
-
*
|
304 |
-
* @param \WC_Product $product WooCommerce Product.
|
305 |
-
*
|
306 |
-
* @return \WC_Product
|
307 |
-
*/
|
308 |
-
function tinvwl_wpml_addtowishlist_out_prepare_product( $product ) {
|
309 |
-
if ( class_exists( 'woocommerce_wpml' ) && is_object( $product ) ) {
|
310 |
-
|
311 |
-
global $woocommerce_wpml, $sitepress, $wpdb;
|
312 |
-
|
313 |
-
// Reload products class.
|
314 |
-
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
315 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
316 |
-
} else {
|
317 |
-
global $wpml_post_translations;
|
318 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
319 |
-
}
|
320 |
-
|
321 |
-
$product_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() );
|
322 |
-
$variation_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 );
|
323 |
-
|
324 |
-
if ( ! empty( $product_id ) ) {
|
325 |
-
$product_id = $woocommerce_wpml->products->get_original_product_id( $product_id );
|
326 |
-
}
|
327 |
-
if ( ! empty( $product_id ) && ! empty( $variation_id ) ) {
|
328 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $product_id );
|
329 |
-
$variation_id = apply_filters( 'translate_object_id', $variation_id, 'product_variation', true, $original_product_language );
|
330 |
-
}
|
331 |
-
if ( ! empty( $product_id ) ) {
|
332 |
-
$product = wc_get_product( $variation_id ? $variation_id : $product_id );
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
return $product;
|
337 |
-
}
|
338 |
-
|
339 |
-
add_filter( 'tinvwl_addtowishlist_out_prepare_product', 'tinvwl_wpml_addtowishlist_out_prepare_product' );
|
340 |
-
}
|
341 |
-
|
342 |
-
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare_form' ) ) {
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Change product form data if product need translate in WooCommerce Multilingual
|
346 |
-
*
|
347 |
-
* @param array $post_data Data for wishlist.
|
348 |
-
*
|
349 |
-
* @return array
|
350 |
-
*/
|
351 |
-
function tinvwl_wpml_addtowishlist_prepare_form( $post_data ) {
|
352 |
-
if ( class_exists( 'woocommerce_wpml' ) && is_array( $post_data ) ) {
|
353 |
-
|
354 |
-
global $woocommerce_wpml, $sitepress, $wpdb;
|
355 |
-
|
356 |
-
// Reload products class.
|
357 |
-
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
358 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
359 |
-
} else {
|
360 |
-
global $wpml_post_translations;
|
361 |
-
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
362 |
-
}
|
363 |
-
|
364 |
-
if ( array_key_exists( 'product_id', $post_data ) && ! empty( $post_data['product_id'] ) ) {
|
365 |
-
$post_data['product_id'] = $woocommerce_wpml->products->get_original_product_id( $post_data['product_id'] );
|
366 |
-
}
|
367 |
-
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'] ) ) {
|
368 |
-
$original_product_language = $woocommerce_wpml->products->get_original_product_language( $post_data['product_id'] );
|
369 |
-
$post_data['variation_id'] = apply_filters( 'translate_object_id', $post_data['variation_id'], 'product_variation', true, $original_product_language );
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
return $post_data;
|
374 |
-
}
|
375 |
-
|
376 |
-
add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_wpml_addtowishlist_prepare_form' );
|
377 |
-
}
|
378 |
-
|
379 |
-
if ( ! function_exists( 'tinvwl_wpml_filter_link' ) ) {
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Correct add wishlist key for WPML plugin.
|
383 |
-
*
|
384 |
-
* @param string $full_link Link for page.
|
385 |
-
* @param array $l Language.
|
386 |
-
*
|
387 |
-
* @return string
|
388 |
-
*/
|
389 |
-
function tinvwl_wpml_filter_link( $full_link, $l ) {
|
390 |
-
$share_key = get_query_var( 'tinvwlID', null );
|
391 |
-
if ( ! empty( $share_key ) ) {
|
392 |
-
if ( get_option( 'permalink_structure' ) ) {
|
393 |
-
$suffix = '';
|
394 |
-
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $full_link, $_full_link ) ) {
|
395 |
-
$full_link = $_full_link[1];
|
396 |
-
$suffix = $_full_link[2];
|
397 |
-
}
|
398 |
-
if ( ! preg_match( '/\/$/', $full_link ) ) {
|
399 |
-
$full_link .= '/';
|
400 |
-
}
|
401 |
-
$full_link .= $share_key . '/' . $suffix;
|
402 |
-
} else {
|
403 |
-
$full_link .= add_query_arg( 'tinvwlID', $share_key, $full_link );
|
404 |
-
}
|
405 |
-
}
|
406 |
-
|
407 |
-
return $full_link;
|
408 |
-
}
|
409 |
-
|
410 |
-
add_filter( 'WPML_filter_link', 'tinvwl_wpml_filter_link', 0, 2 );
|
411 |
-
}
|
412 |
-
|
413 |
-
if ( ! function_exists( 'tinvwl_gift_card_add' ) ) {
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Support WooCommerce - Gift Cards
|
417 |
-
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
418 |
-
*
|
419 |
-
* @param boolean $redirect Default value to redirect.
|
420 |
-
* @param \WC_Product $product Product data.
|
421 |
-
*
|
422 |
-
* @return boolean
|
423 |
-
*/
|
424 |
-
function tinvwl_gift_card_add( $redirect, $product ) {
|
425 |
-
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
426 |
-
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
427 |
-
|
428 |
-
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
429 |
-
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
430 |
-
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
431 |
-
return true;
|
432 |
-
}
|
433 |
-
}
|
434 |
-
}
|
435 |
-
|
436 |
-
return $redirect;
|
437 |
-
}
|
438 |
-
|
439 |
-
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_gift_card_add', 20, 2 );
|
440 |
-
}
|
441 |
-
|
442 |
-
if ( ! function_exists( 'tinvwl_gift_card_add_url' ) ) {
|
443 |
-
|
444 |
-
/**
|
445 |
-
* Support WooCommerce - Gift Cards
|
446 |
-
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
447 |
-
*
|
448 |
-
* @param string $redirect_url Default value to redirect.
|
449 |
-
* @param \WC_Product $product Product data.
|
450 |
-
*
|
451 |
-
* @return boolean
|
452 |
-
*/
|
453 |
-
function tinvwl_gift_card_add_url( $redirect_url, $product ) {
|
454 |
-
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
455 |
-
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
456 |
-
|
457 |
-
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
458 |
-
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
459 |
-
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
460 |
-
return $product->get_permalink();
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
return $redirect_url;
|
466 |
-
}
|
467 |
-
|
468 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinvwl_gift_card_add_url', 20, 2 );
|
469 |
-
}
|
470 |
-
|
471 |
-
if ( ! function_exists( 'tinv_wishlist_meta_support_rpgiftcards' ) ) {
|
472 |
-
|
473 |
-
/**
|
474 |
-
* Set description for meta WooCommerce - Gift Cards
|
475 |
-
*
|
476 |
-
* @param array $meta Meta array.
|
477 |
-
*
|
478 |
-
* @return array
|
479 |
-
*/
|
480 |
-
function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
|
481 |
-
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
482 |
-
foreach ( $meta as $key => $data ) {
|
483 |
-
switch ( $data['key'] ) {
|
484 |
-
case 'rpgc_note':
|
485 |
-
$meta[ $key ]['key'] = __( 'Note', 'ti-woocommerce-wishlist' );
|
486 |
-
break;
|
487 |
-
case 'rpgc_to':
|
488 |
-
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
|
489 |
-
break;
|
490 |
-
case 'rpgc_to_email':
|
491 |
-
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
|
492 |
-
break;
|
493 |
-
case 'rpgc_address':
|
494 |
-
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
|
495 |
-
break;
|
496 |
-
case 'rpgc_reload_card':
|
497 |
-
$meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'ti-woocommerce-wishlist' );
|
498 |
-
break;
|
499 |
-
case 'rpgc_description':
|
500 |
-
case 'rpgc_reload_check':
|
501 |
-
unset( $meta[ $key ] );
|
502 |
-
break;
|
503 |
-
}
|
504 |
-
}
|
505 |
-
}
|
506 |
-
|
507 |
-
return $meta;
|
508 |
-
}
|
509 |
-
|
510 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_rpgiftcards' );
|
511 |
-
} // End if().
|
512 |
-
|
513 |
-
if ( ! function_exists( 'tinv_wishlist_metaprepare_rpgiftcards' ) ) {
|
514 |
-
|
515 |
-
/**
|
516 |
-
* Prepare save meta for WooCommerce - Gift Cards
|
517 |
-
*
|
518 |
-
* @param array $meta Meta array.
|
519 |
-
*
|
520 |
-
* @return array
|
521 |
-
*/
|
522 |
-
function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
|
523 |
-
if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
|
524 |
-
if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
|
525 |
-
foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
|
526 |
-
if ( array_key_exists( $value, $meta ) ) {
|
527 |
-
unset( $meta[ $value ] );
|
528 |
-
}
|
529 |
-
}
|
530 |
-
}
|
531 |
-
}
|
532 |
-
|
533 |
-
return $meta;
|
534 |
-
}
|
535 |
-
|
536 |
-
add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_rpgiftcards' );
|
537 |
-
}
|
538 |
-
|
539 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_bookings' ) ) {
|
540 |
-
|
541 |
-
/**
|
542 |
-
* Set description for meta WooCommerce Bookings
|
543 |
-
*
|
544 |
-
* @param array $meta Meta array.
|
545 |
-
* @param integer $product_id Priduct ID.
|
546 |
-
* @param integer $variation_id Variation Product ID.
|
547 |
-
*
|
548 |
-
* @return array
|
549 |
-
*/
|
550 |
-
function tinv_wishlist_metasupport_woocommerce_bookings( $meta, $product_id, $variation_id ) {
|
551 |
-
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
552 |
-
return $meta;
|
553 |
-
}
|
554 |
-
$product = wc_get_product( $variation_id ? $variation_id : $product_id );
|
555 |
-
if ( is_wc_booking_product( $product ) ) {
|
556 |
-
$booking_form = new WC_Booking_Form( $product );
|
557 |
-
$post_data = array();
|
558 |
-
foreach ( $meta as $data ) {
|
559 |
-
$post_data[ $data['key'] ] = $data['display'];
|
560 |
-
}
|
561 |
-
$booking_data = $booking_form->get_posted_data( $post_data );
|
562 |
-
$meta = array();
|
563 |
-
foreach ( $booking_data as $key => $value ) {
|
564 |
-
if ( ! preg_match( '/^_/', $key ) ) {
|
565 |
-
$meta[ $key ] = array(
|
566 |
-
'key' => get_wc_booking_data_label( $key, $product ),
|
567 |
-
'display' => $value,
|
568 |
-
);
|
569 |
-
}
|
570 |
-
}
|
571 |
-
}
|
572 |
-
|
573 |
-
return $meta;
|
574 |
-
}
|
575 |
-
|
576 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_bookings', 10, 3 );
|
577 |
-
} // End if().
|
578 |
-
|
579 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_bookings' ) ) {
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Modify price for WooCommerce Bookings
|
583 |
-
*
|
584 |
-
* @param string $price Returned price.
|
585 |
-
* @param array $wl_product Wishlist Product.
|
586 |
-
* @param \WC_Product $product Woocommerce Product.
|
587 |
-
*
|
588 |
-
* @return string
|
589 |
-
*/
|
590 |
-
function tinvwl_item_price_woocommerce_bookings( $price, $wl_product, $product ) {
|
591 |
-
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
592 |
-
return $price;
|
593 |
-
}
|
594 |
-
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
595 |
-
$booking_form = new WC_Booking_Form( $product );
|
596 |
-
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
597 |
-
if ( is_wp_error( $cost ) ) {
|
598 |
-
return $price;
|
599 |
-
}
|
600 |
-
|
601 |
-
if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
|
602 |
-
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
603 |
-
$display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
|
604 |
-
} else {
|
605 |
-
$display_price = $product->get_price_including_tax( 1, $cost );
|
606 |
-
}
|
607 |
-
} else {
|
608 |
-
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
609 |
-
$display_price = wc_get_price_excluding_tax( $product, array( 'price' => $cost ) );
|
610 |
-
} else {
|
611 |
-
$display_price = $product->get_price_excluding_tax( 1, $cost );
|
612 |
-
}
|
613 |
-
}
|
614 |
-
|
615 |
-
if ( version_compare( WC_VERSION, '2.4.0', '>=' ) ) {
|
616 |
-
$price_suffix = $product->get_price_suffix( $cost, 1 );
|
617 |
-
} else {
|
618 |
-
$price_suffix = $product->get_price_suffix();
|
619 |
-
}
|
620 |
-
$price = wc_price( $display_price ) . $price_suffix;
|
621 |
-
}
|
622 |
-
|
623 |
-
return $price;
|
624 |
-
}
|
625 |
-
|
626 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_bookings', 10, 3 );
|
627 |
-
} // End if().
|
628 |
-
|
629 |
-
if ( ! function_exists( 'tinvwl_item_status_woocommerce_bookings' ) ) {
|
630 |
-
|
631 |
-
/**
|
632 |
-
* Modify availability for WooCommerce Bookings
|
633 |
-
*
|
634 |
-
* @param string $status Status availability.
|
635 |
-
* @param string $availability Default availability.
|
636 |
-
* @param array $wl_product Wishlist Product.
|
637 |
-
* @param \WC_Product $product Woocommerce Product.
|
638 |
-
*
|
639 |
-
* @return type
|
640 |
-
*/
|
641 |
-
function tinvwl_item_status_woocommerce_bookings( $status, $availability, $wl_product, $product ) {
|
642 |
-
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
643 |
-
return $status;
|
644 |
-
}
|
645 |
-
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
646 |
-
$booking_form = new WC_Booking_Form( $product );
|
647 |
-
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
648 |
-
if ( is_wp_error( $cost ) ) {
|
649 |
-
return '<p class="stock out-of-stock"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . $cost->get_error_message() . '</span></p>';
|
650 |
-
}
|
651 |
-
}
|
652 |
-
|
653 |
-
return $status;
|
654 |
-
}
|
655 |
-
|
656 |
-
add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_woocommerce_bookings', 10, 4 );
|
657 |
-
}
|
658 |
-
|
659 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
|
660 |
-
|
661 |
-
/**
|
662 |
-
* Set description for meta WooCommerce - Gravity Forms Product Add-Ons
|
663 |
-
*
|
664 |
-
* @param array $meta Meta array.
|
665 |
-
*
|
666 |
-
* @return array
|
667 |
-
*/
|
668 |
-
function tinv_wishlist_metasupport_wc_gf_addons( $meta ) {
|
669 |
-
if ( array_key_exists( 'wc_gforms_form_id', $meta ) && class_exists( 'RGFormsModel' ) ) {
|
670 |
-
$form_meta = RGFormsModel::get_form_meta( $meta['wc_gforms_form_id']['display'] );
|
671 |
-
if ( array_key_exists( 'fields', $form_meta ) ) {
|
672 |
-
$_meta = array();
|
673 |
-
foreach ( $form_meta['fields'] as $field ) {
|
674 |
-
$field_name = $field->get_first_input_id( array( 'id' => 0 ) );
|
675 |
-
if ( array_key_exists( $field_name, $meta ) ) {
|
676 |
-
$meta[ $field_name ]['key'] = $field->label;
|
677 |
-
$_meta[ $field_name ] = $meta[ $field_name ];
|
678 |
-
}
|
679 |
-
}
|
680 |
-
$meta = $_meta;
|
681 |
-
}
|
682 |
-
}
|
683 |
-
|
684 |
-
return $meta;
|
685 |
-
}
|
686 |
-
|
687 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_wc_gf_addons' );
|
688 |
-
}
|
689 |
-
|
690 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_composite_products' ) ) {
|
691 |
-
|
692 |
-
/**
|
693 |
-
* Set description for meta WooCommerce Composite Products
|
694 |
-
*
|
695 |
-
* @param array $meta Meta array.
|
696 |
-
* @param integer $product_id Product ID.
|
697 |
-
*
|
698 |
-
* @return array
|
699 |
-
*/
|
700 |
-
function tinv_wishlist_metasupport_woocommerce_composite_products( $meta, $product_id ) {
|
701 |
-
if ( array_key_exists( 'wccp_component_selection', $meta ) && is_array( $meta['wccp_component_selection'] ) ) {
|
702 |
-
$meta = array();
|
703 |
-
} // End if().
|
704 |
-
|
705 |
-
return $meta;
|
706 |
-
}
|
707 |
-
|
708 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_composite_products', 10, 2 );
|
709 |
-
} // End if().
|
710 |
-
|
711 |
-
if ( ! function_exists( 'tinvwl_row_woocommerce_composite_products' ) ) {
|
712 |
-
|
713 |
-
/**
|
714 |
-
* Add rows for sub product for WooCommerce Composite Products
|
715 |
-
*
|
716 |
-
* @param array $wl_product Wishlist Product.
|
717 |
-
* @param \WC_Product_Composite $product Woocommerce Product.
|
718 |
-
*/
|
719 |
-
function tinvwl_row_woocommerce_composite_products( $wl_product, $product ) {
|
720 |
-
if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
|
721 |
-
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
722 |
-
|
723 |
-
$components = $product->get_components();
|
724 |
-
foreach ( $components as $component_id => $component ) {
|
725 |
-
$composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
|
726 |
-
$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' );
|
727 |
-
|
728 |
-
$composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
|
729 |
-
|
730 |
-
if ( $composited_product_id ) {
|
731 |
-
|
732 |
-
$composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
|
733 |
-
|
734 |
-
if ( ! $composited_product_wrapper ) {
|
735 |
-
continue;
|
736 |
-
}
|
737 |
-
|
738 |
-
$composited_product = $composited_product_wrapper->get_product();
|
739 |
-
|
740 |
-
if ( $composited_product->is_sold_individually() && $composited_product_quantity > 1 ) {
|
741 |
-
$composited_product_quantity = 1;
|
742 |
-
}
|
743 |
-
|
744 |
-
$product_url = $composited_product->get_permalink();
|
745 |
-
$product_image = $composited_product->get_image();
|
746 |
-
$product_title = $composited_product->get_title();
|
747 |
-
$product_price = $composited_product->get_price_html();
|
748 |
-
|
749 |
-
$component_option = $product->get_component_option( $component_id, $composited_product_id );
|
750 |
-
|
751 |
-
if ( $component_option ) {
|
752 |
-
if ( false === $component_option->is_priced_individually() && $composited_product->get_price() == 0 ) {
|
753 |
-
$product_price = '';
|
754 |
-
} elseif ( false === $component_option->get_component()->is_subtotal_visible( 'cart' ) ) {
|
755 |
-
$product_price = '';
|
756 |
-
} elseif ( apply_filters( 'woocommerce_add_composited_cart_item_prices', true ) ) {
|
757 |
-
if ( $product_price ) {
|
758 |
-
$product_price = '<span class="component_table_item_price">' . $product_price . '</span>';
|
759 |
-
}
|
760 |
-
}
|
761 |
-
}
|
762 |
-
|
763 |
-
|
764 |
-
if ( $composited_product->is_visible() ) {
|
765 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
766 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
767 |
-
}
|
768 |
-
$product_title .= tinv_wishlist_get_item_data( $composited_product, $wl_product );
|
769 |
-
|
770 |
-
$availability = (array) $composited_product->get_availability();
|
771 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
772 |
-
$availability['availability'] = '';
|
773 |
-
}
|
774 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
775 |
-
$availability['class'] = '';
|
776 |
-
}
|
777 |
-
$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>';
|
778 |
-
$row_string = '<tr>';
|
779 |
-
$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>';
|
780 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
781 |
-
$row_string .= ( $product_price ) ? '<td class="product-price">%4$s × %6$s</td>' : '<td class="product-price">%4$s</td>';
|
782 |
-
}
|
783 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
784 |
-
$row_string .= '<td class="product-date"> </td>';
|
785 |
-
}
|
786 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
787 |
-
$row_string .= '<td class="product-stock">%5$s</td>';
|
788 |
-
}
|
789 |
-
if ( tinv_get_option( 'product_table', 'colm_quantity' ) ) {
|
790 |
-
$row_string .= '<td class="product-quantity"> </td>';
|
791 |
-
}
|
792 |
-
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
793 |
-
$row_string .= '<td class="product-action"> </td>';
|
794 |
-
}
|
795 |
-
$row_string .= '</tr>';
|
796 |
-
|
797 |
-
echo sprintf( $row_string, $component->get_title(), $product_image, $product_title, $product_price, $availability_html, $composited_product_quantity * $product_quantity ); // WPCS: xss ok.
|
798 |
-
} // End if().
|
799 |
-
} // End foreach().
|
800 |
-
} // End if().
|
801 |
-
}
|
802 |
-
|
803 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_composite_products', 10, 2 );
|
804 |
-
} // End if().
|
805 |
-
|
806 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_composite_products' ) ) {
|
807 |
-
|
808 |
-
/**
|
809 |
-
* Modify price for WooCommerce Composite Products
|
810 |
-
*
|
811 |
-
* @param string $price Returned price.
|
812 |
-
* @param array $wl_product Wishlist Product.
|
813 |
-
* @param \WC_Product $product Woocommerce Product.
|
814 |
-
*
|
815 |
-
* @return string
|
816 |
-
*/
|
817 |
-
function tinvwl_item_price_woocommerce_composite_products( $price, $wl_product, $product ) {
|
818 |
-
if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
|
819 |
-
$components = $product->get_components();
|
820 |
-
$_price = $product->get_price();
|
821 |
-
$regular_price = $product->get_regular_price();
|
822 |
-
foreach ( $components as $component_id => $component ) {
|
823 |
-
$composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
|
824 |
-
$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' );
|
825 |
-
|
826 |
-
$composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
|
827 |
-
|
828 |
-
if ( $composited_product_id ) {
|
829 |
-
$composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
|
830 |
-
if ( $component->is_priced_individually() ) {
|
831 |
-
$_price += $composited_product_wrapper->get_price() * $composited_product_quantity;
|
832 |
-
$regular_price += $composited_product_wrapper->get_regular_price() * $composited_product_quantity;
|
833 |
-
}
|
834 |
-
}
|
835 |
-
}
|
836 |
-
if ( $_price == $regular_price ) {
|
837 |
-
$price = wc_price( $_price ) . $product->get_price_suffix();
|
838 |
-
} else {
|
839 |
-
$price = wc_format_sale_price( $regular_price, $_price ) . $product->get_price_suffix();
|
840 |
-
}
|
841 |
-
}
|
842 |
-
|
843 |
-
return $price;
|
844 |
-
}
|
845 |
-
|
846 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_composite_products', 10, 3 );
|
847 |
-
} // End if().
|
848 |
-
|
849 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_bundles' ) ) {
|
850 |
-
|
851 |
-
/**
|
852 |
-
* Set description for meta WooCommerce Product Bundles
|
853 |
-
*
|
854 |
-
* @param array $meta Meta array.
|
855 |
-
* @param integer $product_id Product ID.
|
856 |
-
*
|
857 |
-
* @return array
|
858 |
-
*/
|
859 |
-
function tinv_wishlist_metasupport_woocommerce_product_bundles( $meta, $product_id ) {
|
860 |
-
$product = wc_get_product( $product_id );
|
861 |
-
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
862 |
-
$meta = array();
|
863 |
-
}
|
864 |
-
|
865 |
-
return $meta;
|
866 |
-
}
|
867 |
-
|
868 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_bundles', 10, 2 );
|
869 |
-
} // End if().
|
870 |
-
|
871 |
-
if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
|
872 |
-
|
873 |
-
/**
|
874 |
-
* Add rows for sub product for WooCommerce Product Bundles
|
875 |
-
*
|
876 |
-
* @param array $wl_product Wishlist Product.
|
877 |
-
* @param \WC_Product $product Woocommerce Product.
|
878 |
-
*/
|
879 |
-
function tinvwl_row_woocommerce_product_bundles( $wl_product, $product ) {
|
880 |
-
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
881 |
-
|
882 |
-
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
883 |
-
$bundled_items = $product->get_bundled_items();
|
884 |
-
if ( ! empty( $bundled_items ) ) {
|
885 |
-
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
886 |
-
|
887 |
-
$bundled_item_variation_id_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_variation_id_' . $bundled_item_id;
|
888 |
-
$bundled_variation_id = absint( isset( $wl_product['meta'][ $bundled_item_variation_id_request_key ] ) ? $wl_product['meta'][ $bundled_item_variation_id_request_key ] : 0 );
|
889 |
-
if ( ! empty( $bundled_variation_id ) ) {
|
890 |
-
$bundled_item->product = wc_get_product( $bundled_variation_id );
|
891 |
-
}
|
892 |
-
|
893 |
-
$is_optional = $bundled_item->is_optional();
|
894 |
-
|
895 |
-
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
896 |
-
$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();
|
897 |
-
|
898 |
-
if ( $is_optional ) {
|
899 |
-
|
900 |
-
/** Documented in method 'get_posted_bundle_configuration'. */
|
901 |
-
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
902 |
-
|
903 |
-
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
904 |
-
$bundled_product_qty = 0;
|
905 |
-
}
|
906 |
-
}
|
907 |
-
if ( 0 === $bundled_product_qty || 'visible' != $bundled_item->cart_visibility ) {
|
908 |
-
continue;
|
909 |
-
}
|
910 |
-
|
911 |
-
$product_url = $bundled_item->product->get_permalink();
|
912 |
-
$product_image = $bundled_item->product->get_image();
|
913 |
-
$product_title = $bundled_item->has_title_override() ? $bundled_item->get_title() : $bundled_item->get_raw_title();
|
914 |
-
|
915 |
-
$product_price = $bundled_item->product->get_price_html();
|
916 |
-
$product_price_raw = $bundled_item->product->get_regular_price();
|
917 |
-
$discount = $bundled_item->get_discount();
|
918 |
-
$product_price = empty( $discount ) ? $product_price : wc_price( WC_PB_Product_Prices::get_discounted_price( $product_price_raw, $discount ) );
|
919 |
-
|
920 |
-
if ( $bundled_item->product->is_visible() ) {
|
921 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
922 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
923 |
-
}
|
924 |
-
$product_title .= tinv_wishlist_get_item_data( $bundled_item->product, $wl_product );
|
925 |
-
|
926 |
-
$availability = (array) $bundled_item->product->get_availability();
|
927 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
928 |
-
$availability['availability'] = '';
|
929 |
-
}
|
930 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
931 |
-
$availability['class'] = '';
|
932 |
-
}
|
933 |
-
$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>';
|
934 |
-
$row_string = '<tr>';
|
935 |
-
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
936 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) && $bundled_item->is_priced_individually() ) {
|
937 |
-
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
938 |
-
} elseif ( ! $bundled_item->is_priced_individually() ) {
|
939 |
-
$row_string .= '<td class="product-price"></td>';
|
940 |
-
}
|
941 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
942 |
-
$row_string .= '<td class="product-date"> </td>';
|
943 |
-
}
|
944 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
945 |
-
$row_string .= '<td class="product-stock">%4$s</td>';
|
946 |
-
}
|
947 |
-
|
948 |
-
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
949 |
-
$row_string .= '<td class="product-action"> </td>';
|
950 |
-
}
|
951 |
-
$row_string .= '</tr>';
|
952 |
-
|
953 |
-
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty ); // WPCS: xss ok.
|
954 |
-
} // End foreach().
|
955 |
-
} // End if().
|
956 |
-
} // End if().
|
957 |
-
}
|
958 |
-
|
959 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_product_bundles', 10, 2 );
|
960 |
-
} // End if().
|
961 |
-
|
962 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
|
963 |
-
|
964 |
-
/**
|
965 |
-
* Modify price for WooCommerce Product Bundles
|
966 |
-
*
|
967 |
-
* @param string $price Returned price.
|
968 |
-
* @param array $wl_product Wishlist Product.
|
969 |
-
* @param \WC_Product $product Woocommerce Product.
|
970 |
-
*
|
971 |
-
* @return string
|
972 |
-
*/
|
973 |
-
function tinvwl_item_price_woocommerce_product_bundles( $price, $wl_product, $product ) {
|
974 |
-
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
975 |
-
|
976 |
-
$bundle_price = $product->get_price();
|
977 |
-
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
978 |
-
$bundled_items = $product->get_bundled_items();
|
979 |
-
|
980 |
-
if ( ! empty( $bundled_items ) ) {
|
981 |
-
|
982 |
-
$bundled_items_price = 0.0;
|
983 |
-
|
984 |
-
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
985 |
-
|
986 |
-
$bundled_item_variation_id_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_variation_id_' . $bundled_item_id;
|
987 |
-
$bundled_variation_id = absint( isset( $wl_product['meta'][ $bundled_item_variation_id_request_key ] ) ? $wl_product['meta'][ $bundled_item_variation_id_request_key ] : 0 );
|
988 |
-
if ( ! empty( $bundled_variation_id ) ) {
|
989 |
-
$_bundled_product = wc_get_product( $bundled_variation_id );
|
990 |
-
} else {
|
991 |
-
$_bundled_product = $bundled_item->product;
|
992 |
-
}
|
993 |
-
|
994 |
-
$is_optional = $bundled_item->is_optional();
|
995 |
-
|
996 |
-
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
997 |
-
$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();
|
998 |
-
|
999 |
-
if ( $is_optional ) {
|
1000 |
-
|
1001 |
-
/** Documented in method 'get_posted_bundle_configuration'. */
|
1002 |
-
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
1003 |
-
|
1004 |
-
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
1005 |
-
$bundled_product_qty = 0;
|
1006 |
-
}
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
if ( $bundled_item->is_priced_individually() ) {
|
1010 |
-
$product_price = $_bundled_product->get_regular_price();
|
1011 |
-
|
1012 |
-
$discount = $bundled_item->get_discount();
|
1013 |
-
$product_price = empty( $discount ) ? $product_price : WC_PB_Product_Prices::get_discounted_price( $product_price, $discount );
|
1014 |
-
|
1015 |
-
$bundled_item_price = $product_price * $bundled_product_qty;
|
1016 |
-
|
1017 |
-
$bundled_items_price += (double) $bundled_item_price;
|
1018 |
-
}
|
1019 |
-
|
1020 |
-
} // End foreach().
|
1021 |
-
$price = wc_price( (double) $bundle_price + $bundled_items_price );
|
1022 |
-
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
1023 |
-
} // End if().
|
1024 |
-
} // End if().
|
1025 |
-
|
1026 |
-
return $price;
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_bundles', 10, 3 );
|
1030 |
-
} // End if().
|
1031 |
-
|
1032 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products' ) ) {
|
1033 |
-
|
1034 |
-
/**
|
1035 |
-
* Set description for meta WooCommerce Mix and Match
|
1036 |
-
*
|
1037 |
-
* @param array $meta Meta array.
|
1038 |
-
* @param integer $product_id Product ID.
|
1039 |
-
*
|
1040 |
-
* @return array
|
1041 |
-
*/
|
1042 |
-
function tinv_wishlist_metasupport_woocommerce_mix_and_match_products( $meta, $product_id ) {
|
1043 |
-
if ( array_key_exists( 'mnm_quantity', $meta ) ) {
|
1044 |
-
$product = wc_get_product( $product_id );
|
1045 |
-
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) ) {
|
1046 |
-
$meta = array();
|
1047 |
-
}
|
1048 |
-
}
|
1049 |
-
|
1050 |
-
return $meta;
|
1051 |
-
}
|
1052 |
-
|
1053 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products', 10, 2 );
|
1054 |
-
} // End if().
|
1055 |
-
|
1056 |
-
if ( ! function_exists( 'tinvwl_row_woocommerce_mix_and_match_products' ) ) {
|
1057 |
-
|
1058 |
-
/**
|
1059 |
-
* Add rows for sub product for WooCommerce Mix and Match
|
1060 |
-
*
|
1061 |
-
* @param array $wl_product Wishlist Product.
|
1062 |
-
* @param \WC_Product $product Woocommerce Product.
|
1063 |
-
*/
|
1064 |
-
function tinvwl_row_woocommerce_mix_and_match_products( $wl_product, $product ) {
|
1065 |
-
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && array_key_exists( 'mnm_quantity', $wl_product['meta'] ) ) {
|
1066 |
-
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
1067 |
-
$mnm_items = $product->get_children();
|
1068 |
-
if ( ! empty( $mnm_items ) ) {
|
1069 |
-
foreach ( $mnm_items as $id => $mnm_item ) {
|
1070 |
-
$item_quantity = 0;
|
1071 |
-
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
1072 |
-
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
1073 |
-
}
|
1074 |
-
if ( 0 >= $item_quantity ) {
|
1075 |
-
continue;
|
1076 |
-
}
|
1077 |
-
|
1078 |
-
$product_url = $mnm_item->get_permalink();
|
1079 |
-
$product_image = $mnm_item->get_image();
|
1080 |
-
$product_title = $mnm_item->get_title();
|
1081 |
-
$product_price = $mnm_item->get_price_html();
|
1082 |
-
if ( $mnm_item->is_visible() ) {
|
1083 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
1084 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
1085 |
-
}
|
1086 |
-
$product_title .= tinv_wishlist_get_item_data( $mnm_item, $wl_product );
|
1087 |
-
|
1088 |
-
$availability = (array) $mnm_item->get_availability();
|
1089 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
1090 |
-
$availability['availability'] = '';
|
1091 |
-
}
|
1092 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
1093 |
-
$availability['class'] = '';
|
1094 |
-
}
|
1095 |
-
$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>';
|
1096 |
-
$row_string = '<tr>';
|
1097 |
-
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
1098 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
1099 |
-
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
1100 |
-
}
|
1101 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
1102 |
-
$row_string .= '<td class="product-date"> </td>';
|
1103 |
-
}
|
1104 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
1105 |
-
$row_string .= '<td class="product-stock">%4$s</td>';
|
1106 |
-
}
|
1107 |
-
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
1108 |
-
$row_string .= '<td class="product-action"> </td>';
|
1109 |
-
}
|
1110 |
-
$row_string .= '</tr>';
|
1111 |
-
|
1112 |
-
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
|
1113 |
-
} // End foreach().
|
1114 |
-
} // End if().
|
1115 |
-
} // End if().
|
1116 |
-
}
|
1117 |
-
|
1118 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_mix_and_match_products', 10, 2 );
|
1119 |
-
} // End if().
|
1120 |
-
|
1121 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' ) ) {
|
1122 |
-
|
1123 |
-
/**
|
1124 |
-
* Modify price for WooCommerce Mix and Match
|
1125 |
-
*
|
1126 |
-
* @param string $price Returned price.
|
1127 |
-
* @param array $wl_product Wishlist Product.
|
1128 |
-
* @param \WC_Product $product Woocommerce Product.
|
1129 |
-
*
|
1130 |
-
* @return string
|
1131 |
-
*/
|
1132 |
-
function tinvwl_item_price_woocommerce_mix_and_match_products( $price, $wl_product, $product ) {
|
1133 |
-
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && $product->is_priced_per_product() ) {
|
1134 |
-
$mnm_items = $product->get_children();
|
1135 |
-
if ( ! empty( $mnm_items ) ) {
|
1136 |
-
$_price = 0;
|
1137 |
-
foreach ( $mnm_items as $id => $mnm_item ) {
|
1138 |
-
$item_quantity = 0;
|
1139 |
-
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
1140 |
-
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
1141 |
-
}
|
1142 |
-
if ( 0 >= $item_quantity ) {
|
1143 |
-
continue;
|
1144 |
-
}
|
1145 |
-
$_price += wc_get_price_to_display( $mnm_item, array( 'qty' => $item_quantity ) );
|
1146 |
-
}
|
1147 |
-
if ( 0 < $_price ) {
|
1148 |
-
if ( $product->is_on_sale() ) {
|
1149 |
-
$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();
|
1150 |
-
} else {
|
1151 |
-
$price = wc_price( $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
|
1152 |
-
}
|
1153 |
-
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
1154 |
-
}
|
1155 |
-
}
|
1156 |
-
}
|
1157 |
-
|
1158 |
-
return $price;
|
1159 |
-
}
|
1160 |
-
|
1161 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_mix_and_match_products', 10, 3 );
|
1162 |
-
} // End if().
|
1163 |
-
|
1164 |
-
if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) ) {
|
1165 |
-
|
1166 |
-
/**
|
1167 |
-
* Remove empty meta for WooCommerce Mix and Match
|
1168 |
-
*
|
1169 |
-
* @param array $form Post form data.
|
1170 |
-
*
|
1171 |
-
* @return array
|
1172 |
-
*/
|
1173 |
-
function tinvwl_add_form_woocommerce_mix_and_match_products( $form = array() ) {
|
1174 |
-
if ( array_key_exists( 'mnm_quantity', $form ) ) {
|
1175 |
-
if ( is_array( $form['mnm_quantity'] ) && ! empty( $form['mnm_quantity'] ) ) {
|
1176 |
-
foreach ( $form['mnm_quantity'] as $key => $value ) {
|
1177 |
-
$value = absint( $value );
|
1178 |
-
if ( empty( $value ) ) {
|
1179 |
-
unset( $form['mnm_quantity'][ $key ] );
|
1180 |
-
}
|
1181 |
-
}
|
1182 |
-
if ( empty( $form['mnm_quantity'] ) ) {
|
1183 |
-
unset( $form['mnm_quantity'] );
|
1184 |
-
}
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
return $form;
|
1189 |
-
}
|
1190 |
-
|
1191 |
-
add_filter( 'tinvwl_addtowishlist_add_form', 'tinvwl_add_form_woocommerce_mix_and_match_products' );
|
1192 |
-
} // End if().
|
1193 |
-
|
1194 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles' ) ) {
|
1195 |
-
|
1196 |
-
/**
|
1197 |
-
* Set description for meta WooCommerce Mix and Match
|
1198 |
-
*
|
1199 |
-
* @param array $meta Meta array.
|
1200 |
-
* @param integer $product_id Product ID.
|
1201 |
-
*
|
1202 |
-
* @return array
|
1203 |
-
*/
|
1204 |
-
function tinv_wishlist_metasupport_yith_woocommerce_product_bundles( $meta, $product_id ) {
|
1205 |
-
if ( array_key_exists( 'yith_bundle_quantity_1', $meta ) ) {
|
1206 |
-
$product = wc_get_product( $product_id );
|
1207 |
-
if ( is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
|
1208 |
-
$meta = array();
|
1209 |
-
}
|
1210 |
-
}
|
1211 |
-
|
1212 |
-
return $meta;
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_yith_woocommerce_product_bundles', 10, 2 );
|
1216 |
-
} // End if().
|
1217 |
-
|
1218 |
-
if ( ! function_exists( 'tinvwl_item_status_yith_woocommerce_product_bundles' ) ) {
|
1219 |
-
|
1220 |
-
/**
|
1221 |
-
* Modify status for YITH WooCommerce Product Bundles
|
1222 |
-
*
|
1223 |
-
* @param string $availability_html Returned availability status.
|
1224 |
-
* @param string $availability Availability status.
|
1225 |
-
* @param array $wl_product Wishlist Product.
|
1226 |
-
* @param \WC_Product $product Woocommerce Product.
|
1227 |
-
*
|
1228 |
-
* @return string
|
1229 |
-
*/
|
1230 |
-
function tinvwl_item_status_yith_woocommerce_product_bundles( $availability_html, $availability, $wl_product, $product ) {
|
1231 |
-
if ( empty( $availability ) && is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
|
1232 |
-
$response = true;
|
1233 |
-
$bundled_items = $product->get_bundled_items();
|
1234 |
-
foreach ( $bundled_items as $key => $bundled_item ) {
|
1235 |
-
if ( method_exists( $bundled_item, 'is_optional' ) ) {
|
1236 |
-
if ( $bundled_item->is_optional() && ! array_key_exists( 'yith_bundle_optional_' . $key, $wl_product['meta'] ) ) {
|
1237 |
-
continue;
|
1238 |
-
}
|
1239 |
-
}
|
1240 |
-
if ( ! $bundled_item->get_product()->is_in_stock() ) {
|
1241 |
-
$response = false;
|
1242 |
-
}
|
1243 |
-
}
|
1244 |
-
|
1245 |
-
if ( ! $response ) {
|
1246 |
-
$availability = array(
|
1247 |
-
'class' => 'out-of-stock',
|
1248 |
-
'availability' => __( 'Out of stock', 'ti-woocommerce-wishlist' ),
|
1249 |
-
);
|
1250 |
-
$availability_html = '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="ftinvwl ftinvwl-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
1251 |
-
}
|
1252 |
-
}
|
1253 |
-
|
1254 |
-
return $availability_html;
|
1255 |
-
}
|
1256 |
-
|
1257 |
-
add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_yith_woocommerce_product_bundles', 10, 4 );
|
1258 |
-
} // End if().
|
1259 |
-
|
1260 |
-
if ( ! function_exists( 'tinvwl_row_yith_woocommerce_product_bundles' ) ) {
|
1261 |
-
|
1262 |
-
/**
|
1263 |
-
* Add rows for sub product for YITH WooCommerce Product Bundles
|
1264 |
-
*
|
1265 |
-
* @param array $wl_product Wishlist Product.
|
1266 |
-
* @param \WC_Product $product Woocommerce Product.
|
1267 |
-
*/
|
1268 |
-
function tinvwl_row_yith_woocommerce_product_bundles( $wl_product, $product ) {
|
1269 |
-
if ( is_object( $product ) && $product->is_type( 'yith_bundle' ) ) {
|
1270 |
-
$bundled_items = $product->get_bundled_items();
|
1271 |
-
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
1272 |
-
if ( ! empty( $bundled_items ) ) {
|
1273 |
-
foreach ( $bundled_items as $key => $bundled_item ) {
|
1274 |
-
$item_quantity = $bundled_item->get_quantity();
|
1275 |
-
if ( array_key_exists( 'yith_bundle_quantity_' . $key, $wl_product['meta'] ) ) {
|
1276 |
-
$item_quantity = absint( $wl_product['meta'][ 'yith_bundle_quantity_' . $key ] );
|
1277 |
-
}
|
1278 |
-
if ( method_exists( $bundled_item, 'is_optional' ) ) {
|
1279 |
-
if ( $bundled_item->is_optional() && ! array_key_exists( 'yith_bundle_optional_' . $key, $wl_product['meta'] ) ) {
|
1280 |
-
$item_quantity = 0;
|
1281 |
-
}
|
1282 |
-
}
|
1283 |
-
if ( 0 >= $item_quantity ) {
|
1284 |
-
continue;
|
1285 |
-
}
|
1286 |
-
|
1287 |
-
$product = $bundled_item->get_product();
|
1288 |
-
if ( ! is_object( $product ) ) {
|
1289 |
-
continue;
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
$product_url = $product->get_permalink();
|
1293 |
-
$product_image = $product->get_image();
|
1294 |
-
$product_title = $product->get_title();
|
1295 |
-
$product_price = $product->get_price_html();
|
1296 |
-
if ( $product->is_visible() ) {
|
1297 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
1298 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
1299 |
-
}
|
1300 |
-
$product_title .= tinv_wishlist_get_item_data( $product, $wl_product );
|
1301 |
-
|
1302 |
-
$availability = (array) $product->get_availability();
|
1303 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
1304 |
-
$availability['availability'] = '';
|
1305 |
-
}
|
1306 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
1307 |
-
$availability['class'] = '';
|
1308 |
-
}
|
1309 |
-
$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>';
|
1310 |
-
$row_string = '<tr>';
|
1311 |
-
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
1312 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
1313 |
-
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
1314 |
-
}
|
1315 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
1316 |
-
$row_string .= '<td class="product-date"> </td>';
|
1317 |
-
}
|
1318 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
1319 |
-
$row_string .= '<td class="product-stock">%4$s</td>';
|
1320 |
-
}
|
1321 |
-
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
1322 |
-
$row_string .= '<td class="product-action"> </td>';
|
1323 |
-
}
|
1324 |
-
$row_string .= '</tr>';
|
1325 |
-
|
1326 |
-
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
|
1327 |
-
} // End foreach().
|
1328 |
-
} // End if().
|
1329 |
-
} // End if().
|
1330 |
-
}
|
1331 |
-
|
1332 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_yith_woocommerce_product_bundles', 10, 2 );
|
1333 |
-
} // End if().
|
1334 |
-
|
1335 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_add_on' ) ) {
|
1336 |
-
|
1337 |
-
/**
|
1338 |
-
* Set description for meta WooCommerce Product Add-on
|
1339 |
-
*
|
1340 |
-
* @param array $meta Meta array.
|
1341 |
-
* @param integer $product_id Product ID.
|
1342 |
-
*
|
1343 |
-
* @return array
|
1344 |
-
*/
|
1345 |
-
function tinv_wishlist_metasupport_woocommerce_product_add_on( $meta, $product_id ) {
|
1346 |
-
if ( isset( $meta['ppom'] ) ) {
|
1347 |
-
$meta = array();
|
1348 |
-
}
|
1349 |
-
|
1350 |
-
return $meta;
|
1351 |
-
}
|
1352 |
-
|
1353 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_add_on', 10, 2 );
|
1354 |
-
} // End if().
|
1355 |
-
|
1356 |
-
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_add_on' ) ) {
|
1357 |
-
|
1358 |
-
/**
|
1359 |
-
* Set description for meta WooCommerce Product Add-on
|
1360 |
-
*
|
1361 |
-
* @param array $meta Meta array.
|
1362 |
-
* @param array $wl_product Wishlist Product.
|
1363 |
-
* @param \WC_Product $product Woocommerce Product.
|
1364 |
-
*
|
1365 |
-
* @return array
|
1366 |
-
*/
|
1367 |
-
function tinv_wishlist_item_meta_woocommerce_product_add_on( $meta, $wl_product, $product ) {
|
1368 |
-
if ( isset( $wl_product['meta'] ) && isset( $wl_product['meta']['ppom'] ) && class_exists( 'NM_PersonalizedProduct' ) ) {
|
1369 |
-
$product_meta = ( isset( $wl_product['meta']['ppom'] ) ) ? $wl_product['meta']['ppom']['fields'] : '';
|
1370 |
-
|
1371 |
-
$item_meta = array();
|
1372 |
-
|
1373 |
-
if ( $product_meta ) {
|
1374 |
-
|
1375 |
-
foreach ( $product_meta as $key => $value ) {
|
1376 |
-
|
1377 |
-
if ( empty( $value ) ) {
|
1378 |
-
continue;
|
1379 |
-
}
|
1380 |
-
|
1381 |
-
$product_id = $wl_product['product_id'];
|
1382 |
-
$field_meta = ppom_get_field_meta_by_dataname( $product_id, $key );
|
1383 |
-
|
1384 |
-
if ( empty( $field_meta ) ) {
|
1385 |
-
continue;
|
1386 |
-
}
|
1387 |
-
|
1388 |
-
$field_type = $field_meta['type'];
|
1389 |
-
$field_title = $field_meta['title'];
|
1390 |
-
|
1391 |
-
|
1392 |
-
switch ( $field_type ) {
|
1393 |
-
case 'quantities':
|
1394 |
-
$total_qty = 0;
|
1395 |
-
foreach ( $value as $label => $qty ) {
|
1396 |
-
if ( ! empty( $qty ) ) {
|
1397 |
-
$item_meta[] = array(
|
1398 |
-
'key' => $label,
|
1399 |
-
'display' => $qty,
|
1400 |
-
);
|
1401 |
-
$total_qty += $qty;
|
1402 |
-
}
|
1403 |
-
}
|
1404 |
-
break;
|
1405 |
-
|
1406 |
-
case 'file':
|
1407 |
-
$file_thumbs_html = '';
|
1408 |
-
foreach ( $value as $file_id => $file_uploaded ) {
|
1409 |
-
$file_name = $file_uploaded['org'];
|
1410 |
-
$file_thumbs_html .= ppom_show_file_thumb( $file_name );
|
1411 |
-
}
|
1412 |
-
$item_meta[] = array(
|
1413 |
-
'key' => $field_title,
|
1414 |
-
'display' => $file_thumbs_html,
|
1415 |
-
);
|
1416 |
-
|
1417 |
-
break;
|
1418 |
-
|
1419 |
-
case 'cropper':
|
1420 |
-
$file_thumbs_html = '';
|
1421 |
-
foreach ( $value as $file_id => $file_cropped ) {
|
1422 |
-
|
1423 |
-
$file_name = $file_cropped['org'];
|
1424 |
-
$file_thumbs_html .= ppom_show_file_thumb( $file_name, true );
|
1425 |
-
}
|
1426 |
-
$item_meta[] = array(
|
1427 |
-
'key' => $field_title,
|
1428 |
-
'display' => $file_thumbs_html,
|
1429 |
-
);
|
1430 |
-
break;
|
1431 |
-
|
1432 |
-
case 'image':
|
1433 |
-
if ( $value ) {
|
1434 |
-
foreach ( $value as $id => $images_meta ) {
|
1435 |
-
$images_meta = json_decode( stripslashes( $images_meta ), true );
|
1436 |
-
$image_url = stripslashes( $images_meta['link'] );
|
1437 |
-
$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'] ) . '">';
|
1438 |
-
$meta_key = $field_title . '(' . $images_meta['title'] . ')';
|
1439 |
-
$item_meta[] = array(
|
1440 |
-
'key' => $meta_key,
|
1441 |
-
'display' => $image_html,
|
1442 |
-
);
|
1443 |
-
}
|
1444 |
-
}
|
1445 |
-
break;
|
1446 |
-
|
1447 |
-
case 'audio':
|
1448 |
-
if ( $value ) {
|
1449 |
-
$ppom_file_count = 1;
|
1450 |
-
foreach ( $value as $id => $audio_meta ) {
|
1451 |
-
$audio_meta = json_decode( stripslashes( $audio_meta ), true );
|
1452 |
-
$audio_url = stripslashes( $audio_meta['link'] );
|
1453 |
-
$audio_html = '<a href="' . esc_url( $audio_url ) . '" title="' . esc_attr( $audio_meta['title'] ) . '">' . $audio_meta['title'] . '</a>';
|
1454 |
-
$meta_key = $field_title . ': ' . $ppom_file_count ++;
|
1455 |
-
$item_meta[] = array(
|
1456 |
-
'key' => $meta_key,
|
1457 |
-
'display' => $audio_html,
|
1458 |
-
);
|
1459 |
-
}
|
1460 |
-
}
|
1461 |
-
break;
|
1462 |
-
|
1463 |
-
case 'bulkquantity':
|
1464 |
-
$item_meta[] = array(
|
1465 |
-
'key' => $key,
|
1466 |
-
'display' => $value['option'] . ' (' . $value['qty'] . ')',
|
1467 |
-
);
|
1468 |
-
break;
|
1469 |
-
|
1470 |
-
default:
|
1471 |
-
$value = is_array( $value ) ? implode( ",", $value ) : $value;
|
1472 |
-
$item_meta[] = array(
|
1473 |
-
'key' => $field_title,
|
1474 |
-
'display' => stripcslashes( $value ),
|
1475 |
-
);
|
1476 |
-
break;
|
1477 |
-
}
|
1478 |
-
|
1479 |
-
} // End foreach().
|
1480 |
-
} // End if().
|
1481 |
-
|
1482 |
-
if ( 0 < count( $item_meta ) ) {
|
1483 |
-
ob_start();
|
1484 |
-
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_meta ) );
|
1485 |
-
$meta .= ob_get_clean();
|
1486 |
-
}
|
1487 |
-
} // End if().
|
1488 |
-
|
1489 |
-
return $meta;
|
1490 |
-
}
|
1491 |
-
|
1492 |
-
add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlist_item_meta_woocommerce_product_add_on', 10, 3 );
|
1493 |
-
} // End if().
|
1494 |
-
|
1495 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options' ) ) {
|
1496 |
-
|
1497 |
-
/**
|
1498 |
-
* Set description for meta WooCommerce TM Extra Product Options
|
1499 |
-
*
|
1500 |
-
* @param array $meta Meta array.
|
1501 |
-
* @param integer $product_id Product ID.
|
1502 |
-
* @param integer $variation_id Product variation ID.
|
1503 |
-
*
|
1504 |
-
* @return array
|
1505 |
-
*/
|
1506 |
-
function tinv_wishlist_metasupport_woocommerce_tm_extra_product_options( $meta, $product_id, $variation_id ) {
|
1507 |
-
if ( array_key_exists( 'tcaddtocart', $meta ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
1508 |
-
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
1509 |
-
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
1510 |
-
$version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
|
1511 |
-
$cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_CART() : TM_EPO_CART();
|
1512 |
-
|
1513 |
-
$has_epo = $api->has_options( $product_id );
|
1514 |
-
if ( $api->is_valid_options( $has_epo ) ) {
|
1515 |
-
$post_data = array();
|
1516 |
-
foreach ( $meta as $key => $value ) {
|
1517 |
-
$post_data[ $key ] = $value['display'];
|
1518 |
-
}
|
1519 |
-
|
1520 |
-
$cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
|
1521 |
-
|
1522 |
-
$cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $post_data );
|
1523 |
-
|
1524 |
-
if ( 'normal' == $core->tm_epo_hide_options_in_cart && 'advanced' != $core->tm_epo_cart_field_display && ! empty( $cart_item['tmcartepo'] ) ) {
|
1525 |
-
$cart_item['quantity'] = 1;
|
1526 |
-
$cart_item['data'] = wc_get_product( $variation_id ? $variation_id : $product_id );
|
1527 |
-
$cart_item['tm_cart_item_key'] = '';
|
1528 |
-
$item_data = $cart_class->get_item_data_array( array(), $cart_item );
|
1529 |
-
|
1530 |
-
foreach ( $item_data as $key => $data ) {
|
1531 |
-
// Set hidden to true to not display meta on cart.
|
1532 |
-
if ( ! empty( $data['hidden'] ) ) {
|
1533 |
-
unset( $item_data[ $key ] );
|
1534 |
-
continue;
|
1535 |
-
}
|
1536 |
-
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
|
1537 |
-
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
|
1538 |
-
}
|
1539 |
-
|
1540 |
-
return $item_data;
|
1541 |
-
}
|
1542 |
-
}
|
1543 |
-
|
1544 |
-
return array();
|
1545 |
-
}
|
1546 |
-
|
1547 |
-
return $meta;
|
1548 |
-
}
|
1549 |
-
|
1550 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options', 10, 3 );
|
1551 |
-
} // End if().
|
1552 |
-
|
1553 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options' ) ) {
|
1554 |
-
|
1555 |
-
/**
|
1556 |
-
* Modify price for WooCommerce TM Extra Product Options
|
1557 |
-
*
|
1558 |
-
* @param string $price Returned price.
|
1559 |
-
* @param array $wl_product Wishlist Product.
|
1560 |
-
* @param \WC_Product $product Woocommerce Product.
|
1561 |
-
*
|
1562 |
-
* @return string
|
1563 |
-
*/
|
1564 |
-
function tinvwl_item_price_woocommerce_tm_extra_product_options( $price, $wl_product, $product ) {
|
1565 |
-
if ( array_key_exists( 'tcaddtocart', (array) @$wl_product['meta'] ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
1566 |
-
|
1567 |
-
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
1568 |
-
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
1569 |
-
$version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
|
1570 |
-
$cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_CART() : TM_EPO_CART();
|
1571 |
-
if ( $core->tm_epo_hide_options_in_cart == 'normal' ) {
|
1572 |
-
$product_id = $wl_product['product_id'];
|
1573 |
-
$has_epo = $api->has_options( $product_id );
|
1574 |
-
if ( $api->is_valid_options( $has_epo ) ) {
|
1575 |
-
|
1576 |
-
$cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
|
1577 |
-
|
1578 |
-
$cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $wl_product['meta'] );
|
1579 |
-
$cart_item['quantity'] = 1;
|
1580 |
-
$cart_item['data'] = $product;
|
1581 |
-
|
1582 |
-
$product_price = apply_filters( 'wc_epo_add_cart_item_original_price', $cart_item['data']->get_price(), $cart_item );
|
1583 |
-
if ( ! empty( $cart_item['tmcartepo'] ) ) {
|
1584 |
-
$to_currency = version_compare( $version, '4.9.0', '<' ) ? tc_get_woocommerce_currency() : themecomplete_get_woocommerce_currency();
|
1585 |
-
foreach ( $cart_item['tmcartepo'] as $value ) {
|
1586 |
-
if ( array_key_exists( $to_currency, $value['price_per_currency'] ) ) {
|
1587 |
-
$value = floatval( $value['price_per_currency'][ $to_currency ] );
|
1588 |
-
$product_price += $value;
|
1589 |
-
}
|
1590 |
-
}
|
1591 |
-
}
|
1592 |
-
|
1593 |
-
$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 );
|
1594 |
-
}
|
1595 |
-
}
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
return $price;
|
1599 |
-
}
|
1600 |
-
|
1601 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3 );
|
1602 |
-
} // End if().
|
1603 |
-
|
1604 |
-
if ( ! function_exists( 'TII18n' ) ) {
|
1605 |
-
|
1606 |
-
/**
|
1607 |
-
* Return TI Yoasti 18n module class
|
1608 |
-
*
|
1609 |
-
* @return \TInvWL_Includes_API_Yoasti18n
|
1610 |
-
*/
|
1611 |
-
function TII18n() { // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
|
1612 |
-
return TInvWL_Includes_API_Yoasti18n::instance();
|
1613 |
-
}
|
1614 |
-
}
|
1615 |
-
|
1616 |
-
// WP Multilang string translations.
|
1617 |
-
if ( function_exists( 'wpm_translate_string' ) ) {
|
1618 |
-
|
1619 |
-
add_filter( 'tinvwl_default_wishlist_title', 'wpm_translate_string' );
|
1620 |
-
add_filter( 'tinvwl_view_wishlist_text', 'wpm_translate_string' );
|
1621 |
-
add_filter( 'tinvwl_added_to_wishlist_text', 'wpm_translate_string' );
|
1622 |
-
add_filter( 'tinvwl_already_in_wishlist_text', 'wpm_translate_string' );
|
1623 |
-
add_filter( 'tinvwl_removed_from_wishlist_text', 'wpm_translate_string' );
|
1624 |
-
add_filter( 'tinvwl_remove_from_wishlist_text', 'wpm_translate_string' );
|
1625 |
-
|
1626 |
-
add_filter( 'tinvwl_added_to_wishlist_text_loop', 'wpm_translate_string' );
|
1627 |
-
add_filter( 'tinvwl_remove_from_wishlist_text_loop', 'wpm_translate_string' );
|
1628 |
-
|
1629 |
-
|
1630 |
-
add_filter( 'tinvwl_add_to_cart_text', 'wpm_translate_string' );
|
1631 |
-
|
1632 |
-
add_filter( 'tinvwl_add_selected_to_cart_text', 'wpm_translate_string' );
|
1633 |
-
add_filter( 'tinvwl_add_all_to_cart_text', 'wpm_translate_string' );
|
1634 |
-
|
1635 |
-
add_filter( 'tinvwl_share_on_text', 'wpm_translate_string' );
|
1636 |
-
|
1637 |
-
add_filter( 'tinvwl_wishlist_products_counter_text', 'wpm_translate_string' );
|
1638 |
-
|
1639 |
-
} // End if().
|
1640 |
-
|
1641 |
-
|
1642 |
-
if ( ! function_exists( 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on' ) ) {
|
1643 |
-
|
1644 |
-
/**
|
1645 |
-
* Set description for meta YITH WooCommerce Product Add-on
|
1646 |
-
*
|
1647 |
-
* @param array $meta Meta array.
|
1648 |
-
* @param array $wl_product Wishlist Product.
|
1649 |
-
* @param \WC_Product $product Woocommerce Product.
|
1650 |
-
*
|
1651 |
-
* @return array
|
1652 |
-
*/
|
1653 |
-
function tinv_wishlist_item_meta_yith_woocommerce_product_add_on( $item_data, $product_id, $variation_id ) {
|
1654 |
-
|
1655 |
-
if ( isset( $item_data['yith_wapo_is_single'] ) && class_exists( 'YITH_WAPO' ) ) {
|
1656 |
-
unset( $item_data['yith_wapo_is_single'] );
|
1657 |
-
|
1658 |
-
$id = ( $variation_id ) ? $variation_id : $product_id;
|
1659 |
-
|
1660 |
-
$base_product = wc_get_product( $id );
|
1661 |
-
|
1662 |
-
if ( ( is_object( $base_product ) && get_option( 'yith_wapo_settings_show_product_price_cart' ) == 'yes' ) ) {
|
1663 |
-
|
1664 |
-
|
1665 |
-
$price = yit_get_display_price( $base_product );
|
1666 |
-
|
1667 |
-
|
1668 |
-
$price_html = wc_price( $price );
|
1669 |
-
|
1670 |
-
$item_data[] = array(
|
1671 |
-
'key' => __( 'Base price', 'ti-woocommerce-wishlist' ),
|
1672 |
-
'display' => $price_html,
|
1673 |
-
);
|
1674 |
-
|
1675 |
-
}
|
1676 |
-
$type_list = YITH_WAPO_Type::getAllowedGroupTypes( $id );
|
1677 |
-
|
1678 |
-
|
1679 |
-
foreach ( $type_list as $single_type ) {
|
1680 |
-
|
1681 |
-
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
1682 |
-
|
1683 |
-
$value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ] : '';
|
1684 |
-
|
1685 |
-
if ( ! $value || ! is_array( $value ) || ! isset( $value['display'] ) ) {
|
1686 |
-
$value = '';
|
1687 |
-
} elseif ( is_array( $value ) && isset( $value['display'] ) && ! ctype_digit( strval( $value['display'][0] ) ) ) {
|
1688 |
-
$value = $value['display'][0];
|
1689 |
-
} else {
|
1690 |
-
$value = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, $value['display'][0], 'label' );
|
1691 |
-
}
|
1692 |
-
|
1693 |
-
|
1694 |
-
unset( $item_data[ $original_data ] );
|
1695 |
-
if ( $value ) {
|
1696 |
-
$item_data[] = array(
|
1697 |
-
'key' => $single_type->label,
|
1698 |
-
'display' => $value,
|
1699 |
-
);
|
1700 |
-
}
|
1701 |
-
|
1702 |
-
}
|
1703 |
-
|
1704 |
-
}
|
1705 |
-
|
1706 |
-
return $item_data;
|
1707 |
-
}
|
1708 |
-
|
1709 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on', 10, 3 );
|
1710 |
-
} // End if().
|
1711 |
-
|
1712 |
-
if ( ! function_exists( 'tinvwl_item_price_yith_woocommerce_product_add_on' ) ) {
|
1713 |
-
|
1714 |
-
/**
|
1715 |
-
* Modify price for YITH WooCommerce product Addons.
|
1716 |
-
*
|
1717 |
-
* @param string $price Returned price.
|
1718 |
-
* @param array $wl_product Wishlist Product.
|
1719 |
-
* @param \WC_Product $product Woocommerce Product.
|
1720 |
-
*
|
1721 |
-
* @return string
|
1722 |
-
*/
|
1723 |
-
function tinvwl_item_price_yith_woocommerce_product_add_on( $price, $wl_product, $product ) {
|
1724 |
-
|
1725 |
-
if ( class_exists( 'YITH_WAPO' ) ) {
|
1726 |
-
|
1727 |
-
$type_list = YITH_WAPO_Type::getAllowedGroupTypes( $product->get_id() );
|
1728 |
-
|
1729 |
-
if ( $type_list ) {
|
1730 |
-
|
1731 |
-
$addons_total = 0;
|
1732 |
-
|
1733 |
-
foreach ( $type_list as $single_type ) {
|
1734 |
-
|
1735 |
-
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
1736 |
-
|
1737 |
-
$value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
|
1738 |
-
|
1739 |
-
|
1740 |
-
if ( ! is_array( $value ) || ! ctype_digit( strval( $value[0] ) ) ) {
|
1741 |
-
continue;
|
1742 |
-
}
|
1743 |
-
|
1744 |
-
$addon_price = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, $value[0], 'price' );
|
1745 |
-
|
1746 |
-
if ( is_numeric( $addon_price ) ) {
|
1747 |
-
$addons_total += $addon_price;
|
1748 |
-
}
|
1749 |
-
|
1750 |
-
}
|
1751 |
-
|
1752 |
-
$price = wc_price( $product->get_price() + $addons_total );
|
1753 |
-
}
|
1754 |
-
}
|
1755 |
-
|
1756 |
-
|
1757 |
-
return $price;
|
1758 |
-
}
|
1759 |
-
|
1760 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_yith_woocommerce_product_add_on', 10, 3 );
|
1761 |
-
} // End if().
|
1762 |
-
|
1763 |
-
|
1764 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_fields' ) ) {
|
1765 |
-
|
1766 |
-
/**
|
1767 |
-
* Modify price for WooCommerce Custom Fields.
|
1768 |
-
*
|
1769 |
-
* @param string $price Returned price.
|
1770 |
-
* @param array $wl_product Wishlist Product.
|
1771 |
-
* @param \WC_Product $product Woocommerce Product.
|
1772 |
-
*
|
1773 |
-
* @return string
|
1774 |
-
*/
|
1775 |
-
function tinvwl_item_price_woocommerce_custom_fields( $price, $wl_product, $product ) {
|
1776 |
-
|
1777 |
-
if ( class_exists( 'WCCF' ) && isset( $wl_product['meta']['wccf']['product_field'] ) ) {
|
1778 |
-
|
1779 |
-
$posted = array();
|
1780 |
-
|
1781 |
-
foreach ( $wl_product['meta']['wccf']['product_field'] as $key => $value ) {
|
1782 |
-
$posted[ $key ] = array( 'value' => $value );
|
1783 |
-
}
|
1784 |
-
|
1785 |
-
$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 ) );
|
1786 |
-
}
|
1787 |
-
|
1788 |
-
return $price;
|
1789 |
-
}
|
1790 |
-
|
1791 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_fields', 10, 3 );
|
1792 |
-
} // End if().
|
1793 |
-
|
1794 |
-
|
1795 |
-
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) ) {
|
1796 |
-
|
1797 |
-
/**
|
1798 |
-
* Set description for meta WooCommerce Product Addons
|
1799 |
-
*
|
1800 |
-
* @param array $meta Meta array.
|
1801 |
-
* @param array $wl_product Wishlist Product.
|
1802 |
-
* @param \WC_Product $product Woocommerce Product.
|
1803 |
-
*
|
1804 |
-
* @return array
|
1805 |
-
*/
|
1806 |
-
function tinv_wishlist_item_meta_woocommerce_product_addons( $item_data, $product_id, $variation_id ) {
|
1807 |
-
|
1808 |
-
|
1809 |
-
if ( class_exists( 'WC_Product_Addons' ) ) {
|
1810 |
-
|
1811 |
-
|
1812 |
-
$id = ( $variation_id ) ? $variation_id : $product_id;
|
1813 |
-
|
1814 |
-
if ( function_exists( 'get_product_addons' ) ) {
|
1815 |
-
$product_addons = get_product_addons( $id );
|
1816 |
-
} else {
|
1817 |
-
$product_addons = WC_Product_Addons_Helper::get_product_addons( $id );
|
1818 |
-
}
|
1819 |
-
|
1820 |
-
if ( $product_addons ) {
|
1821 |
-
|
1822 |
-
|
1823 |
-
foreach ( $product_addons as $addon ) {
|
1824 |
-
foreach ( $addon['options'] as $option ) {
|
1825 |
-
$original_data = 'addon-' . $addon['field_name'];
|
1826 |
-
|
1827 |
-
if ( 'file_upload' === $addon['type'] ) {
|
1828 |
-
$original_data = 'addon-' . $addon['field_name'] . '-' . sanitize_title( $option['label'] );
|
1829 |
-
}
|
1830 |
-
|
1831 |
-
$value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ]['display'] : '';
|
1832 |
-
|
1833 |
-
if ( $value == '' ) {
|
1834 |
-
continue;
|
1835 |
-
}
|
1836 |
-
|
1837 |
-
|
1838 |
-
if ( is_array( $value ) ) {
|
1839 |
-
$value = array_map( 'stripslashes', $value );
|
1840 |
-
} else {
|
1841 |
-
$value = stripslashes( $value );
|
1842 |
-
}
|
1843 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
|
1844 |
-
switch ( $addon['type'] ) {
|
1845 |
-
case 'checkbox':
|
1846 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
1847 |
-
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
1848 |
-
break;
|
1849 |
-
case 'multiple_choice':
|
1850 |
-
switch ( $addon['display'] ) {
|
1851 |
-
case 'radiobutton':
|
1852 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
1853 |
-
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
1854 |
-
break;
|
1855 |
-
case 'images':
|
1856 |
-
case 'select':
|
1857 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php' );
|
1858 |
-
$field = new WC_Product_Addons_Field_Select( $addon, $value );
|
1859 |
-
break;
|
1860 |
-
}
|
1861 |
-
break;
|
1862 |
-
case 'custom_text':
|
1863 |
-
case 'custom_textarea':
|
1864 |
-
case 'custom_price':
|
1865 |
-
case 'input_multiplier':
|
1866 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php' );
|
1867 |
-
$field = new WC_Product_Addons_Field_Custom( $addon, $value );
|
1868 |
-
break;
|
1869 |
-
case 'file_upload':
|
1870 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
|
1871 |
-
$field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
|
1872 |
-
break;
|
1873 |
-
default:
|
1874 |
-
// Continue to the next field in case the type is not recognized (instead of causing a fatal error)
|
1875 |
-
break;
|
1876 |
-
}
|
1877 |
-
|
1878 |
-
|
1879 |
-
$data = $field->get_cart_item_data();
|
1880 |
-
|
1881 |
-
unset( $item_data[ $original_data ] );
|
1882 |
-
foreach ( $data as $option ) {
|
1883 |
-
$name = $option['name'];
|
1884 |
-
|
1885 |
-
if ( $option['price'] && apply_filters( 'woocommerce_addons_add_price_to_name', '__return_true' ) ) {
|
1886 |
-
$name .= ' (' . wc_price( get_product_addon_price_for_display( $option['price'] ) ) . ')';
|
1887 |
-
}
|
1888 |
-
|
1889 |
-
$item_data[] = array(
|
1890 |
-
'key' => $name,
|
1891 |
-
'display' => $option['value'],
|
1892 |
-
);
|
1893 |
-
}
|
1894 |
-
}
|
1895 |
-
}
|
1896 |
-
}
|
1897 |
-
}
|
1898 |
-
|
1899 |
-
return $item_data;
|
1900 |
-
}
|
1901 |
-
|
1902 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_product_addons', 10, 3 );
|
1903 |
-
} // End if().
|
1904 |
-
|
1905 |
-
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) ) {
|
1906 |
-
|
1907 |
-
/**
|
1908 |
-
* Set description for meta WooCommerce Custom Fields
|
1909 |
-
*
|
1910 |
-
* @param array $meta Meta array.
|
1911 |
-
* @param array $wl_product Wishlist Product.
|
1912 |
-
* @param \WC_Product $product Woocommerce Product.
|
1913 |
-
*
|
1914 |
-
* @return array
|
1915 |
-
*/
|
1916 |
-
function tinv_wishlist_item_meta_woocommerce_custom_fields( $item_data, $product_id, $variation_id ) {
|
1917 |
-
|
1918 |
-
|
1919 |
-
if ( class_exists( 'WCCF' ) && isset( $item_data['wccf'] ) ) {
|
1920 |
-
|
1921 |
-
$id = ( $variation_id ) ? $variation_id : $product_id;
|
1922 |
-
$product = wc_get_product( $id );
|
1923 |
-
if ( $product ) {
|
1924 |
-
|
1925 |
-
|
1926 |
-
// Get fields to save values for
|
1927 |
-
$fields = WCCF_Product_Field_Controller::get_filtered( null, array(
|
1928 |
-
'item_id' => $product_id,
|
1929 |
-
'child_id' => $variation_id,
|
1930 |
-
) );
|
1931 |
-
|
1932 |
-
// Set quantity
|
1933 |
-
$quantity = 1;
|
1934 |
-
$quantity_index = null;
|
1935 |
-
$display_pricing = null;
|
1936 |
-
|
1937 |
-
// Check if pricing can be displayed for this product
|
1938 |
-
if ( $display_pricing === null ) {
|
1939 |
-
$display_pricing = ! WCCF_WC_Product::skip_pricing( $product );
|
1940 |
-
}
|
1941 |
-
|
1942 |
-
foreach ( $fields as $field ) {
|
1943 |
-
|
1944 |
-
// Check how many times to iterate the same field (used for quantity-based product fields)
|
1945 |
-
if ( $quantity_index !== null ) {
|
1946 |
-
$iterations = ( $quantity_index + 1 );
|
1947 |
-
$i = $quantity_index;
|
1948 |
-
} else {
|
1949 |
-
$iterations = ( $field->is_quantity_based() && $quantity ) ? $quantity : 1;
|
1950 |
-
$i = 0;
|
1951 |
-
}
|
1952 |
-
|
1953 |
-
// Start iteration of the same field
|
1954 |
-
for ( $i = $i; $i < $iterations; $i ++ ) {
|
1955 |
-
|
1956 |
-
// Get field id
|
1957 |
-
$field_id = $field->get_id() . ( $i ? ( '_' . $i ) : '' );
|
1958 |
-
|
1959 |
-
// Special handling for files
|
1960 |
-
if ( $field->field_type_is( 'file' ) ) {
|
1961 |
-
//just skip this field type because we can't save uploaded data.
|
1962 |
-
} // Handle other field values
|
1963 |
-
else {
|
1964 |
-
|
1965 |
-
// Check if any data for this field was posted or is available in request query vars for GET requests
|
1966 |
-
if ( isset( $item_data['wccf']['display']['product_field'][ $field_id ] ) ) {
|
1967 |
-
|
1968 |
-
// Get field value
|
1969 |
-
if ( isset( $item_data['wccf']['display']['product_field'][ $field_id ] ) ) {
|
1970 |
-
$field_value = $item_data['wccf']['display']['product_field'][ $field_id ];
|
1971 |
-
}
|
1972 |
-
|
1973 |
-
// Prepare multiselect field values
|
1974 |
-
if ( $field->accepts_multiple_values() ) {
|
1975 |
-
|
1976 |
-
// Ensure that value is array
|
1977 |
-
$value = ! RightPress_Help::is_empty( $field_value ) ? (array) $field_value : array();
|
1978 |
-
|
1979 |
-
// Filter out hidden placeholder input value
|
1980 |
-
$value = array_filter( (array) $value, function ( $test_value ) {
|
1981 |
-
return trim( $test_value ) !== '';
|
1982 |
-
} );
|
1983 |
-
} else {
|
1984 |
-
$value = stripslashes( trim( $field_value ) );
|
1985 |
-
}
|
1986 |
-
|
1987 |
-
$item_data[] = array(
|
1988 |
-
'key' => $field->get_label(),
|
1989 |
-
'display' => $field->format_display_value( array( 'value' => $value ), $display_pricing ),
|
1990 |
-
);
|
1991 |
-
|
1992 |
-
|
1993 |
-
}
|
1994 |
-
}
|
1995 |
-
}
|
1996 |
-
}
|
1997 |
-
|
1998 |
-
unset( $item_data['wccf'] );
|
1999 |
-
unset( $item_data['wccf_ignore'] );
|
2000 |
-
}
|
2001 |
-
}
|
2002 |
-
|
2003 |
-
return $item_data;
|
2004 |
-
}
|
2005 |
-
|
2006 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_fields', 10, 3 );
|
2007 |
-
} // End if().
|
2008 |
-
|
2009 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
|
2010 |
-
|
2011 |
-
/**
|
2012 |
-
* Modify price for WooCommerce Product Addons.
|
2013 |
-
*
|
2014 |
-
* @param string $price Returned price.
|
2015 |
-
* @param array $wl_product Wishlist Product.
|
2016 |
-
* @param \WC_Product $product Woocommerce Product.
|
2017 |
-
*
|
2018 |
-
* @return string
|
2019 |
-
*/
|
2020 |
-
function tinvwl_item_price_woocommerce_product_addons( $price, $wl_product, $product ) {
|
2021 |
-
|
2022 |
-
if ( class_exists( 'WC_Product_Addons' ) ) {
|
2023 |
-
|
2024 |
-
|
2025 |
-
if ( function_exists( 'get_product_addons' ) ) {
|
2026 |
-
$product_addons = get_product_addons( $product->get_id() );
|
2027 |
-
} else {
|
2028 |
-
$product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
|
2029 |
-
}
|
2030 |
-
|
2031 |
-
if ( $product_addons ) {
|
2032 |
-
|
2033 |
-
$price = 0;
|
2034 |
-
|
2035 |
-
foreach ( $product_addons as $addon ) {
|
2036 |
-
|
2037 |
-
$original_data = 'addon-' . $addon['field_name'];
|
2038 |
-
|
2039 |
-
$value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
|
2040 |
-
if ( $value == '' ) {
|
2041 |
-
continue;
|
2042 |
-
}
|
2043 |
-
|
2044 |
-
|
2045 |
-
if ( is_array( $value ) ) {
|
2046 |
-
$value = array_map( 'stripslashes', $value );
|
2047 |
-
} else {
|
2048 |
-
$value = stripslashes( $value );
|
2049 |
-
}
|
2050 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
|
2051 |
-
switch ( $addon['type'] ) {
|
2052 |
-
case 'checkbox':
|
2053 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
2054 |
-
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
2055 |
-
break;
|
2056 |
-
case 'multiple_choice':
|
2057 |
-
switch ( $addon['display'] ) {
|
2058 |
-
case 'radiobutton':
|
2059 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
|
2060 |
-
$field = new WC_Product_Addons_Field_List( $addon, $value );
|
2061 |
-
break;
|
2062 |
-
case 'images':
|
2063 |
-
case 'select':
|
2064 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-select.php' );
|
2065 |
-
$field = new WC_Product_Addons_Field_Select( $addon, $value );
|
2066 |
-
break;
|
2067 |
-
}
|
2068 |
-
break;
|
2069 |
-
case 'custom_text':
|
2070 |
-
case 'custom_textarea':
|
2071 |
-
case 'custom_price':
|
2072 |
-
case 'input_multiplier':
|
2073 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-custom.php' );
|
2074 |
-
$field = new WC_Product_Addons_Field_Custom( $addon, $value );
|
2075 |
-
break;
|
2076 |
-
case 'file_upload':
|
2077 |
-
include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
|
2078 |
-
$field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
|
2079 |
-
break;
|
2080 |
-
default:
|
2081 |
-
// Continue to the next field in case the type is not recognized (instead of causing a fatal error)
|
2082 |
-
break;
|
2083 |
-
}
|
2084 |
-
|
2085 |
-
|
2086 |
-
$data = $field->get_cart_item_data();
|
2087 |
-
foreach ( $data as $option ) {
|
2088 |
-
if ( $option['price'] ) {
|
2089 |
-
$price += (float) $option['price'];
|
2090 |
-
}
|
2091 |
-
}
|
2092 |
-
|
2093 |
-
|
2094 |
-
}
|
2095 |
-
|
2096 |
-
$price = wc_price( $product->get_price() + $price );
|
2097 |
-
}
|
2098 |
-
}
|
2099 |
-
|
2100 |
-
|
2101 |
-
return $price;
|
2102 |
-
}
|
2103 |
-
|
2104 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_addons', 10, 3 );
|
2105 |
-
} // End if().
|
2106 |
-
|
2107 |
-
|
2108 |
-
// OceanWP theme compatibility;
|
2109 |
-
if ( ! function_exists( 'oceanwp_fix_archive_markup' ) ) {
|
2110 |
-
add_action( 'init', 'oceanwp_fix_archive_markup' );
|
2111 |
-
|
2112 |
-
/**
|
2113 |
-
* OceanWP theme fix for catalog add to wishlist button position
|
2114 |
-
*/
|
2115 |
-
function oceanwp_fix_archive_markup() {
|
2116 |
-
if ( class_exists( 'OceanWP_WooCommerce_Config' ) && 'above_thumb' === tinv_get_option( 'add_to_wishlist_catalog', 'position' ) ) {
|
2117 |
-
remove_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 9 );
|
2118 |
-
add_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 10 );
|
2119 |
-
}
|
2120 |
-
}
|
2121 |
-
}
|
2122 |
-
|
2123 |
-
// Google Tag Manager for WordPress compatibility.
|
2124 |
-
if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
|
2125 |
-
|
2126 |
-
/**
|
2127 |
-
* Prepare save meta for WooCommerce - Google Tag Manager for WordPress
|
2128 |
-
*
|
2129 |
-
* @param array $meta Meta array.
|
2130 |
-
*
|
2131 |
-
* @return array
|
2132 |
-
*/
|
2133 |
-
function tinv_wishlist_metaprepare_gtm4wp( $meta ) {
|
2134 |
-
|
2135 |
-
foreach ( array_keys( $meta ) as $key ) {
|
2136 |
-
if ( strpos( $key, 'gtm4wp_' ) === 0 ) {
|
2137 |
-
unset( $meta[ $key ] );
|
2138 |
-
}
|
2139 |
-
}
|
2140 |
-
|
2141 |
-
return $meta;
|
2142 |
-
}
|
2143 |
-
|
2144 |
-
add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_gtm4wp' );
|
2145 |
-
}
|
2146 |
-
|
2147 |
-
// WooCommerce Advanced Quantity compatibility.
|
2148 |
-
if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_qty' ) ) {
|
2149 |
-
|
2150 |
-
/**
|
2151 |
-
* Force quantity to minimum.
|
2152 |
-
*
|
2153 |
-
* @param $quantity
|
2154 |
-
* @param $product
|
2155 |
-
*
|
2156 |
-
* @return mixed
|
2157 |
-
*/
|
2158 |
-
function tinv_wishlist_qty_woo_advanced_qty( $quantity, $product ) {
|
2159 |
-
|
2160 |
-
if ( class_exists( 'Woo_Advanced_QTY_Public' ) ) {
|
2161 |
-
$advanced_qty = new Woo_Advanced_QTY_Public( null, null );
|
2162 |
-
|
2163 |
-
$args = $advanced_qty->qty_input_args( array(
|
2164 |
-
'min_value' => 1,
|
2165 |
-
'max_value' => '',
|
2166 |
-
'step' => 1,
|
2167 |
-
), $product );
|
2168 |
-
|
2169 |
-
$quantity = $args['input_value'];
|
2170 |
-
}
|
2171 |
-
|
2172 |
-
return $quantity;
|
2173 |
-
}
|
2174 |
-
|
2175 |
-
add_filter( 'tinvwl_product_add_to_cart_quantity', 'tinv_wishlist_qty_woo_advanced_qty', 10, 2 );
|
2176 |
-
}
|
2177 |
-
|
2178 |
-
// WooCommerce Advanced Quantity compatibility.
|
2179 |
-
if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_url' ) ) {
|
2180 |
-
|
2181 |
-
/**
|
2182 |
-
* @param $url
|
2183 |
-
* @param $product
|
2184 |
-
*
|
2185 |
-
* @return string|string[]|null
|
2186 |
-
*/
|
2187 |
-
function tinv_wishlist_qty_woo_advanced_url( $url, $product ) {
|
2188 |
-
|
2189 |
-
if ( class_exists( 'Woo_Advanced_QTY_Public' ) ) {
|
2190 |
-
if ( strpos( $url, 'add-to-cart=' ) ) {
|
2191 |
-
$advanced_qty = new Woo_Advanced_QTY_Public( null, null );
|
2192 |
-
$args = $advanced_qty->qty_input_args( array(
|
2193 |
-
'min_value' => 1,
|
2194 |
-
'max_value' => '',
|
2195 |
-
'step' => 1,
|
2196 |
-
), $product );
|
2197 |
-
|
2198 |
-
$url = preg_replace( '/&quantity=[0-9.]*/', '', $url );
|
2199 |
-
|
2200 |
-
$url .= '&quantity=' . $args['input_value'];
|
2201 |
-
}
|
2202 |
-
}
|
2203 |
-
|
2204 |
-
return $url;
|
2205 |
-
}
|
2206 |
-
|
2207 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_slug_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
|
2208 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_url_original', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
|
2209 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinv_wishlist_qty_woo_advanced_url', 10, 2 );
|
2210 |
-
}
|
2211 |
-
|
2212 |
-
if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addons' ) ) {
|
2213 |
-
|
2214 |
-
/**
|
2215 |
-
* Set description for meta WooCommerce Custom Product Addons
|
2216 |
-
*
|
2217 |
-
* @param array $meta Meta array.
|
2218 |
-
* @param array $wl_product Wishlist Product.
|
2219 |
-
* @param \WC_Product $product Woocommerce Product.
|
2220 |
-
*
|
2221 |
-
* @return array
|
2222 |
-
*/
|
2223 |
-
|
2224 |
-
function tinv_wishlist_item_meta_woocommerce_custom_product_addons( $item_data, $product_id, $variation_id ) {
|
2225 |
-
if ( function_exists( 'WCPA' ) ) {
|
2226 |
-
$form = new WCPA_Form();
|
2227 |
-
$frontend = new WCPA_Front_End();
|
2228 |
-
$data = array();
|
2229 |
-
$post_ids = $form->get_form_ids( $product_id );
|
2230 |
-
|
2231 |
-
if ( wcpa_get_option( 'form_loading_order_by_date' ) === true ) {
|
2232 |
-
if ( is_array( $post_ids ) && count( $post_ids ) ) {
|
2233 |
-
$post_ids = get_posts( array(
|
2234 |
-
'posts_per_page' => - 1,
|
2235 |
-
'include' => $post_ids,
|
2236 |
-
'fields' => 'ids',
|
2237 |
-
'post_type' => WCPA_POST_TYPE,
|
2238 |
-
'posts_per_page' => - 1,
|
2239 |
-
) );
|
2240 |
-
}
|
2241 |
-
}
|
2242 |
-
foreach ( $post_ids as $id ) {
|
2243 |
-
if ( get_post_status( $id ) == 'publish' ) {
|
2244 |
-
$json_string = get_post_meta( $id, WCPA_FORM_META_KEY, true );
|
2245 |
-
$json_encoded = json_decode( $json_string );
|
2246 |
-
if ( $json_encoded && is_array( $json_encoded ) ) {
|
2247 |
-
$data = array_merge( $data, $json_encoded );
|
2248 |
-
}
|
2249 |
-
}
|
2250 |
-
}
|
2251 |
-
|
2252 |
-
foreach ( $data as $v ) {
|
2253 |
-
$form_data = clone $v;
|
2254 |
-
unset( $form_data->values ); //avoid saving large number of data
|
2255 |
-
unset( $form_data->className ); //avoid saving no use data
|
2256 |
-
if ( ! in_array( $v->type, array( 'header', 'paragraph' ) ) ) {
|
2257 |
-
if ( isset( $item_data[ $v->name ] ) ) {
|
2258 |
-
|
2259 |
-
if ( ! is_object( $v ) ) {
|
2260 |
-
$value = sanitize_text_field( $v );
|
2261 |
-
} else if ( ( isset( $v->name ) ) ) {
|
2262 |
-
if ( is_array( $item_data[ $v->name ] ) ) {
|
2263 |
-
|
2264 |
-
$_values = $item_data[ $v->name ];
|
2265 |
-
array_walk( $_values, function ( &$a ) {
|
2266 |
-
sanitize_text_field( $a );
|
2267 |
-
} ); // using this array_wal method to preserve the keys
|
2268 |
-
$value = $_values;
|
2269 |
-
} else if ( $v->type == 'textarea' ) {
|
2270 |
-
$value = sanitize_textarea_field( wp_unslash( $item_data[ $v->name ] ) );
|
2271 |
-
} else {
|
2272 |
-
$value = sanitize_text_field( wp_unslash( $item_data[ $v->name ] ) );
|
2273 |
-
}
|
2274 |
-
}
|
2275 |
-
$item_data[ $v->name ]['key'] = ( isset( $v->label ) ) ? $v->label : '';
|
2276 |
-
$item_data[ $v->name ]['display'] = $frontend->cart_display( array(
|
2277 |
-
'type' => $v->type,
|
2278 |
-
'name' => $v->name,
|
2279 |
-
'label' => ( isset( $v->label ) ) ? $v->label : '',
|
2280 |
-
'value' => $value['display'],
|
2281 |
-
'price' => false,
|
2282 |
-
'form_data' => $form_data,
|
2283 |
-
) );
|
2284 |
-
}
|
2285 |
-
}
|
2286 |
-
}
|
2287 |
-
}
|
2288 |
-
|
2289 |
-
return $item_data;
|
2290 |
-
}
|
2291 |
-
|
2292 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woocommerce_custom_product_addons', 10, 3 );
|
2293 |
-
}
|
2294 |
-
|
2295 |
-
|
2296 |
-
if ( ! function_exists( 'tinv_wishlist_meta_support_ivpa' ) ) {
|
2297 |
-
|
2298 |
-
/**
|
2299 |
-
* Set description for meta Improved Product Options for WooCommerce
|
2300 |
-
*
|
2301 |
-
* @param array $meta Meta array.
|
2302 |
-
*
|
2303 |
-
* @return array
|
2304 |
-
*/
|
2305 |
-
function tinv_wishlist_meta_support_ivpa( $meta ) {
|
2306 |
-
global $product;
|
2307 |
-
|
2308 |
-
if ( class_exists( 'WC_Improved_Variable_Product_Attributes_Init' ) ) {
|
2309 |
-
|
2310 |
-
$curr_customizations = WC_Improved_Variable_Product_Attributes::get_custom();
|
2311 |
-
|
2312 |
-
foreach ( $meta as $k => $v ) {
|
2313 |
-
$prefix = 'ivpac_';
|
2314 |
-
$k_ivpac = ( 0 === strpos( $k, $prefix ) ) ? substr( $k, strlen( $prefix ) ) : $k;
|
2315 |
-
|
2316 |
-
$prefix = 'attribute_';
|
2317 |
-
$k_ivpac = ( 0 === strpos( $k, $prefix ) ) ? substr( $k, strlen( $prefix ) ) : $k_ivpac;
|
2318 |
-
$v = is_array( $v['display'] ) ? implode( ', ', $v['display'] ) : $v['display'];
|
2319 |
-
if ( isset( $curr_customizations['ivpa_attr'][ $k_ivpac ] ) ) {
|
2320 |
-
if ( $curr_customizations['ivpa_attr'][ $k_ivpac ] == 'ivpa_custom' ) {
|
2321 |
-
$meta[ $k ] = array(
|
2322 |
-
'key' => $curr_customizations['ivpa_title'][ $k_ivpac ],
|
2323 |
-
'display' => $v,
|
2324 |
-
);
|
2325 |
-
}
|
2326 |
-
}
|
2327 |
-
if ( in_array( $k_ivpac, $curr_customizations['ivpa_attr'] ) ) {
|
2328 |
-
if ( $product->is_type( 'variation' ) && $product->get_attribute( $k_ivpac ) === $v ) {
|
2329 |
-
unset( $meta[ $k ] );
|
2330 |
-
} else {
|
2331 |
-
$meta[ $k ] = array(
|
2332 |
-
'key' => wc_attribute_label( $k_ivpac ),
|
2333 |
-
'display' => $v,
|
2334 |
-
);
|
2335 |
-
}
|
2336 |
-
}
|
2337 |
-
}
|
2338 |
-
}
|
2339 |
-
|
2340 |
-
return $meta;
|
2341 |
-
}
|
2342 |
-
|
2343 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_meta_support_ivpa' );
|
2344 |
-
} // End if().
|
2345 |
-
|
2346 |
-
|
2347 |
-
function tinv_add_to_wishlist_ivpa() {
|
2348 |
-
if ( class_exists( 'WC_Improved_Variable_Product_Attributes_Init' ) ) {
|
2349 |
-
|
2350 |
-
wp_add_inline_script( 'tinvwl', "
|
2351 |
-
jQuery(document).ready(function($){
|
2352 |
-
$(document).on('tinvwl_wishlist_button_clicked', function (e, el, data) {
|
2353 |
-
|
2354 |
-
if (!ivpa) {
|
2355 |
-
return false;
|
2356 |
-
}
|
2357 |
-
var button = $(el);
|
2358 |
-
var container = button.closest(ivpa.settings.archive_selector);
|
2359 |
-
var find = button.closest('.summary').length > 0 ? '#ivpa-content' : '.ivpa-content';
|
2360 |
-
|
2361 |
-
if (container.find(find).length > 0) {
|
2362 |
-
var var_id = container.find(find).attr('data-selected');
|
2363 |
-
|
2364 |
-
if (typeof var_id == 'undefined' || var_id == '') {
|
2365 |
-
var_id = container.find('[name=\"variation_id\"]').val();
|
2366 |
-
}
|
2367 |
-
|
2368 |
-
if (typeof var_id == 'undefined' || var_id == '') {
|
2369 |
-
var_id = container.find(find).attr('data-id');
|
2370 |
-
}
|
2371 |
-
|
2372 |
-
var item = {};
|
2373 |
-
container.find(find + ' .ivpa_attribute').each(function () {
|
2374 |
-
var attribute = $(this).attr('data-attribute');
|
2375 |
-
var attribute_value = $(this).find('.ivpa_term.ivpa_clicked').attr('data-term');
|
2376 |
-
|
2377 |
-
data.form['attribute_' + attribute] = attribute_value;
|
2378 |
-
});
|
2379 |
-
|
2380 |
-
var ivpac = container.find(find + ' .ivpa_custom_option').length > 0 ? container.find(find + ' .ivpa_custom_option [name^=\"ivpac_\"]').serialize() : '';
|
2381 |
-
|
2382 |
-
var ivpac_fields = container.find(find + ' .ivpa_custom_option').length > 0 ? container.find(find + ' .ivpa_custom_option [name^=\"ivpac_\"]') : '';
|
2383 |
-
|
2384 |
-
ivpac_fields.each(function () {
|
2385 |
-
|
2386 |
-
var name = $(this).attr('name').replace(/\[.*\]/g, '');
|
2387 |
-
|
2388 |
-
if ($(this).is(':checkbox')) {
|
2389 |
-
|
2390 |
-
if (!$(this).is(':checked')) return true;
|
2391 |
-
|
2392 |
-
if (data.form.hasOwnProperty(name) && data.form[name].length) {
|
2393 |
-
data.form[name] = (data.form[name] + ', ' + $(this).val()).replace(/^, /, '');
|
2394 |
-
} else {
|
2395 |
-
data.form[name] = $(this).val();
|
2396 |
-
}
|
2397 |
-
} else {
|
2398 |
-
data.form[name] = $(this).val();
|
2399 |
-
}
|
2400 |
-
});
|
2401 |
-
|
2402 |
-
|
2403 |
-
data.form.variation_id = var_id;
|
2404 |
-
data.ivpac = ivpac;
|
2405 |
-
}
|
2406 |
-
});
|
2407 |
-
});
|
2408 |
-
" );
|
2409 |
-
}
|
2410 |
-
}
|
2411 |
-
|
2412 |
-
add_action( 'wp_enqueue_scripts', 'tinv_add_to_wishlist_ivpa', 100, 1 );
|
2413 |
-
|
2414 |
-
|
2415 |
-
// myCred hooks
|
2416 |
-
if ( defined( 'myCRED_VERSION' ) ) {
|
2417 |
-
|
2418 |
-
/**
|
2419 |
-
* Register Hook
|
2420 |
-
*/
|
2421 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_ti_woocommerce_wishlist_hook', 100 );
|
2422 |
-
function mycred_register_ti_woocommerce_wishlist_hook( $installed ) {
|
2423 |
-
|
2424 |
-
$installed['tinvwl'] = array(
|
2425 |
-
'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
|
2426 |
-
'description' => __( 'Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist.', 'ti-woocommerce-wishlist' ),
|
2427 |
-
'callback' => array( 'myCRED_Hook_TinvWL' ),
|
2428 |
-
);
|
2429 |
-
|
2430 |
-
return $installed;
|
2431 |
-
|
2432 |
-
}
|
2433 |
-
|
2434 |
-
/**
|
2435 |
-
* TI WooCommerce Wihslist Hook
|
2436 |
-
*/
|
2437 |
-
add_action( 'mycred_load_hooks', 'mycred_load_ti_woocommerce_wishlist_hook', 100 );
|
2438 |
-
function mycred_load_ti_woocommerce_wishlist_hook() {
|
2439 |
-
|
2440 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
2441 |
-
if ( class_exists( 'myCRED_Hook_TinvWL' ) ) {
|
2442 |
-
return;
|
2443 |
-
}
|
2444 |
-
|
2445 |
-
class myCRED_Hook_TinvWL extends myCRED_Hook {
|
2446 |
-
|
2447 |
-
/**
|
2448 |
-
* Construct
|
2449 |
-
*/
|
2450 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
2451 |
-
|
2452 |
-
parent::__construct( array(
|
2453 |
-
'id' => 'tinvwl',
|
2454 |
-
'defaults' => array(
|
2455 |
-
'tinvwl_added' => array(
|
2456 |
-
'creds' => 1,
|
2457 |
-
'log' => '%plural% for adding a product to a wishlist',
|
2458 |
-
'limit' => '0/x',
|
2459 |
-
),
|
2460 |
-
'tinvwl_purchased' => array(
|
2461 |
-
'creds' => 1,
|
2462 |
-
'log' => '%plural% for purchasing a product from a wishlist',
|
2463 |
-
'limit' => '0/x',
|
2464 |
-
),
|
2465 |
-
),
|
2466 |
-
), $hook_prefs, $type );
|
2467 |
-
|
2468 |
-
}
|
2469 |
-
|
2470 |
-
/**
|
2471 |
-
* Run
|
2472 |
-
*/
|
2473 |
-
public function run() {
|
2474 |
-
add_action( 'tinvwl_product_added', array( $this, 'added' ) );
|
2475 |
-
add_action( 'tinvwl_product_purchased', array( $this, 'purchased' ), 10, 3 );
|
2476 |
-
}
|
2477 |
-
|
2478 |
-
/**
|
2479 |
-
* Added product to a wishlist
|
2480 |
-
*
|
2481 |
-
* @param array $data product data including author and wishlist IDs.
|
2482 |
-
*/
|
2483 |
-
public function added( $data ) {
|
2484 |
-
|
2485 |
-
// Must be logged in
|
2486 |
-
if ( ! is_user_logged_in() ) {
|
2487 |
-
return;
|
2488 |
-
}
|
2489 |
-
|
2490 |
-
$user_id = get_current_user_id();
|
2491 |
-
|
2492 |
-
// Award the user adding to wishlist
|
2493 |
-
if ( $this->prefs['tinvwl_added']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
|
2494 |
-
|
2495 |
-
// Limit
|
2496 |
-
if ( ! $this->over_hook_limit( 'tinvwl_added', 'added_to_wishlist', $user_id ) ) {
|
2497 |
-
|
2498 |
-
// Make sure this is unique event
|
2499 |
-
if ( ! $this->core->has_entry( 'added_to_wishlist', $data['product_id'], $user_id ) ) {
|
2500 |
-
|
2501 |
-
// Execute
|
2502 |
-
$this->core->add_creds(
|
2503 |
-
'added_to_wishlist',
|
2504 |
-
$user_id,
|
2505 |
-
$this->prefs['tinvwl_added']['creds'],
|
2506 |
-
$this->prefs['tinvwl_added']['log'],
|
2507 |
-
$data['product_id'],
|
2508 |
-
array( 'ref_type' => 'post' ),
|
2509 |
-
$this->mycred_type
|
2510 |
-
);
|
2511 |
-
|
2512 |
-
}
|
2513 |
-
|
2514 |
-
}
|
2515 |
-
|
2516 |
-
}
|
2517 |
-
}
|
2518 |
-
|
2519 |
-
/**
|
2520 |
-
* Purchased product from a wishlist
|
2521 |
-
*
|
2522 |
-
* @param WC_order $order Order object.
|
2523 |
-
* @param WC_Order_Item_Product $item Order item product object.
|
2524 |
-
* @param array $wishlist A wishlist data where product added from.
|
2525 |
-
*/
|
2526 |
-
public function purchased( $order, $item, $wishlist ) {
|
2527 |
-
|
2528 |
-
// Must be logged in
|
2529 |
-
if ( ! is_user_logged_in() ) {
|
2530 |
-
return;
|
2531 |
-
}
|
2532 |
-
|
2533 |
-
$user_id = get_current_user_id();
|
2534 |
-
|
2535 |
-
// Award the user adding to wishlist
|
2536 |
-
if ( $this->prefs['tinvwl_purchased']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
|
2537 |
-
|
2538 |
-
// Limit
|
2539 |
-
if ( ! $this->over_hook_limit( 'tinvwl_purchased', 'purchased_from_wishlist', $user_id ) ) {
|
2540 |
-
|
2541 |
-
// Make sure this is unique event
|
2542 |
-
if ( ! $this->core->has_entry( 'purchased_from_wishlist', $item->get_id(), $user_id ) ) {
|
2543 |
-
|
2544 |
-
// Execute
|
2545 |
-
$this->core->add_creds(
|
2546 |
-
'purchased_from_wishlist',
|
2547 |
-
$user_id,
|
2548 |
-
$this->prefs['tinvwl_purchased']['creds'],
|
2549 |
-
$this->prefs['tinvwl_purchased']['log'],
|
2550 |
-
$item->get_id(),
|
2551 |
-
array( 'ref_type' => 'post' ),
|
2552 |
-
$this->mycred_type
|
2553 |
-
);
|
2554 |
-
|
2555 |
-
}
|
2556 |
-
|
2557 |
-
}
|
2558 |
-
|
2559 |
-
}
|
2560 |
-
|
2561 |
-
}
|
2562 |
-
|
2563 |
-
/**
|
2564 |
-
* Preferences
|
2565 |
-
*/
|
2566 |
-
public function preferences() {
|
2567 |
-
|
2568 |
-
$prefs = $this->prefs;
|
2569 |
-
|
2570 |
-
?>
|
2571 |
-
<div class="hook-instance">
|
2572 |
-
<h3><?php _e( 'Adding Product to Wishlist', 'ti-woocommerce-wishlist' ); ?></h3>
|
2573 |
-
<div class="row">
|
2574 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
2575 |
-
<div class="form-group">
|
2576 |
-
<label
|
2577 |
-
for="<?php echo $this->field_id( array( 'tinvwl_added' => 'creds' ) ); ?>"><?php _e( 'Points', 'ti-woocommerce-wishlist' ); ?></label>
|
2578 |
-
<input type="text"
|
2579 |
-
name="<?php echo $this->field_name( array( 'tinvwl_added' => 'creds' ) ); ?>"
|
2580 |
-
id="<?php echo $this->field_id( array( 'tinvwl_added' => 'creds' ) ); ?>"
|
2581 |
-
value="<?php echo $this->core->number( $prefs['tinvwl_added']['creds'] ); ?>"
|
2582 |
-
class="form-control"/>
|
2583 |
-
</div>
|
2584 |
-
</div>
|
2585 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
2586 |
-
<div class="form-group">
|
2587 |
-
<label for="<?php echo $this->field_id( array(
|
2588 |
-
'tinvwl_added',
|
2589 |
-
'limit',
|
2590 |
-
) ); ?>"><?php _e( 'Limit', 'ti-woocommerce-wishlist' ); ?></label>
|
2591 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array(
|
2592 |
-
'tinvwl_added',
|
2593 |
-
'limit',
|
2594 |
-
) ), $this->field_id( array(
|
2595 |
-
'tinvwl_added',
|
2596 |
-
'limit',
|
2597 |
-
) ), $prefs['tinvwl_added']['limit'] ); ?>
|
2598 |
-
</div>
|
2599 |
-
</div>
|
2600 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
2601 |
-
<div class="form-group">
|
2602 |
-
<label
|
2603 |
-
for="<?php echo $this->field_id( array( 'tinvwl_added' => 'log' ) ); ?>"><?php _e( 'Log Template', 'ti-woocommerce-wishlist' ); ?></label>
|
2604 |
-
<input type="text"
|
2605 |
-
name="<?php echo $this->field_name( array( 'tinvwl_added' => 'log' ) ); ?>"
|
2606 |
-
id="<?php echo $this->field_id( array( 'tinvwl_added' => 'log' ) ); ?>"
|
2607 |
-
placeholder="<?php _e( 'required', 'ti-woocommerce-wishlist' ); ?>"
|
2608 |
-
value="<?php echo esc_attr( $prefs['tinvwl_added']['log'] ); ?>"
|
2609 |
-
class="form-control"/>
|
2610 |
-
<span class="description"><?php echo $this->available_template_tags( array(
|
2611 |
-
'general',
|
2612 |
-
'post',
|
2613 |
-
) ); ?></span>
|
2614 |
-
</div>
|
2615 |
-
</div>
|
2616 |
-
</div>
|
2617 |
-
<h3><?php _e( 'Purchasing Product from Wishlist', 'ti-woocommerce-wishlist' ); ?></h3>
|
2618 |
-
<div class="row">
|
2619 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
2620 |
-
<div class="form-group">
|
2621 |
-
<label
|
2622 |
-
for="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'creds' ) ); ?>"><?php _e( 'Points', 'ti-woocommerce-wishlist' ); ?></label>
|
2623 |
-
<input type="text"
|
2624 |
-
name="<?php echo $this->field_name( array( 'tinvwl_purchased' => 'creds' ) ); ?>"
|
2625 |
-
id="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'creds' ) ); ?>"
|
2626 |
-
value="<?php echo $this->core->number( $prefs['tinvwl_purchased']['creds'] ); ?>"
|
2627 |
-
class="form-control"/>
|
2628 |
-
</div>
|
2629 |
-
</div>
|
2630 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
2631 |
-
<div class="form-group">
|
2632 |
-
<label for="<?php echo $this->field_id( array(
|
2633 |
-
'tinvwl_purchased',
|
2634 |
-
'limit',
|
2635 |
-
) ); ?>"><?php _e( 'Limit', 'ti-woocommerce-wishlist' ); ?></label>
|
2636 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array(
|
2637 |
-
'tinvwl_purchased',
|
2638 |
-
'limit',
|
2639 |
-
) ), $this->field_id( array(
|
2640 |
-
'tinvwl_purchased',
|
2641 |
-
'limit',
|
2642 |
-
) ), $prefs['tinvwl_purchased']['limit'] ); ?>
|
2643 |
-
</div>
|
2644 |
-
</div>
|
2645 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
2646 |
-
<div class="form-group">
|
2647 |
-
<label
|
2648 |
-
for="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'log' ) ); ?>"><?php _e( 'Log Template', 'ti-woocommerce-wishlist' ); ?></label>
|
2649 |
-
<input type="text"
|
2650 |
-
name="<?php echo $this->field_name( array( 'tinvwl_purchased' => 'log' ) ); ?>"
|
2651 |
-
id="<?php echo $this->field_id( array( 'tinvwl_purchased' => 'log' ) ); ?>"
|
2652 |
-
placeholder="<?php _e( 'required', 'ti-woocommerce-wishlist' ); ?>"
|
2653 |
-
value="<?php echo esc_attr( $prefs['tinvwl_purchased']['log'] ); ?>"
|
2654 |
-
class="form-control"/>
|
2655 |
-
<span class="description"><?php echo $this->available_template_tags( array(
|
2656 |
-
'general',
|
2657 |
-
'post',
|
2658 |
-
) ); ?></span>
|
2659 |
-
</div>
|
2660 |
-
</div>
|
2661 |
-
</div>
|
2662 |
-
</div>
|
2663 |
-
|
2664 |
-
<?php
|
2665 |
-
|
2666 |
-
}
|
2667 |
-
|
2668 |
-
/**
|
2669 |
-
* Sanitise Preferences
|
2670 |
-
*/
|
2671 |
-
public function sanitise_preferences( $data ) {
|
2672 |
-
|
2673 |
-
if ( isset( $data['tinvwl_added']['limit'] ) && isset( $data['tinvwl_added']['limit_by'] ) ) {
|
2674 |
-
$limit = sanitize_text_field( $data['tinvwl_added']['limit'] );
|
2675 |
-
if ( $limit == '' ) {
|
2676 |
-
$limit = 0;
|
2677 |
-
}
|
2678 |
-
$data['tinvwl_added']['limit'] = $limit . '/' . $data['tinvwl_added']['limit_by'];
|
2679 |
-
unset( $data['tinvwl_added']['limit_by'] );
|
2680 |
-
}
|
2681 |
-
|
2682 |
-
if ( isset( $data['tinvwl_purchased']['limit'] ) && isset( $data['tinvwl_purchased']['limit_by'] ) ) {
|
2683 |
-
$limit = sanitize_text_field( $data['tinvwl_purchased']['limit'] );
|
2684 |
-
if ( $limit == '' ) {
|
2685 |
-
$limit = 0;
|
2686 |
-
}
|
2687 |
-
$data['tinvwl_purchased']['limit'] = $limit . '/' . $data['tinvwl_purchased']['limit_by'];
|
2688 |
-
unset( $data['tinvwl_purchased']['limit_by'] );
|
2689 |
-
}
|
2690 |
-
|
2691 |
-
return $data;
|
2692 |
-
|
2693 |
-
}
|
2694 |
-
|
2695 |
-
}
|
2696 |
-
|
2697 |
-
}
|
2698 |
-
|
2699 |
-
add_filter( 'mycred_all_references', 'tinvwl_mycred_references' );
|
2700 |
-
|
2701 |
-
function tinvwl_mycred_references( $references ) {
|
2702 |
-
|
2703 |
-
$references['purchased_from_wishlist'] = __( 'Purchased From Wishlist', 'ti-woocommerce-wishlist' );
|
2704 |
-
$references['added_to_wishlist'] = __( 'Added To Wishlist', 'ti-woocommerce-wishlist' );
|
2705 |
-
|
2706 |
-
return $references;
|
2707 |
-
}
|
2708 |
-
|
2709 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|