Skip to content

Commit fb796f1

Browse files
committedSep 19, 2024·
v3.0.8
1 parent fafa231 commit fb796f1

26 files changed

+2093
-1117
lines changed
 

‎assets/css/algwcwishlistmodal.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
width: 100%;
169169
margin-bottom: 10px;
170170
}
171-
.algwcwishlistmodal-container .create-wishlist-form.is-hidden, .algwcwishlistmodal-container .select-wishlist.is-hidden{
171+
.algwcwishlistmodal-container .create-wishlist-form.is-hidden, .copy-wishlist-form.is-hidden, .algwcwishlistmodal-container .select-wishlist.is-hidden{
172172
display: none;
173173
}
174174

‎assets/css/algwcwishlistmodal.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/js/alg-wc-wish-list.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/js/algwcwishlistmodal.js

+70-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Js responsible for creation and save of multiple wishlist.
55
*
6-
* @version 3.0.4
6+
* @version 3.0.8
77
* @since 3.0.0
88
* @requires jQuery.js
99
*/
@@ -23,19 +23,23 @@
2323
algwcwishlistmodalCreate: '.js-algwcwishlistmodal-btn-create',
2424
algwcwishlistmodalSaveWishlist: '.js-algwcwishlistmodal-btn-save-wishlist',
2525
algwcwishlistmodalSave: '.js-algwcwishlistmodal-btn-save',
26+
algwcwishlistmodalSaveCopy: '.js-algwcwishlistmodal-btn-save-copy',
2627
algwcwishlistmodalCancel: '.js-algwcwishlistmodal-btn-cancel',
28+
algwcwishlistmodalCancelCopy: '.js-algwcwishlistmodal-btn-cancel-copy',
2729
algwcwishlistmodalForm: '.create-wishlist-form',
30+
algwcwishlistmodalFormCopy: '.copy-wishlist-form',
2831
algwcwishlistmodalSelect: '.select-wishlist',
2932
algwcwishlistContainer: '.algwc-wishlist-collections-wrapper',
30-
algwcwishlistDeleteWishlist: '.delete-customized-wishlist'
33+
algwcwishlistDeleteWishlist: '.delete-customized-wishlist',
34+
algwcwishlistCopyWishlist: '.copy-wishlist'
3135
};
3236

3337
var alg_wc_wl_save_multiple_item_data = function () {
34-
var this_btn = jQuery("input#wishlist_name");
38+
var this_input = jQuery("input#wishlist_name");
3539
var data = {
3640
action: alg_wc_wl_ajax.action_save_wishlist,
3741
nonce: alg_wc_wl_ajax.toggle_nonce,
38-
value: this_btn.val()
42+
value: this_input.val()
3943
};
4044
return data;
4145
}
@@ -50,6 +54,19 @@
5054
return data;
5155
}
5256

57+
var alg_wc_wl_save_duplicate_item_data = function () {
58+
var this_input = jQuery("input#duplicate_wishlist_name");
59+
var this_tab = jQuery("input#wishlist_tab_id");
60+
61+
var data = {
62+
action: alg_wc_wl_ajax.action_duplicate_wishlist,
63+
nonce: alg_wc_wl_ajax.toggle_nonce,
64+
value_tab_id: this_tab.val(),
65+
value: this_input.val(),
66+
};
67+
return data;
68+
}
69+
5370
var alg_wc_wl_delete_wishlist_multiple_item_data = function () {
5471
var wishlist_tab_id = $('.delete-customized-wishlist').attr('data-wishlist_tab_id');
5572
var wishlist_page = $('.delete-customized-wishlist').attr('data-page');
@@ -142,6 +159,7 @@
142159
var data = alg_wc_wl_save_multiple_item_data();
143160
jQuery.post(alg_wc_wl.ajaxurl, data, function (response) {
144161
if (response.success) {
162+
145163
Plugin.prototype.showSelect( _obj );
146164
Plugin.prototype.hideForm( _obj );
147165
Plugin.prototype.loadWishlist( _obj );
@@ -153,12 +171,21 @@
153171
$( document ).on( 'click', _obj.algwcwishlistmodalSaveWishlist, function() {
154172

155173
var data = alg_wc_wl_save_wishlist_multiple_item_data();
174+
var btns_with_same_item_id = jQuery(alg_wc_wl_toggle_btn.btn_class + '[data-item_id="' + data.item_id + '"]');
156175
jQuery.post(alg_wc_wl.ajaxurl, data, function (response) {
157176
if (response.success) {
158177
Plugin.prototype.hide( _obj );
159178
Plugin.prototype.hideContainer( _obj );
160179
Plugin.prototype.hideOverlay( _obj );
161180
alg_wc_wish_list.show_notification(response);
181+
182+
btns_with_same_item_id.removeClass('remove add');
183+
184+
if (response.data.added_or_removed === 'removed') {
185+
btns_with_same_item_id.addClass('add');
186+
} else if (response.data.added_or_removed === 'added') {
187+
btns_with_same_item_id.addClass('remove');
188+
}
162189
}
163190
});
164191
});
@@ -173,6 +200,37 @@
173200
});
174201
});
175202

203+
$( document ).on( 'click', _obj.algwcwishlistCopyWishlist, function( event ) {
204+
var title = $(this).attr('data-wishlist_tab_title');
205+
var tabid = $(this).attr('data-wishlist_tab_id');
206+
Plugin.prototype.show( _obj );
207+
Plugin.prototype.showContainer( _obj );
208+
Plugin.prototype.showOverlay( _obj );
209+
Plugin.prototype.hideSelect( _obj );
210+
Plugin.prototype.hideForm( _obj );
211+
Plugin.prototype.showFormCopy( _obj );
212+
213+
$("#duplicate_wishlist_name").val(title + ' (Copy)');
214+
$("#wishlist_tab_id").val(tabid);
215+
});
216+
217+
$( document ).on( 'click', _obj.algwcwishlistmodalCancelCopy, function() {
218+
Plugin.prototype.hide( _obj );
219+
Plugin.prototype.hideContainer( _obj );
220+
Plugin.prototype.hideOverlay( _obj );
221+
$("#duplicate_wishlist_name").val('');
222+
});
223+
224+
$( document ).on( 'click', _obj.algwcwishlistmodalSaveCopy, function() {
225+
226+
var data = alg_wc_wl_save_duplicate_item_data();
227+
jQuery.post(alg_wc_wl.ajaxurl, data, function (response) {
228+
if (response.success) {
229+
location.reload();
230+
}
231+
});
232+
});
233+
176234
$( document ).on( 'click', _obj.algwcwishlistmodal, function( event ) {
177235
event.stopPropagation();
178236
});
@@ -226,6 +284,14 @@
226284

227285
hideForm: function( _obj ) {
228286
$( _obj.algwcwishlistmodalForm ).addClass( 'is-hidden' );
287+
},
288+
289+
showFormCopy: function( _obj ) {
290+
$( _obj.algwcwishlistmodalFormCopy ).removeClass( 'is-hidden' );
291+
},
292+
293+
hideFormCopy: function( _obj ) {
294+
$( _obj.algwcwishlistmodalFormCopy ).addClass( 'is-hidden' );
229295
}
230296
});
231297

‎assets/js/algwcwishlistmodal.min.js

+1-246
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎includes/admin/class-alg-wc-wish-list-settings-admin.php

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class Alg_WC_Wish_List_Settings_Admin extends Alg_WC_Wish_List_Settings_Section {
1515

1616
const OPTION_REPORT_WISHLIST_COL_USERS_PAGE = 'alg_wc_wl_report_col_users_page';
17+
const OPTION_REPORT_WISHLIST_COL_USERS_PAGE_CLEAR_WISHLIST = 'alg_wc_wl_report_col_users_page_clear_wishlist';
1718
const OPTION_REPORT_WISHLIST_COL_PRODUCTS_PAGE = 'alg_wc_wl_report_col_products_page';
1819
const OPTION_REPORT_WISHLIST_COL_PRODUCTS_UNLOGGED = 'alg_wc_wl_report_col_products_page_u';
1920
const OPTION_REPORT_WISHLIST_PRODUCT_EXPORT_COL = 'alg_wc_wl_report_prod_export_col';
@@ -66,6 +67,13 @@ function get_settings( $settings = array() ) {
6667
'id' => self::OPTION_REPORT_WISHLIST_COL_USERS_PAGE,
6768
'default' => 'no',
6869
),
70+
array(
71+
'title' => __( 'Users Page "Clear Wishlist" Button', 'wish-list-for-woocommerce' ),
72+
'type' => 'checkbox',
73+
'desc' => sprintf( __( 'Enable a column on the <a href="%s">users list page</a> showing a button able to clear Wishlist.', 'wish-list-for-woocommerce' ), admin_url( 'users.php' ) ),
74+
'id' => self::OPTION_REPORT_WISHLIST_COL_USERS_PAGE_CLEAR_WISHLIST,
75+
'default' => 'no',
76+
),
6977
array(
7078
'title' => __( 'Products Page', 'wish-list-for-woocommerce' ),
7179
'type' => 'checkbox',

‎includes/admin/class-alg-wc-wish-list-settings-list.php

+42
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,46 @@ function get_settings( $settings = array() ) {
123123
'type' => 'sectionend',
124124
'id' => 'alg_wc_wl_loptions',
125125
),
126+
127+
array(
128+
'title' => __( 'Dropdown sorting', 'wish-list-for-woocommerce' ),
129+
'type' => 'title',
130+
'desc' => __( 'Sort the wishlist items by choosing an option from the dropdown.', 'wish-list-for-woocommerce' ),
131+
'id' => 'alg_wc_wl_dropdown_sorting_opts',
132+
),
133+
134+
array(
135+
'title' => __( 'Dropdown ordering', 'wish-list-for-woocommerce' ),
136+
'desc' => __( 'Enable wishlist item ordering by choosing an option from the dropdown. Ensure the dropdown also appears on the wishlist page.', 'wish-list-for-woocommerce' ) . '<br>' . apply_filters( 'alg_wc_wishlist_settings', sprintf( __( 'This is a Pro feature, you will need <a target="_blank" href="%1$s">Wishlist for WooCommerce Pro</a> to enable it.', 'wish-list-for-woocommerce' ), esc_url( $this->pro_version_url ) ) ),
137+
'id' => 'alg_wc_wl_dropdown_sorting',
138+
'default' => 'no',
139+
'type' => 'checkbox',
140+
'custom_attributes' => apply_filters( 'alg_wc_wishlist_settings', array( 'disabled' => 'disabled' ) )
141+
),
142+
array(
143+
'type' => 'sectionend',
144+
'id' => 'alg_wc_wl_dropdown_sorting_opts',
145+
),
146+
147+
array(
148+
'title' => __( 'Duplicate', 'wish-list-for-woocommerce' ),
149+
'type' => 'title',
150+
'desc' => __( 'Duplicate functionality for wishlist.', 'wish-list-for-woocommerce' ),
151+
'id' => 'alg_wc_wl_duplicate_opts',
152+
),
153+
154+
array(
155+
'title' => __( 'Duplicate Functionality', 'wish-list-for-woocommerce' ),
156+
'desc' => __( 'A "COPY" button will appear on every wishlist page. This function is applicable to logged-in users.', 'wish-list-for-woocommerce' ) . '<br>' . apply_filters( 'alg_wc_wishlist_settings', sprintf( __( 'This is a Pro feature, you will need <a target="_blank" href="%1$s">Wishlist for WooCommerce Pro</a> to enable it.', 'wish-list-for-woocommerce' ), esc_url( $this->pro_version_url ) ) ),
157+
'id' => 'alg_wc_wl_duplicate_option',
158+
'default' => 'no',
159+
'type' => 'checkbox',
160+
'custom_attributes' => apply_filters( 'alg_wc_wishlist_settings', array( 'disabled' => 'disabled' ) )
161+
),
162+
array(
163+
'type' => 'sectionend',
164+
'id' => 'alg_wc_wl_duplicate_opts',
165+
),
126166

127167
// Columns.
128168
array(
@@ -359,6 +399,8 @@ function get_settings( $settings = array() ) {
359399
'id' => 'alg_wc_wl_arrow_sorting_opts',
360400
),
361401

402+
403+
362404
array(
363405
'title' => __( 'Note field', 'wish-list-for-woocommerce' ),
364406
'type' => 'title',

‎includes/admin/class-alg-wc-wish-list-settings-texts.php

+38-16
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515

1616
class Alg_WC_Wish_List_Settings_Texts extends Alg_WC_Wish_List_Settings_Section {
1717

18-
const OPTION_TEXTS_ADD_TO_WISH_LIST = 'alg_wc_wl_texts_add_to_wish_list';
19-
const OPTION_TEXTS_SEE_YOUR_WISH_LIST = 'alg_wc_wl_texts_see_your_wish_list';
20-
const OPTION_TEXTS_ADDED_TO_WISH_LIST = 'alg_wc_wl_texts_remove_added_to_wish_list';
21-
const OPTION_TEXTS_REMOVE_FROM_WISH_LIST = 'alg_wc_wl_texts_remove_from_wish_list';
22-
const OPTION_TEXTS_REMOVED_FROM_WISH_LIST = 'alg_wc_wl_texts_removed_from_wish_list';
23-
const OPTION_TEXTS_ERROR = 'alg_wc_wl_texts_error';
24-
const OPTION_TEXTS_EMAIL_TEXTAREA = 'alg_wc_wl_texts_email_textarea';
25-
const OPTION_TEXTS_EMAIL_LINK = 'alg_wc_wl_texts_email_link';
26-
const OPTION_TEXTS_SHARE = 'alg_wc_wl_texts_share';
27-
const OPTION_TEXTS_SHARE_ADMIN = 'alg_wc_wl_texts_admin';
28-
const OPTION_TEXTS_SHARE_FRIENDS = 'alg_wc_wl_texts_friends';
29-
const OPTION_TEXTS_TWITTER_SHARE = 'alg_wc_wl_texts_twitter';
30-
const OPTION_TEXTS_DISALLOW_UNLOGGED = 'alg_wc_wl_texts_disallow_unlogged';
31-
const OPTION_TEXTS_EMPTY_WISHLIST = 'alg_wc_wl_texts_empty_wishlist';
32-
const OPTION_TEXTS_REMOVE_ALL_BTN_LABEL ='alg_wc_wl_texts_remove_all_btn_label';
33-
const OPTION_TEXTS_REMOVE_ALL_SUCCESS_TEXT = 'alg_wc_wl_texts_remove_all_success_text';
18+
const OPTION_TEXTS_ADD_TO_WISH_LIST = 'alg_wc_wl_texts_add_to_wish_list';
19+
const OPTION_TEXTS_SEE_YOUR_WISH_LIST = 'alg_wc_wl_texts_see_your_wish_list';
20+
const OPTION_TEXTS_ADDED_TO_WISH_LIST = 'alg_wc_wl_texts_remove_added_to_wish_list';
21+
const OPTION_TEXTS_REMOVE_FROM_WISH_LIST = 'alg_wc_wl_texts_remove_from_wish_list';
22+
const OPTION_TEXTS_REMOVED_FROM_WISH_LIST = 'alg_wc_wl_texts_removed_from_wish_list';
23+
const OPTION_TEXTS_ERROR = 'alg_wc_wl_texts_error';
24+
const OPTION_TEXTS_EMAIL_TEXTAREA = 'alg_wc_wl_texts_email_textarea';
25+
const OPTION_TEXTS_EMAIL_LINK = 'alg_wc_wl_texts_email_link';
26+
const OPTION_TEXTS_SHARE = 'alg_wc_wl_texts_share';
27+
const OPTION_TEXTS_SHARE_ADMIN = 'alg_wc_wl_texts_admin';
28+
const OPTION_TEXTS_SHARE_FRIENDS = 'alg_wc_wl_texts_friends';
29+
const OPTION_TEXTS_TWITTER_SHARE = 'alg_wc_wl_texts_twitter';
30+
const OPTION_TEXTS_DISALLOW_UNLOGGED = 'alg_wc_wl_texts_disallow_unlogged';
31+
const OPTION_TEXTS_EMPTY_WISHLIST = 'alg_wc_wl_texts_empty_wishlist';
32+
const OPTION_TEXTS_REMOVE_ALL_BTN_LABEL ='alg_wc_wl_texts_remove_all_btn_label';
33+
const OPTION_TEXTS_REMOVE_ALL_SUCCESS_TEXT = 'alg_wc_wl_texts_remove_all_success_text';
34+
const OPTION_TEXTS_ADDED_TO_WISH_LIST_MULTIPLE = 'alg_wc_wl_texts_add_to_wish_list_multiple';
3435

3536
protected $pro_version_url = 'https://wpcodefactory.com/item/wish-list-woocommerce/';
3637

@@ -253,6 +254,27 @@ function get_settings( $settings = null ) {
253254
'type' => 'sectionend',
254255
'id' => 'alg_wc_wl_texts_email_sharing_opt',
255256
),
257+
258+
// Social
259+
array(
260+
'title' => __( 'Multiple Wishlist', 'wish-list-for-woocommerce' ),
261+
'type' => 'title',
262+
'desc' => __( 'Sharing options', 'wish-list-for-woocommerce' ),
263+
'id' => 'alg_wc_wl_texts_multiple_wishlist_opt',
264+
),
265+
array(
266+
'title' => __( 'Saved to wishlist', 'wish-list-for-woocommerce' ),
267+
'id' => self::OPTION_TEXTS_ADDED_TO_WISH_LIST_MULTIPLE,
268+
'desc' => __( 'Notification text after saved wishlist.', 'wish-list-for-woocommerce' ),
269+
'desc_tip' => __( '%s will be replaced by the product title', 'wish-list-for-woocommerce' ),
270+
'default' => __('Wishlist successfully saved.', 'wish-list-for-woocommerce' ),
271+
'type' => 'text',
272+
'class' => 'regular-input',
273+
),
274+
array(
275+
'type' => 'sectionend',
276+
'id' => 'alg_wc_wl_texts_multiple_wishlist_opt',
277+
),
256278
);
257279

258280
return parent::get_settings( array_merge( $settings, $new_settings ) );

‎includes/class-alg-wc-wish-list-core.php

+55-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wish List for WooCommerce - Core Class.
44
*
5-
* @version 3.0.7
5+
* @version 3.0.8
66
* @since 1.0.0
77
* @author WPFactory.
88
*/
@@ -21,7 +21,7 @@ final class Alg_WC_Wish_List_Core {
2121
* @var string
2222
* @since 1.0.0
2323
*/
24-
public $version = '3.0.7';
24+
public $version = '3.0.8';
2525

2626
/**
2727
* @var Alg_WC_Wish_List_Core The single instance of the class
@@ -119,7 +119,7 @@ public static function delete_meta_data(){
119119
/**
120120
* Constructor.
121121
*
122-
* @version 3.0.7
122+
* @version 3.0.8
123123
* @since 1.0.0
124124
*/
125125
function __construct() {
@@ -278,9 +278,34 @@ function __construct() {
278278
$compatibility = new Alg_WC_Wish_List_Compatibility();
279279
$compatibility->init();
280280

281+
add_action( 'admin_notices', array( $this, 'clear_wishlist_admin_notice' ) );
282+
283+
// Admin Multiple Wishlist.
284+
$this->admin_multiple_wishlist = new Alg_WC_Wish_List_Admin_Multiple();
285+
$this->admin_multiple_wishlist->init();
286+
287+
}
288+
}
289+
290+
291+
292+
/**
293+
* Shows a error message after cleared message
294+
*
295+
* @version 3.0.8
296+
* @since 3.0.8
297+
*/
298+
function clear_wishlist_admin_notice() {
299+
if ( isset( $_GET['cleared'] ) && $_GET['cleared'] == '1' ) {
300+
?>
301+
<div class="notice is-dismissible updated">
302+
<p><?php _e( 'Wishlist cleared.' ); ?></p>
303+
</div>
304+
<?php
281305
}
282306
}
283307

308+
284309
/**
285310
* set_all_removed_text.
286311
*
@@ -616,7 +641,7 @@ public function woocommerce_locate_template( $template, $template_name, $templat
616641
* @since 1.2.8
617642
*/
618643
private function handle_ajax() {
619-
644+
620645
// Get wish list shortcode via ajax
621646
$action = Alg_WC_Wish_List_Ajax::ACTION_GET_WISH_LIST_SHORTCODE;
622647
add_action( "wp_ajax_nopriv_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'get_wish_list_shortcode' ) );
@@ -656,6 +681,16 @@ private function handle_ajax() {
656681
$action = Alg_WC_Wish_List_Ajax::ACTION_GET_MULTIPLE_WISHLIST;
657682
add_action( "wp_ajax_nopriv_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'get_multiple_wishlist' ) );
658683
add_action( "wp_ajax_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'get_multiple_wishlist' ) );
684+
685+
// clear wishlist
686+
$action = Alg_WC_Wish_List_Ajax::ACTION_GET_CLEAR_WISHLIST_ADMIN;
687+
add_action( "wp_ajax_nopriv_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'admin_clear_wishlist' ) );
688+
add_action( "wp_ajax_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'admin_clear_wishlist' ) );
689+
690+
// Save Duplicate wishlist
691+
$action = Alg_WC_Wish_List_Ajax::ACTION_DUPLICATE_WISHLIST;
692+
add_action( "wp_ajax_nopriv_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'save_duplicate_wishlist' ) );
693+
add_action( "wp_ajax_{$action}", array( Alg_WC_Wish_List_Ajax::get_class_name(), 'save_duplicate_wishlist' ) );
659694
}
660695

661696
/**
@@ -735,6 +770,7 @@ function enqueue_frontend_scripts() {
735770
*/
736771
public function override_toggle_item_texts($params){
737772
$params['added'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ADDED_TO_WISH_LIST ) ), 'wish-list-for-woocommerce' );
773+
$params['saved'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ADDED_TO_WISH_LIST_MULTIPLE ) ), 'wish-list-for-woocommerce' );
738774
$params['removed'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_REMOVED_FROM_WISH_LIST ) ), 'wish-list-for-woocommerce' );
739775
$params['error'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ERROR ) ), 'wish-list-for-woocommerce' );
740776
$params['see_wish_list'] = __(sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_SEE_YOUR_WISH_LIST ) ), 'wish-list-for-woocommerce');
@@ -1396,6 +1432,21 @@ function handle_responsive_script() {
13961432
<div class="float-clear"></div>
13971433
</div>
13981434
</div>
1435+
1436+
<div class="copy-wishlist-form is-hidden">
1437+
<h2><?php _e( 'Copy Wishlist', 'wish-list-for-woocommerce' ); ?></h2>
1438+
<div class="form-field-wrap">
1439+
<label for="duplicate_wishlist_name"><?php _e( 'Duplicate Wishlist Name', 'wish-list-for-woocommerce' ); ?></label>
1440+
<input type="text" name="duplicate_wishlist_name" id="duplicate_wishlist_name" class="form-field">
1441+
</div>
1442+
<div class="button-split">
1443+
<button class="page__btn page__btn--create js-algwcwishlistmodal-btn-save-copy"><?php _e( 'Save Wishlist', 'wish-list-for-woocommerce' ); ?></button>
1444+
<button class="page__btn page__btn--save js-algwcwishlistmodal-btn-cancel-copy"><?php _e( 'Cancel', 'wish-list-for-woocommerce' ); ?></button>
1445+
<div class="float-clear"></div>
1446+
<input type="hidden" name="wishlist_tab_id" id="wishlist_tab_id" value="d">
1447+
</div>
1448+
</div>
1449+
13991450
</div>
14001451
</div>
14011452
<div class="algwcwishlistmodal-overlay js-algwcwishlistmodal-overlay"></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Wishlist for WooCommerce - Admin Multiple Wishlist
4+
*
5+
* @version 3.0.8
6+
* @since 3.0.8
7+
* @author WPFactory
8+
*/
9+
if ( ! defined( 'ABSPATH' ) )
10+
exit; // Exit if accessed directly
11+
12+
if ( ! class_exists( 'Alg_WC_Wish_List_Admin_Multiple' ) ) {
13+
14+
class Alg_WC_Wish_List_Admin_Multiple {
15+
16+
/**
17+
* init.
18+
*
19+
* @version 3.0.8
20+
* @since 3.0.8
21+
*
22+
*/
23+
function init() {
24+
if( 'yes' === get_option( 'alg_wc_wl_multiple_wishlist_enabled', 'no' ) ) {
25+
add_filter( 'alg_wc_wl_locate_template', array( $this, 'admin_profile_template_upgrade_to_multiple_wishlist' ), 99, 3 );
26+
}
27+
}
28+
29+
/**
30+
* admin_profile_template_upgrade_to_multiple_wishlist.
31+
*
32+
* @version 3.0.8
33+
* @since 3.0.8
34+
*
35+
* @param $final_file, $params, $path
36+
*
37+
* @return $final_file
38+
*/
39+
function admin_profile_template_upgrade_to_multiple_wishlist( $final_file, $params, $path ) {
40+
41+
42+
if( $path == 'admin-wish-list.php' ) {
43+
44+
$path = 'admin-wish-list-multiple.php';
45+
46+
$located = locate_template( array(
47+
ALG_WC_WL_FOLDER_NAME . '/' . $path,
48+
) );
49+
50+
$plugin_path = ALG_WC_WL_DIR . 'templates' . DIRECTORY_SEPARATOR . $path;
51+
52+
if ( ! $located && file_exists( $plugin_path ) ) {
53+
$final_file = $plugin_path;
54+
} elseif ( $located ) {
55+
$final_file = $located;
56+
}
57+
58+
return $final_file;
59+
}
60+
61+
62+
return $final_file;
63+
}
64+
65+
66+
}
67+
}

‎includes/free/class-alg-wc-wish-list-ajax.php

+194-24
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ class Alg_WC_Wish_List_Ajax {
1717
const ACTION_GET_WISH_LIST = 'alg_wc_wl_get_wish_list';
1818
const ACTION_REMOVE_ALL_FROM_WISH_LIST = 'alg_wc_wl_remove_all_from_wish_list';
1919
const ACTION_GET_MULTIPLE_WISHLIST = 'alg_wc_wl_get_multiple_wish_list';
20+
const ACTION_GET_CLEAR_WISHLIST_ADMIN = 'alg_wc_wl_clear_wish_list_admin';
2021
const ACTION_SAVE_MULTIPLE_WISHLIST = 'alg_wc_wl_save_multiple_wish_list';
2122
const ACTION_DELETE_MULTIPLE_WISHLIST = 'alg_wc_wl_delete_multiple_wish_list';
2223
const ACTION_SAVE_WISHLIST = 'alg_wc_wl_save_to_multiple_wish_list';
24+
const ACTION_DUPLICATE_WISHLIST = 'alg_wc_wl_save_duplicate_wish_list';
2325
const ACTION_GET_WISH_LIST_SHORTCODE = 'alg_wc_wl_pro_get_wish_list_sc';
2426

2527

@@ -144,6 +146,7 @@ public static function localize_script( $script ) {
144146
'is_multiple_wishlist_enabled' => get_option( 'alg_wc_wl_multiple_wishlist_enabled', 'no' ),
145147
'is_current_page_wishlist' => self::is_current_page_wishlist(),
146148
'action_save_wishlist' => self::ACTION_SAVE_WISHLIST,
149+
'action_duplicate_wishlist' => self::ACTION_DUPLICATE_WISHLIST,
147150
'ajax_action' => self::ACTION_GET_WISH_LIST,
148151
'nonce' => wp_create_nonce( 'alg_wc_wl' ),
149152
'toggle_nonce' => wp_create_nonce( 'alg_wc_wl_toggle_item' ),
@@ -307,7 +310,7 @@ public static function get_wishlist_via_ajax( $handle ) {
307310
/**
308311
* Ajax method for save new wishlist.
309312
*
310-
* @version 2.0.5
313+
* @version 3.0.8
311314
* @since 2.0.5
312315
*/
313316
public static function save_to_multiple_wishlist() {
@@ -332,7 +335,12 @@ public static function save_to_multiple_wishlist() {
332335
$wishlist_list = array();
333336
}
334337
array_push( $wishlist_list, $value );
335-
set_transient( "{$transient}{$user_id}", $wishlist_list, 1 * MONTH_IN_SECONDS );
338+
339+
if( is_int( $user_id ) && $user_id > 0 ) {
340+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE_NAME, $wishlist_list );
341+
} else {
342+
set_transient( "{$transient}{$user_id}", $wishlist_list, 1 * MONTH_IN_SECONDS );
343+
}
336344

337345
$response = array( 'wishlist_list' => ! is_array( $wishlist_list ) ? array() : $wishlist_list );
338346

@@ -343,7 +351,7 @@ public static function save_to_multiple_wishlist() {
343351
/**
344352
* Ajax method for delete multiple wishlist item.
345353
*
346-
* @version 3.0.4
354+
* @version 3.0.8
347355
* @since 2.0.5
348356
*/
349357
public static function delete_multiple_wishlist_item($item_id, $tab_id) {
@@ -365,8 +373,16 @@ public static function delete_multiple_wishlist_item($item_id, $tab_id) {
365373
}
366374
}
367375

368-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
369-
set_transient( "{$transient}{$user_id}", $wishlist_list_items, 1 * MONTH_IN_SECONDS );
376+
if( is_int( $user_id ) && $user_id > 0 ) {
377+
378+
// remove only multiple wishlist items
379+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, $wishlist_list_items );
380+
} else {
381+
382+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
383+
set_transient( "{$transient}{$user_id}", $wishlist_list_items, 1 * MONTH_IN_SECONDS );
384+
385+
}
370386

371387
$product = wc_get_product( $item_id );
372388

@@ -404,7 +420,7 @@ public static function delete_multiple_wishlist_item($item_id, $tab_id) {
404420
/**
405421
* Ajax method for delete multiple wishlist.
406422
*
407-
* @version 2.0.5
423+
* @version 3.0.8
408424
* @since 2.0.5
409425
*/
410426
public static function delete_multiple_wishlist() {
@@ -434,11 +450,22 @@ public static function delete_multiple_wishlist() {
434450
unset( $wishlist_list_items[$index] );
435451
}
436452

437-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE;
438-
set_transient( "{$transient}{$user_id}", $wishlist_list, 1 * MONTH_IN_SECONDS );
453+
if( is_int( $user_id ) && $user_id > 0 ) {
454+
455+
// save only multiple wishlist name
456+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE_NAME, $wishlist_list );
457+
458+
// save only multiple wishlist items
459+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, $wishlist_list_items );
460+
461+
} else {
439462

440-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
441-
set_transient( "{$transient}{$user_id}", $wishlist_list_items, 1 * MONTH_IN_SECONDS );
463+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE;
464+
set_transient( "{$transient}{$user_id}", $wishlist_list, 1 * MONTH_IN_SECONDS );
465+
466+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
467+
set_transient( "{$transient}{$user_id}", $wishlist_list_items, 1 * MONTH_IN_SECONDS );
468+
}
442469

443470
}
444471

@@ -468,15 +495,21 @@ public static function delete_multiple_wishlist() {
468495
/**
469496
* Ajax method for save to new multiple wishlist.
470497
*
471-
* @version 2.0.5
498+
* @version 3.0.8
472499
* @since 2.0.5
473500
*/
474501
public static function save_multiple_wishlist() {
475502
$args = wp_parse_args( $_POST, array(
476503
'ignore_excluded_items' => false,
504+
'value' => array(),
477505
) );
478506

479-
$value = $args['value'];
507+
if( isset($args['value']) ) {
508+
$value = $args['value'];
509+
} else {
510+
$value = array();
511+
}
512+
480513
$item_id = $args['item_id'];
481514

482515
if ( is_user_logged_in() ) {
@@ -496,10 +529,18 @@ public static function save_multiple_wishlist() {
496529
}
497530
}
498531

532+
if ( is_int( $user_id ) && $user_id > 0 ) {
533+
534+
// get only multiple wishlist items
535+
$arrange_arr = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
536+
537+
} else {
499538

539+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
540+
$arrange_arr = get_transient( "{$transient}{$user_id}" );
541+
542+
}
500543

501-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
502-
$arrange_arr = get_transient( "{$transient}{$user_id}" );
503544
if ( ! $arrange_arr ) {
504545
$arrange_arr = array();
505546
}
@@ -531,7 +572,15 @@ public static function save_multiple_wishlist() {
531572
}
532573
}
533574

534-
set_transient( "{$transient}{$user_id}", $arrange_arr, 1 * MONTH_IN_SECONDS );
575+
if ( is_int( $user_id ) && $user_id > 0 ) {
576+
577+
// save only multiple wishlist items
578+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, $arrange_arr );
579+
580+
} else {
581+
582+
set_transient( "{$transient}{$user_id}", $arrange_arr, 1 * MONTH_IN_SECONDS );
583+
}
535584

536585

537586
$product = wc_get_product( $item_id );
@@ -542,6 +591,7 @@ public static function save_multiple_wishlist() {
542591

543592
$params = apply_filters( 'alg_wc_wl_toggle_item_texts', array(
544593
'added' => __( '%s was successfully added to wishlist.', 'wish-list-for-woocommerce' ),
594+
'saved' => __( 'Wishlist successfully saved.', 'wish-list-for-woocommerce' ),
545595
'removed' => __( '%s was successfully removed from wishlist', 'wish-list-for-woocommerce' ),
546596
'see_wish_list' => __( 'See your wishlist', 'wish-list-for-woocommerce' ),
547597
'error' => apply_filters( 'alg_wc_wl_error_text', __( 'Sorry, Some error occurred. Please, try again later.', 'wish-list-for-woocommerce' ) ),
@@ -551,22 +601,44 @@ public static function save_multiple_wishlist() {
551601
$wish_list_page_id = Alg_WC_Wish_List_Page::get_wish_list_page_id();
552602
$wish_list_permalink = get_permalink( $wish_list_page_id );
553603
$see_your_wishlist_message = $params['see_wish_list'];
554-
$added_message = sprintf(
555-
$params['added'],
556-
'<b>' . $product->get_name() . '</b>'
604+
$saved_message = sprintf(
605+
$params['saved'],
606+
''
557607
);
558-
559-
$message = "{$added_message}<br /> <a class='alg-wc-wl-notification-link' href='{$wish_list_permalink}'>{$see_your_wishlist_message}</a>";
608+
609+
$added_or_removed = 'removed';
610+
611+
if ( Alg_WC_Wish_List_Item::is_item_in_wish_list( $item_id, $user_id ) ) {
612+
$added_or_removed = 'added';
613+
}
614+
615+
$message = "{$saved_message}<br /> <a class='alg-wc-wl-notification-link' href='{$wish_list_permalink}'>{$see_your_wishlist_message}</a>";
560616
$response = array(
561617
'ok' => true,
562618
'message' => $message,
563619
'action' => $action,
564-
'icon' => $icon
620+
'icon' => $icon,
621+
'added_or_removed' => $added_or_removed
565622
);
566623

567624
wp_send_json_success( $response );
568625
}
569626

627+
/**
628+
* wishlist_multi_array_search
629+
*
630+
* @version 3.0.8
631+
* @since 3.0.8
632+
*/
633+
public static function wishlist_multi_array_search($search_for, $search_in) {
634+
foreach ($search_in as $element) {
635+
if ( ($element === $search_for) || (is_array($element) && self::wishlist_multi_array_search($search_for, $element)) ){
636+
return true;
637+
}
638+
}
639+
return false;
640+
}
641+
570642
/**
571643
* Ajax method for get wish list shortcode
572644
*
@@ -609,7 +681,7 @@ public static function add_variable_product_data_to_response_text( $texts ) {
609681
/**
610682
* Ajax method for get from new multiple wishlist.
611683
*
612-
* @version 2.0.5
684+
* @version 3.0.8
613685
* @since 2.0.5
614686
*/
615687
public static function get_multiple_wishlist() {
@@ -628,8 +700,15 @@ public static function get_multiple_wishlist() {
628700

629701
$wishlist_list = Alg_WC_Wish_List::get_multiple_wishlists( $user_id );
630702

631-
$transient_store = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
632-
$arrange_arr = get_transient( "{$transient_store}{$user_id}" );
703+
if ( is_int( $user_id ) && $user_id > 0 ) {
704+
705+
// get only multiple wishlist items
706+
$arrange_arr = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
707+
} else {
708+
709+
$transient_store = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
710+
$arrange_arr = get_transient( "{$transient_store}{$user_id}" );
711+
}
633712
if ( ! $arrange_arr ) {
634713
$arrange_arr = array();
635714
}
@@ -691,6 +770,97 @@ public static function get_multiple_wishlist() {
691770

692771
wp_send_json_success( $response );
693772
}
773+
774+
/**
775+
* Ajax method for get from new multiple wishlist.
776+
*
777+
* @version 3.0.8
778+
* @since 3.0.8
779+
*/
780+
public static function admin_clear_wishlist() {
781+
$args = wp_parse_args( $_GET, array(
782+
'user_id' => 0,
783+
) );
784+
if( $args['user_id'] > 0 ) {
785+
$user_id = $args['user_id'];
786+
delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM );
787+
delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_METAS );
788+
delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE );
789+
delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_METAS_MULTIPLE );
790+
delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE_NAME );
791+
delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_METAS_MULTIPLE_NAME );
792+
}
793+
$ref_url = add_query_arg('cleared', '1', wp_get_referer());
794+
wp_safe_redirect( $ref_url );
795+
exit;
796+
}
797+
798+
/**
799+
* Ajax method for copy wishlist.
800+
*
801+
* @version 3.0.8
802+
* @since 3.0.8
803+
*/
804+
public static function save_duplicate_wishlist() {
805+
806+
$args = wp_parse_args( $_POST, array(
807+
'value_tab_id' => '',
808+
'value' => '',
809+
) );
810+
811+
$value = $args['value'];
812+
$value_tab_id = $args['value_tab_id'];
813+
814+
if( $value_tab_id !== '' ) {
815+
$value_tab_id = (int) $value_tab_id;
816+
} else {
817+
$value_tab_id = 'd';
818+
}
819+
820+
$wishlisted_items = array();
821+
822+
$user_id = get_current_user_id();
823+
$use_id_from_unlogged_user = false;
824+
$ignore_excluded_items = false;
825+
826+
827+
828+
// save wishlist name
829+
$wishlist_list = Alg_WC_Wish_List::get_multiple_wishlists( $user_id );
830+
if ( ! $wishlist_list ) {
831+
$wishlist_list = array();
832+
}
833+
array_push( $wishlist_list, $value );
834+
835+
if( is_int( $user_id ) && $user_id > 0 ) {
836+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE_NAME, $wishlist_list );
837+
}
838+
839+
if( is_int( $value_tab_id ) ) {
840+
$wishlisted_items = Alg_WC_Wish_List::get_multiple_wishlist_items( $user_id, $use_id_from_unlogged_user, $ignore_excluded_items, $value_tab_id );
841+
} else if ( $value_tab_id == 'd' ) {
842+
$wishlisted_items = Alg_WC_Wish_List::get_wish_list( $user_id, $use_id_from_unlogged_user, $ignore_excluded_items );
843+
}
844+
845+
if ( is_int( $user_id ) && $user_id > 0 ) {
846+
847+
// get only multiple wishlist items
848+
$arrange_arr = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
849+
850+
if( empty($arrange_arr) ) {
851+
$arrange_arr = array();
852+
}
853+
854+
$arrange_arr[] = $wishlisted_items;
855+
// save only multiple wishlist items
856+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, $arrange_arr );
857+
858+
}
859+
860+
861+
$response = array('ok' => true);
862+
wp_send_json_success( $response );
863+
}
694864

695865
}
696866

‎includes/free/class-alg-wc-wish-list-item.php

+43-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static function add_item_to_wish_list( $item_id, $user_id = null, $use_id
8484
/**
8585
* Add metas to wishlist item.
8686
*
87-
* @version 1.8.7
87+
* @version 3.0.8
8888
* @since 1.2.6
8989
*
9090
* @param $item_id
@@ -119,9 +119,19 @@ public static function update_wish_list_item_metas( $item_id, $meta_key, $meta_v
119119

120120
// multiple wishlist
121121
if ( $tab_id > 0 ) {
122-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_METAS_MULTIPLE_STORE;
123-
$old_user_meta_multiple = get_transient( "{$transient}{$user_id}" );
124-
$old_user_meta = ( isset( $old_user_meta_multiple[$tab_id] ) ? $old_user_meta_multiple[$tab_id] : array() );
122+
123+
if ( is_int( $user_id ) && $user_id > 0 ) {
124+
125+
// get only multiple wishlist items
126+
$old_user_meta_multiple = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_METAS_MULTIPLE, true );
127+
128+
} else {
129+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_METAS_MULTIPLE_STORE;
130+
$old_user_meta_multiple = get_transient( "{$transient}{$user_id}" );
131+
}
132+
133+
$old_user_meta = ( isset( $old_user_meta_multiple[$tab_id] ) ? $old_user_meta_multiple[$tab_id] : array() );
134+
125135
}
126136

127137
// If there is an old meta, update only that product id with a specific meta
@@ -152,7 +162,15 @@ public static function update_wish_list_item_metas( $item_id, $meta_key, $meta_v
152162

153163
if ( $tab_id > 0 ) {
154164
$new_user_meta_multiple[$tab_id] = $new_user_meta;
155-
set_transient( "{$transient}{$user_id}", $new_user_meta_multiple, 1 * MONTH_IN_SECONDS );
165+
166+
if( is_int( $user_id ) && $user_id > 0 ) {
167+
168+
// update only multiple wishlist items
169+
update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_METAS_MULTIPLE, $new_user_meta_multiple );
170+
} else {
171+
172+
set_transient( "{$transient}{$user_id}", $new_user_meta_multiple, 1 * MONTH_IN_SECONDS );
173+
}
156174
$response = $item_id;
157175
} else {
158176
// Update meta
@@ -208,7 +226,7 @@ public static function remove_item_from_wish_list( $item_id, $user_id = null, $u
208226
/**
209227
* Check if an item is already in the user wishlist.
210228
*
211-
* @version 1.1.6
229+
* @version 3.0.10
212230
* @since 1.0.0
213231
*
214232
* @param $item_id
@@ -219,7 +237,25 @@ public static function remove_item_from_wish_list( $item_id, $user_id = null, $u
219237
* @throws Exception
220238
*/
221239
public static function is_item_in_wish_list( $item_id, $user_id = null, $use_id_from_unlogged_user = false ) {
240+
222241
$wishlisted_items = Alg_WC_Wish_List::get_wish_list( $user_id, $use_id_from_unlogged_user );
242+
243+
if ( 'yes' === get_option( 'alg_wc_wl_multiple_wishlist_enabled', 'no' ) ) {
244+
245+
$multiple_wishlisted_items = Alg_WC_Wish_List::get_multiple_wishlist_unique_items( $user_id );
246+
247+
if ( is_array( $wishlisted_items ) && count( $wishlisted_items ) > 0 && is_array( $multiple_wishlisted_items ) && count( $multiple_wishlisted_items ) > 0 ) {
248+
// Merge the arrays
249+
$merged_items = array_merge($wishlisted_items, $multiple_wishlisted_items);
250+
251+
// Remove duplicates
252+
$wishlisted_items = array_unique($merged_items);
253+
} else if ( is_array( $multiple_wishlisted_items ) && count( $multiple_wishlisted_items ) > 0 ) {
254+
$wishlisted_items = $multiple_wishlisted_items;
255+
}
256+
257+
}
258+
223259
$response = false;
224260
if ( is_array( $wishlisted_items ) && count( $wishlisted_items ) > 0 ) {
225261
$index = array_search( $item_id, $wishlisted_items );
@@ -231,6 +267,7 @@ public static function is_item_in_wish_list( $item_id, $user_id = null, $use_id_
231267
} else {
232268
$response = false;
233269
}
270+
234271
return $response;
235272
}
236273

‎includes/free/class-alg-wc-wish-list-note-field.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function get_field_label() {
9191
/**
9292
* get_field_output.
9393
*
94-
* @version 2.0.5
94+
* @version 3.0.8
9595
* @since 1.7.4
9696
*
9797
* @param $product
@@ -118,7 +118,15 @@ function get_field_output( $product, $params = null ) {
118118
$user_id = Alg_WC_Wish_List_Unlogged_User::get_unlogged_user_id();
119119
}
120120

121-
$old_user_meta_multiple = get_transient( "{$transient}{$user_id}" );
121+
if ( is_int( $user_id ) && $user_id > 0 ) {
122+
123+
// get only multiple wishlist items
124+
$old_user_meta_multiple = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_METAS_MULTIPLE, true );
125+
126+
} else {
127+
$old_user_meta_multiple = get_transient( "{$transient}{$user_id}" );
128+
}
129+
122130
$old_user_meta = ( isset( $old_user_meta_multiple[$tab_id] ) ? $old_user_meta_multiple[$tab_id] : array() );
123131

124132
$item_value = isset( $old_user_meta[ $product->get_id() ] ) && isset( $old_user_meta[ $product->get_id() ]['note'] ) ? esc_attr( $old_user_meta[ $product->get_id() ]['note'] ) : '';

‎includes/free/class-alg-wc-wish-list-report.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ function admin_users_columns_setup( $val, $column_name, $user_id ) {
362362
} else {
363363
return '';
364364
}
365+
case 'alg_wish_list_clear_wishlist' :
366+
$request = 'admin-ajax.php?action=alg_wc_wl_clear_wish_list_admin&user_id=' . $user_id;
367+
$action_url = admin_url( $request );
368+
return '<a href="' . $action_url . '" class="button" value="Clear Wishlist">Clear Wishlist</a>';
365369
default:
366370
}
367371
return $val;
@@ -407,12 +411,19 @@ function admin_products_columns_setup( $val, $product_id ) {
407411
* @return mixed
408412
*/
409413
function admin_users_columns_add( $columns ) {
410-
if ( 'no' === get_option( Alg_WC_Wish_List_Settings_Admin::OPTION_REPORT_WISHLIST_COL_USERS_PAGE, 'no' ) ) {
411-
return $columns;
412-
}
413-
$columns = array_slice( $columns, 0, count( $columns ) - 1, true ) +
414+
415+
if ( 'yes' === get_option( Alg_WC_Wish_List_Settings_Admin::OPTION_REPORT_WISHLIST_COL_USERS_PAGE, 'no' ) ) {
416+
$columns = array_slice( $columns, 0, count( $columns ) - 1, true ) +
414417
array( "alg_wish_list" => __( 'Wish List', 'wish-list-for-woocommerce' ) ) +
415418
array_slice( $columns, count( $columns ) - 1, count( $columns ) - 1, true );
419+
}
420+
421+
if ( 'yes' === get_option( Alg_WC_Wish_List_Settings_Admin::OPTION_REPORT_WISHLIST_COL_USERS_PAGE_CLEAR_WISHLIST, 'no' ) ) {
422+
$columns = array_slice( $columns, 0, count( $columns ) - 1, true ) +
423+
array( "alg_wish_list_clear_wishlist" => __( 'Clear Wish List', 'wish-list-for-woocommerce' ) ) +
424+
array_slice( $columns, count( $columns ) - 1, count( $columns ) - 1, true );
425+
}
426+
416427
return $columns;
417428
}
418429

‎includes/free/class-alg-wc-wish-list-shortcodes.php

+55-4
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,66 @@ public static function sc_alg_wc_wl( $atts ) {
245245
$wishlisted_items = Alg_WC_Wish_List::get_wish_list( $user_id, $use_id_from_unlogged_user, $ignore_excluded_items );
246246
}
247247

248+
$alg_wc_wl_orderby = (isset($_GET['alg_wc_wl_orderby']) ? $_GET['alg_wc_wl_orderby'] : '');
249+
250+
switch ( $alg_wc_wl_orderby ) {
251+
case "name-asc":
252+
$order_by = 'title';
253+
$order = 'asc';
254+
break;
255+
case "name-desc":
256+
$order_by = 'title';
257+
$order = 'desc';
258+
break;
259+
case "date-asc":
260+
$order_by = 'modified';
261+
$order = 'asc';
262+
break;
263+
case "date-desc":
264+
$order_by = 'modified';
265+
$order = 'desc';
266+
break;
267+
case "price-asc":
268+
$meta_key = '_price';
269+
$order_by = 'meta_value_num';
270+
$order = 'asc';
271+
break;
272+
case "price-desc":
273+
$meta_key = '_price';
274+
$order_by = 'meta_value_num';
275+
$order = 'desc';
276+
break;
277+
case "sku-asc":
278+
$meta_key = '_sku';
279+
$order_by = 'meta_value';
280+
$order = 'asc';
281+
break;
282+
case "sku-desc":
283+
$meta_key = '_sku';
284+
$order_by = 'meta_value';
285+
$order = 'desc';
286+
break;
287+
default:
288+
$order_by = 'post__in';
289+
$order = 'asc';
290+
}
291+
292+
293+
248294
if ( is_array( $wishlisted_items ) && count( $wishlisted_items ) > 0 ) {
249-
$the_query = new WP_Query( array(
295+
$query_args = array(
250296
'post_type' => array( 'product', 'product_variation' ),
251297
'post_status' => array( 'publish','trash' ),
252298
'posts_per_page' => - 1,
253299
'post__in' => $wishlisted_items,
254-
'orderby' => 'post__in',
255-
'order' => 'asc'
256-
) );
300+
'orderby' => $order_by,
301+
'order' => $order
302+
);
303+
if ( isset( $meta_key ) ) {
304+
$query_args['meta_key'] = $meta_key;
305+
}
306+
307+
$the_query = new WP_Query( $query_args );
257308
} else {
258309
$the_query = null;
259310
}

‎includes/free/class-alg-wc-wish-list-sorting.php

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function sort_wish_list_alphabetically( $wish_list, $args ) {
4646
) {
4747
$order = 'alpha_asc' === $sorting_method ? 'asc' : 'desc';
4848

49+
4950
return wc_get_products( array(
5051
'type' => array_merge( array_keys( wc_get_product_types() ), array( 'variation' ) ),
5152
'limit' => - 1,

‎includes/free/class-alg-wc-wish-list-transients.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wishlist for WooCommerce - Transients
44
*
5-
* @version 1.1.5
5+
* @version 3.0.8
66
* @since 1.0.0
77
* @author WPFactory
88
*/
@@ -31,33 +31,33 @@ class Alg_WC_Wish_List_Transients {
3131
const WISH_LIST_METAS = 'alg_wc_wlm_';
3232

3333
/**
34-
* Transient responsible for saving the wishlist of unlogged users
34+
* Transient responsible for saving the multiple wishlist name.
3535
*
36-
* @version 2.0.5
36+
* @version 3.0.8
3737
* @since 2.0.5
3838
*/
3939
const WISH_LIST_MULTIPLE = 'alg_wc_wl_multiple_';
4040

4141
/**
42-
* Transient responsible for saving the wishlist metas of unlogged users
42+
* Transient responsible for saving the multiple wishlist meta.
4343
*
44-
* @version 2.0.5
44+
* @version 3.0.8
4545
* @since 2.0.5
4646
*/
4747
const WISH_LIST_METAS_MULTIPLE = 'alg_wc_wlm_multiple_';
4848

4949
/**
50-
* Transient responsible for saving the wishlist of unlogged users
50+
* Transient responsible for the saving multiple wishlist item.
5151
*
52-
* @version 2.0.5
52+
* @version 3.0.8
5353
* @since 2.0.5
5454
*/
5555
const WISH_LIST_MULTIPLE_STORE = 'alg_wc_wl_multiple_store_';
5656

5757
/**
58-
* Transient responsible for saving the wishlist metas of unlogged users
58+
* Transient responsible for saving multiple wishlist item meta data.
5959
*
60-
* @version 2.0.5
60+
* @version 3.0.8
6161
* @since 2.0.5
6262
*/
6363
const WISH_LIST_METAS_MULTIPLE_STORE = 'alg_wc_wlm_multiple_store_';

‎includes/free/class-alg-wc-wish-list-user-metas.php

+29-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wishlist for WooCommerce - Wishlist User Metas
44
*
5-
* @version 1.2.6
5+
* @version 3.0.8
66
* @since 1.0.0
77
* @author WPFactory
88
*/
@@ -27,6 +27,34 @@ class Alg_WC_Wish_List_User_Metas {
2727
* @since 1.2.6
2828
*/
2929
const WISH_LIST_ITEM_METAS = '_alg_wc_wl_item_metas';
30+
31+
/**
32+
* Meta responsible for pointing what item is in user multiple wishlist
33+
*
34+
* @since 3.0.8
35+
*/
36+
const WISH_LIST_ITEM_MULTIPLE = '_alg_wc_wl_item_multiple';
37+
38+
/**
39+
* Meta responsible for saving metas to a multiple wishlist item
40+
*
41+
* @since 3.0.8
42+
*/
43+
const WISH_LIST_ITEM_METAS_MULTIPLE = '_alg_wc_wl_item_metas_multiple';
44+
45+
/**
46+
* Meta is responsible for indicating which items are in the user's multiple wishlist names (used when displaying multiple wishlist names across the entire website).
47+
*
48+
* @since 3.0.8
49+
*/
50+
const WISH_LIST_ITEM_MULTIPLE_NAME = '_alg_wc_wl_item_multiple_name';
51+
52+
/**
53+
* Meta is responsible for saving metas to multiple wishlist names (used when displaying multiple wishlist names across the entire website).
54+
*
55+
* @since 3.0.8
56+
*/
57+
const WISH_LIST_ITEM_METAS_MULTIPLE_NAME = '_alg_wc_wl_item_metas_multiple_name';
3058

3159
}
3260

‎includes/free/class-alg-wc-wish-list.php

+65-11
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,19 @@ public static function get_wish_list( $user_id = null, $use_id_from_unlogged_use
302302
/**
303303
* get_multiple_wishlists.
304304
*
305-
* @version 2.0.5
305+
* @version 3.0.8
306306
* @since 2.0.5
307307
*/
308-
public static function get_multiple_wishlists( $user_id = null ) {
308+
public static function get_multiple_wishlists( $user_id = null, $use_id_from_unlogged_user = false ) {
309309

310-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE;
311-
$wishlist_list = get_transient( "{$transient}{$user_id}" );
310+
if( is_int( $user_id ) && $user_id > 0 ) {
311+
312+
$wishlist_list = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE_NAME, true );
313+
314+
} else {
315+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE;
316+
$wishlist_list = get_transient( "{$transient}{$user_id}" );
317+
}
312318

313319
if ( ! $wishlist_list ) {
314320
$wishlist_list = array();
@@ -320,13 +326,20 @@ public static function get_multiple_wishlists( $user_id = null ) {
320326
/**
321327
* get_multiple_wishlists_with_all_item.
322328
*
323-
* @version 2.0.5
329+
* @version 3.0.8
324330
* @since 2.0.5
325331
*/
326332
public static function get_multiple_wishlists_with_all_item( $user_id = null ) {
327333

328-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
329-
$wishlist_list = get_transient( "{$transient}{$user_id}" );
334+
if ( is_int( $user_id ) && $user_id > 0 ) {
335+
336+
// get only multiple wishlist items
337+
$wishlist_list = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
338+
339+
} else {
340+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
341+
$wishlist_list = get_transient( "{$transient}{$user_id}" );
342+
}
330343

331344
if ( ! $wishlist_list ) {
332345
$wishlist_list = array();
@@ -338,21 +351,35 @@ public static function get_multiple_wishlists_with_all_item( $user_id = null ) {
338351
/**
339352
* get_multiple_wishlist_items.
340353
*
341-
* @version 2.0.5
354+
* @version 3.0.8
342355
* @since 2.0.5
343356
*/
344-
public static function get_multiple_wishlist_items( $user_id = null, $use_id_from_unlogged_user = false, $ignore_excluded_items = false ) {
357+
public static function get_multiple_wishlist_items( $user_id = null, $use_id_from_unlogged_user = false, $ignore_excluded_items = false, $tab_id = 0 ) {
345358

346359
$current_tab_id = '';
347360
$item_id = -99;
361+
362+
if( $tab_id > 0 ) {
363+
$item_id = $tab_id - 1;
364+
}
348365

349366
if ( isset($_GET) && isset($_GET['wtab']) && $_GET['wtab'] > 0) {
350367
$current_tab_id = $_GET['wtab'];
351368
$item_id = $current_tab_id - 1;
352369
}
353370

354-
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
355-
$wishlist_list = get_transient( "{$transient}{$user_id}" );
371+
if ( is_int( $user_id ) && $user_id > 0 ) {
372+
373+
// get only multiple wishlist items
374+
$wishlist_list = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
375+
376+
} else {
377+
378+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
379+
$wishlist_list = get_transient( "{$transient}{$user_id}" );
380+
381+
}
382+
356383

357384
if ( ! $wishlist_list ) {
358385
$wishlist_list = array();
@@ -362,6 +389,33 @@ public static function get_multiple_wishlist_items( $user_id = null, $use_id_fro
362389

363390
return $wishlist_list;
364391
}
392+
393+
/**
394+
* get_multiple_wishlist_unique_items.
395+
*
396+
* @version 3.0.10
397+
* @since 3.0.10
398+
*/
399+
public static function get_multiple_wishlist_unique_items( $user_id = null, $use_id_from_unlogged_user = false ) {
400+
401+
$wishlisted_items = self::get_multiple_wishlists_with_all_item( $user_id );
402+
$single_array = array();
403+
404+
if ( is_array( $wishlisted_items ) && count( $wishlisted_items ) > 0 ) {
405+
406+
407+
foreach ( $wishlisted_items as $key => $first_level_arr ){
408+
foreach ( $first_level_arr as $key_first => $value ){
409+
$single_array[] = $value;
410+
}
411+
}
412+
413+
$single_array = array_unique($single_array);
414+
}
415+
416+
return $single_array;
417+
418+
}
365419

366420
}
367421

‎langs/wish-list-for-woocommerce-fr_FR.po

+369-258
Large diffs are not rendered by default.

‎langs/wish-list-for-woocommerce-nl_NL.po

+369-258
Large diffs are not rendered by default.

‎langs/wish-list-for-woocommerce.pot

+371-260
Large diffs are not rendered by default.

‎readme.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: wpcodefactory, omardabbas, karzin, anbinder, algoritmika, kousikmu
33
Tags: woocommerce, wishlist, woocommerce wishlist, add to wishlist, product wishlist
44
Requires at least: 6.1
55
Tested up to: 6.6
6-
Stable tag: 3.0.7
6+
Stable tag: 3.0.8
77
Requires PHP: 5.6.0
88
License: GNU General Public License v3.0
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -258,6 +258,12 @@ Once activated, access the plugin's settings by navigating to “WooCommerce > S
258258

259259
== Changelog ==
260260

261+
= 3.0.8 - 19/09/2024 =
262+
* Update - Store multiple wishlists in the database for logged-in users.
263+
* Update - Display multiple wishlists on the admin user profile page.
264+
* Add - Wishlist page - Duplicate Functionality (Duplicate functionality on the wishlist page).
265+
* Add - Clear wishlist from the admin user list page.
266+
261267
= 3.0.7 - 21/08/2024 =
262268
* Fix - delete duplicate HOPS code.
263269

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
<?php
2+
/**
3+
* Wish List for WooCommerce Pro - Multiple Admin wish list.
4+
*
5+
* Template used to display the multiple wishlist on user profile page.
6+
*
7+
* @author WPFactory.
8+
* @version 3.0.8
9+
* @since 3.0.8
10+
*/
11+
?>
12+
13+
<?php
14+
$the_query = $params['the_query'];
15+
$products_attributes = isset( $params['product_attributes'] ) ? $params['product_attributes'] : false;
16+
$empty_wishlist_msg = isset( $params['empty_wishlist_msg'] ) ? $params['empty_wishlist_msg'] : false;
17+
18+
19+
// If is current user's profile (profile.php)
20+
if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE ) {
21+
$user_id = get_current_user_id();
22+
// If is another user's profile page
23+
} elseif (! empty($_GET['user_id']) && is_numeric($_GET['user_id']) ) {
24+
$user_id = $_GET['user_id'];
25+
// Otherwise something is wrong.
26+
} else {
27+
$user_id = 0;
28+
}
29+
30+
$wishlist_list = Alg_WC_Wish_List::get_multiple_wishlists( $user_id );
31+
$tab_contents = '';
32+
?>
33+
34+
<style type="text/css" scoped>
35+
.alg-wc-wl-admin-wish-list .alg-wc-wl-item a{
36+
37+
}
38+
.alg-wc-wl-admin-wish-list .alg-wc-wl-item img{
39+
width:50px;
40+
height:auto;
41+
margin-right:15px;
42+
border:3px solid #ccc;
43+
}
44+
.alg-wc-wl-admin-wish-list td{
45+
padding:0;
46+
vertical-align:middle;
47+
}
48+
49+
/* Style the tab */
50+
.alg_wc_wl_admin_tab {
51+
overflow: hidden;
52+
border: 1px solid #ccc;
53+
background-color: #f1f1f1;
54+
}
55+
56+
/* Style the buttons inside the tab */
57+
.alg_wc_wl_admin_tab button {
58+
background-color: inherit;
59+
float: left;
60+
border: none;
61+
outline: none;
62+
cursor: pointer;
63+
padding: 14px 16px;
64+
transition: 0.3s;
65+
font-size: 17px;
66+
}
67+
68+
/* Change background color of buttons on hover */
69+
.alg_wc_wl_admin_tab button:hover {
70+
background-color: #ddd;
71+
}
72+
73+
/* Create an active/current tablink class */
74+
.alg_wc_wl_admin_tab button.alg_wc_wl_admin_active {
75+
background-color: #ccc;
76+
}
77+
78+
/* Style the tab content */
79+
.alg_wc_wl_admin_tabcontent {
80+
display: none;
81+
padding: 6px 12px;
82+
border: 1px solid #ccc;
83+
border-top: none;
84+
}
85+
86+
87+
#alg_wc_wl_admin_tab_default {
88+
display: block;
89+
}
90+
91+
92+
</style>
93+
94+
95+
<script type="text/javascript">
96+
97+
function alg_wc_wl_admin_open_multi_wishlist_admin(evt, cityName) {
98+
var i, alg_wc_wl_admin_tabcontent, alg_wc_wl_admin_tablinks;
99+
alg_wc_wl_admin_tabcontent = document.getElementsByClassName("alg_wc_wl_admin_tabcontent");
100+
for (i = 0; i < alg_wc_wl_admin_tabcontent.length; i++) {
101+
alg_wc_wl_admin_tabcontent[i].style.display = "none";
102+
}
103+
alg_wc_wl_admin_tablinks = document.getElementsByClassName("alg_wc_wl_admin_tablinks");
104+
for (i = 0; i < alg_wc_wl_admin_tablinks.length; i++) {
105+
alg_wc_wl_admin_tablinks[i].className = alg_wc_wl_admin_tablinks[i].className.replace(" alg_wc_wl_admin_active", "");
106+
}
107+
document.getElementById(cityName).style.display = "block";
108+
evt.currentTarget.className += " alg_wc_wl_admin_active";
109+
}
110+
111+
</script>
112+
113+
114+
115+
116+
<?php
117+
118+
if( is_array( $wishlist_list ) ) {
119+
120+
?>
121+
<div class="alg_wc_wl_admin_tab">
122+
<button type="button" class="alg_wc_wl_admin_tablinks alg_wc_wl_admin_active" onclick="alg_wc_wl_admin_open_multi_wishlist_admin(event, 'alg_wc_wl_admin_tab_default')" id="alg_wc_wl_admin_defaultOpen"><?php _e( 'Default Wishlist', 'wish-list-for-woocommerce' ); ?></button>
123+
124+
<?php
125+
126+
foreach( $wishlist_list as $k => $list ) {
127+
$tab_id = $k + 1;
128+
129+
$tab_option_id = 'alg_wc_wl_admin_tab_' . $tab_id;
130+
131+
$wishlisted_items = Alg_WC_Wish_List::get_multiple_wishlist_items( $user_id, false, false, $tab_id );
132+
$wishlisted_items = array_values($wishlisted_items);
133+
$the_query = new WP_Query( array(
134+
'post_type' => array( 'product', 'product_variation' ),
135+
'post_status' => array( 'publish', 'trash' ),
136+
'posts_per_page' => - 1,
137+
'post__in' => $wishlisted_items,
138+
'orderby' => 'post__in',
139+
'order' => 'asc'
140+
) );
141+
142+
ob_start();
143+
144+
?>
145+
146+
<div id="<?php echo $tab_option_id; ?>" class="alg_wc_wl_admin_tabcontent">
147+
<table class="alg-wc-wl-admin-wish-list">
148+
<?php if ( $the_query != null && $the_query->have_posts() ) : ?>
149+
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
150+
<?php if(isset($products_attributes[ get_the_ID() ]['variation_id']) && !empty($products_attributes[ get_the_ID() ]['variation_id'])): ?>
151+
<?php $product = new WC_Product_Variation($products_attributes[ get_the_ID() ]['variation_id']); ?>
152+
<?php else: ?>
153+
<?php $product = wc_get_product( get_the_ID() ); ?>
154+
<?php endif; ?>
155+
<tr class="alg-wc-wl-item">
156+
<td>
157+
<a href="<?php echo esc_url( get_edit_post_link( get_the_ID() ) ); ?>">
158+
<?php echo $product->get_image(); ?>
159+
</a>
160+
</td>
161+
<td>
162+
<a href="<?php echo $product->get_permalink(); ?>">
163+
<?php echo $product->get_title(); ?>
164+
</a>
165+
<span>
166+
<?php if ( is_a( $product, 'WC_Product_Variation' ) ) {
167+
foreach ( $product->get_attributes() as $variation_attribute => $term_slug ) {
168+
$taxonomy = str_replace( 'attribute_', '', $variation_attribute );
169+
$label_name = wc_attribute_label( $taxonomy );
170+
$term_name = ( $term = get_term_by( 'slug', $term_slug, $taxonomy ) ) ? $term->name : $term_slug;
171+
echo '<div style=\'font-size:13px;\'><strong>' . $label_name . ':</strong> ' . $term_name . '</div>';
172+
}
173+
} ?>
174+
</span>
175+
</td>
176+
</tr>
177+
<?php endwhile; ?>
178+
<?php else: ?>
179+
<?php echo esc_html( $empty_wishlist_msg ) ?>
180+
<?php endif;?>
181+
</table>
182+
</div>
183+
<?php
184+
$ob_content = ob_get_clean();
185+
$tab_contents .= $ob_content;
186+
?>
187+
<button type="button" class="alg_wc_wl_admin_tablinks" onclick="alg_wc_wl_admin_open_multi_wishlist_admin(event, '<?php echo $tab_option_id; ?>')"><?php echo $list; ?></button>
188+
<?php
189+
}
190+
?>
191+
</div>
192+
<?php
193+
}
194+
?>
195+
196+
<div id="alg_wc_wl_admin_tab_default" class="alg_wc_wl_admin_tabcontent">
197+
<table class="alg-wc-wl-admin-wish-list">
198+
<?php if ( $the_query != null && $the_query->have_posts() ) : ?>
199+
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
200+
<?php if(isset($products_attributes[ get_the_ID() ]['variation_id']) && !empty($products_attributes[ get_the_ID() ]['variation_id'])): ?>
201+
<?php $product = new WC_Product_Variation($products_attributes[ get_the_ID() ]['variation_id']); ?>
202+
<?php else: ?>
203+
<?php $product = wc_get_product( get_the_ID() ); ?>
204+
<?php endif; ?>
205+
<tr class="alg-wc-wl-item">
206+
<td>
207+
<a href="<?php echo esc_url( get_edit_post_link( get_the_ID() ) ); ?>">
208+
<?php echo $product->get_image(); ?>
209+
</a>
210+
</td>
211+
<td>
212+
<a href="<?php echo $product->get_permalink(); ?>">
213+
<?php echo $product->get_title(); ?>
214+
</a>
215+
<span>
216+
<?php if ( is_a( $product, 'WC_Product_Variation' ) ) {
217+
foreach ( $product->get_attributes() as $variation_attribute => $term_slug ) {
218+
$taxonomy = str_replace( 'attribute_', '', $variation_attribute );
219+
$label_name = wc_attribute_label( $taxonomy );
220+
$term_name = ( $term = get_term_by( 'slug', $term_slug, $taxonomy ) ) ? $term->name : $term_slug;
221+
echo '<div style=\'font-size:13px;\'><strong>' . $label_name . ':</strong> ' . $term_name . '</div>';
222+
}
223+
} ?>
224+
</span>
225+
</td>
226+
</tr>
227+
<?php endwhile; ?>
228+
<?php else: ?>
229+
<?php echo esc_html( $empty_wishlist_msg ) ?>
230+
<?php endif;?>
231+
</table>
232+
</div>
233+
<?php echo $tab_contents; ?>
234+

‎templates/wish-list.php

+37-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Wish list template.
44
*
55
* @author WPFactory.
6-
* @version 3.0.4
6+
* @version 3.0.8
77
* @since 1.0.0
88
*/
99

@@ -13,7 +13,7 @@
1313
?>
1414

1515
<?php
16-
global $wp_query;
16+
global $wp_query, $wp;
1717
$theid = intval( $wp_query->queried_object->ID );
1818

1919
$the_query = $params['the_query'];
@@ -60,6 +60,9 @@
6060
$email_table_params = 'border="1" style="width:100%;border-collapse: collapse;border:1px solid #ccc" cellpadding="15"';
6161
}
6262

63+
$alg_wc_wl_dropdown_sorting = get_option( 'alg_wc_wl_dropdown_sorting', 'no' );
64+
$alg_wc_wl_duplicate_option = get_option( 'alg_wc_wl_duplicate_option', 'no' );
65+
6366
// $current_page_id = get_the_ID();
6467

6568
$current_page_id = $theid;
@@ -90,6 +93,7 @@
9093
$wishlist_list = Alg_WC_Wish_List::get_multiple_wishlists( $user_id );
9194

9295
$current_tab_id = '';
96+
$current_tab_title = __( 'Default Wishlist', 'wish-list-for-woocommerce' );
9397

9498
if ( isset($_GET) && isset($_GET['wtab']) && $_GET['wtab'] > 0) {
9599
$current_tab_id = $_GET['wtab'];
@@ -179,6 +183,7 @@
179183
$active = '';
180184
if( $tab_id == $current_tab_id ) {
181185
$active = 'active';
186+
$current_tab_title = $list;
182187
}
183188
?>
184189
<div class="col-20per">
@@ -190,13 +195,40 @@
190195
</div>
191196
<?php } } ?>
192197
<div style="clear:both;"></div>
193-
<?php if( $current_tab_id > 0 ){ ?>
198+
<?php
199+
if( $alg_wc_wl_dropdown_sorting == 'yes' ) {
200+
$alg_wc_wl_orderby = (isset($_GET['alg_wc_wl_orderby']) ? $_GET['alg_wc_wl_orderby'] : '');
201+
?>
202+
<form action="<?php echo add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ); ?>" method="GET" >
203+
<select name="alg_wc_wl_orderby" class="alg_wc_wl_orderby" aria-label="Wishlist order" onchange="this.form.submit()">
204+
<option value="" <?php selected('', $alg_wc_wl_orderby); ?>><?php _e( 'Default sorting', 'wish-list-for-woocommerce' ); ?></option>
205+
<option value="name-asc" <?php selected('name-asc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by product name A - Z', 'wish-list-for-woocommerce' ); ?></option>
206+
<option value="name-desc" <?php selected('name-desc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by product name Z - A', 'wish-list-for-woocommerce' ); ?></option>
207+
<option value="date-asc" <?php selected('date-asc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by latest', 'wish-list-for-woocommerce' ); ?></option>
208+
<option value="date-desc" <?php selected('date-desc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by oldest', 'wish-list-for-woocommerce' ); ?></option>
209+
<option value="price-asc" <?php selected('price-asc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by price: low to high', 'wish-list-for-woocommerce' ); ?></option>
210+
<option value="price-desc" <?php selected('price-desc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by price: high to low', 'wish-list-for-woocommerce' ); ?></option>
211+
<option value="sku-asc" <?php selected('sku-asc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by SKU A - Z', 'wish-list-for-woocommerce' ); ?></option>
212+
<option value="sku-desc" <?php selected('sku-desc', $alg_wc_wl_orderby); ?>><?php _e( 'Sort by SKU Z - A', 'wish-list-for-woocommerce' ); ?></option>
213+
</select>
214+
<input type="hidden" name="wtab" id="wtab" value="<?php echo (isset($_GET['wtab']) ? $_GET['wtab'] : ''); ?>">
215+
</form>
216+
<?php
217+
}
218+
?>
194219
<div class="alg-wc-delete-wishlist">
220+
<?php if( $user_id > 0 && $alg_wc_wl_duplicate_option == 'yes' ) { ?>
221+
<a href="javascript:;" data-page="<?php echo $page; ?>" data-wishlist_tab_title="<?php echo $current_tab_title; ?>" data-wishlist_tab_id="<?php echo $current_tab_id; ?>" class="button copy-wishlist" title="<?php _e( 'Copy Wishlist', 'wish-list-for-woocommerce' ); ?>" rel="nofollow"><?php _e( 'Copy Wishlist', 'wish-list-for-woocommerce' ); ?></a>
222+
<?php
223+
}
224+
if( $current_tab_id > 0 ){
225+
?>
195226

196-
<a href="javascript:;" data-page="<?php echo $page; ?>" data-wishlist_tab_id="<?php echo $current_tab_id; ?>" class="button delete-customized-wishlist" title="Delete Wishlist" rel="nofollow"><?php _e( 'Delete Wishlist', 'wish-list-for-woocommerce' ); ?></a>
227+
<a href="javascript:;" data-page="<?php echo $page; ?>" data-wishlist_tab_id="<?php echo $current_tab_id; ?>" class="button delete-customized-wishlist" title="<?php _e( 'Delete Wishlist', 'wish-list-for-woocommerce' ); ?>" rel="nofollow"><?php _e( 'Delete Wishlist', 'wish-list-for-woocommerce' ); ?></a>
197228

198-
</div>
199229
<?php } ?>
230+
231+
</div>
200232
<div style="clear:both;"></div>
201233
<?php if ( $the_query != null && $the_query->have_posts() ) : ?>
202234

‎wish-list-for-woocommerce.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Wishlist for WooCommerce
44
Plugin URI: https://wpfactory.com/item/wish-list-woocommerce/
55
Description: Let your visitors show what products they like on your WooCommerce store with a <strong>Wishlist</strong>.
6-
Version: 3.0.7
6+
Version: 3.0.8
77
Author: WPFactory
88
Author URI: https://wpfactory.com/
99
Copyright: © 2023 WPFactory.

0 commit comments

Comments
 (0)
Please sign in to comment.