Version Description
Release Date - 4 June 2020
- Added compatibility with WooCommerce 4.2.x
- Added integration with WooCommerce Product Table plugin as a custom table column 'wishlist'
- Improved integration with Product Options and Price Calculation Formulas for WooCommerce Uni CPO plugin
- Fixed PHP Fatal error in case wishlist page doesn't set and forced permalinks option is active
- Fixed an issue when custom button icon didn't save in settings
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.20.2 |
Comparing to | |
See all releases |
Code changes from version 1.20.1 to 1.20.2
- assets/css/admin-form.min.css +1 -1
- assets/css/admin-setup.min.css +1 -1
- 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/api/wishlist.class.php +381 -381
- includes/form.helper.php +1 -2
- includes/product.helper.php +0 -1
- integrations/elex-woocommerce-catalog-mode.php +5 -5
- integrations/hide-price-add-to-cart-button.php +2 -2
- integrations/mycred.php +4 -4
- integrations/theme-divi.php +4 -4
- integrations/theme-flatsome.php +9 -9
- integrations/theme-kallyas.php +3 -3
- integrations/theme-oceanwp.php +3 -3
- integrations/uni-woo-custom-product-options.php +27 -2
- integrations/woocommerce-gravityforms-product-addons.php +3 -3
- integrations/woocommerce-product-table.php +39 -0
- languages/ti-woocommerce-wishlist.pot +23 -3
- public/tinvwl.class.php +1 -1
- readme.txt +11 -1
- ti-woocommerce-wishlist.php +3 -3
assets/css/admin-form.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.20.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.2
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
|
assets/css/admin-setup.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.20.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
html{background:#f6f3ed}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.2
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
html{background:#f6f3ed}
|
assets/css/admin.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.20.
|
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.20.2
|
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.20.
|
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.20.2
|
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.20.
|
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.20.2
|
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.20.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
"use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.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(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.2
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
"use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.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(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
|
assets/js/public.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.20.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){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):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val();("checkbox"!==i&&"radio"!==i||r(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=r("<ul>");r.each(t,function(t,i){n.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){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(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){if(r("body").trigger("tinvwl_wishlist_added_status",[this,t]),t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).addClass("tinvwl-product-in-list")})}},removed:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")})}},make_remove:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")})}},counter:function(t){var i=!("0"==t||""==t);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t)}}};i.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},n=this;r(n).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var l=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===l.length){var a={};a[l[2]]=n,n=a}t=l[1],o--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),s.form[t]=e(s.form[t],n)):s.form[t]=e(s.form[t],n)}}),s=e.onPrepareDataAction.call(n,n,s)||s,r.post(e.api_url,s,function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=r(this).find(e.class.select).eq(0);r(this).find(e.class.newtitle).hide().val(""),n.html(""),r.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),r(this).find(e.class.newtitle).toggle(""===n.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=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;r(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=r(o.tinvwl_dialog).find(e.class.select),n=r(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},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,n){var o=r(this).find(".tinvwl_add_to_wishlist_button");if(o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),l=!1,a="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(l=!0);o.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&a).attr("data-tinv-wl-action",l&&a?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),r(window).on("storage onstorage",function(t){l===t.originalEvent.key&&localStorage.getItem(l)!==sessionStorage.getItem(l)&&a(localStorage.getItem(l))});var n=[],i=!1;r("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&n.push(r(this).data("tinv-wl-product"))}),r(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),r.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i=!("0"==t.counter||""==t.counter);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t.counter),r.each(t.products,function(t,o){var e=t,l="1"==window.tinvwl_add_to_wishlist.simple_flow;r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+e+"']").each(function(){var t=r(this).data("tinv-wl-productvariation"),i=!1;for(var n in o)o[n].hasOwnProperty("in")&&Array.isArray(o[n].in)&&(-1<(o[n].in||[]).indexOf(e)||-1<(o[n].in||[]).indexOf(t))&&(i=!0);r(this).removeClass("tinvwl-add-hide").attr("data-tinv-wl-list",JSON.stringify(o)).toggleClass("tinvwl-product-in-list",i).toggleClass("tinvwl-product-make-remove",i&&l).attr("data-tinv-wl-action",i&&l?"remove":"addto")})})})}}o();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&r(i).each(function(){var t=r(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&n.push(r(this).data("tinv-wl-product"))})})}),n.length&&o()}),e=document.body;t.observe(e,{childList:!0,subtree:!0})});var n=!0,l=tinvwl_add_to_wishlist.hash_key;try{n="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){n=!1}function a(t){if(n){localStorage.setItem(l,t),sessionStorage.setItem(l,t),"false"!==t?jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t):jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products");var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i)}}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o.trim(o(this).html()).length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.2
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){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):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val();("checkbox"!==i&&"radio"!==i||r(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=r("<ul>");r.each(t,function(t,i){n.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){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(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){if(r("body").trigger("tinvwl_wishlist_added_status",[this,t]),t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).addClass("tinvwl-product-in-list")})}},removed:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")})}},make_remove:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")})}},counter:function(t){var i=!("0"==t||""==t);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t)}}};i.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},n=this;r(n).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var l=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===l.length){var a={};a[l[2]]=n,n=a}t=l[1],o--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),s.form[t]=e(s.form[t],n)):s.form[t]=e(s.form[t],n)}}),s=e.onPrepareDataAction.call(n,n,s)||s,r.post(e.api_url,s,function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=r(this).find(e.class.select).eq(0);r(this).find(e.class.newtitle).hide().val(""),n.html(""),r.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),r(this).find(e.class.newtitle).toggle(""===n.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=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;r(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=r(o.tinvwl_dialog).find(e.class.select),n=r(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},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,n){var o=r(this).find(".tinvwl_add_to_wishlist_button");if(o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),l=!1,a="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(l=!0);o.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&a).attr("data-tinv-wl-action",l&&a?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),r(window).on("storage onstorage",function(t){l===t.originalEvent.key&&localStorage.getItem(l)!==sessionStorage.getItem(l)&&a(localStorage.getItem(l))});var n=[],i=!1;r("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&n.push(r(this).data("tinv-wl-product"))}),r(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),r.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i=!("0"==t.counter||""==t.counter);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t.counter),r.each(t.products,function(t,o){var e=t,l="1"==window.tinvwl_add_to_wishlist.simple_flow;r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+e+"']").each(function(){var t=r(this).data("tinv-wl-productvariation"),i=!1;for(var n in o)o[n].hasOwnProperty("in")&&Array.isArray(o[n].in)&&(-1<(o[n].in||[]).indexOf(e)||-1<(o[n].in||[]).indexOf(t))&&(i=!0);r(this).removeClass("tinvwl-add-hide").attr("data-tinv-wl-list",JSON.stringify(o)).toggleClass("tinvwl-product-in-list",i).toggleClass("tinvwl-product-make-remove",i&&l).attr("data-tinv-wl-action",i&&l?"remove":"addto")})})})}}o();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&r(i).each(function(){var t=r(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&n.push(r(this).data("tinv-wl-product"))})})}),n.length&&o()}),e=document.body;t.observe(e,{childList:!0,subtree:!0})});var n=!0,l=tinvwl_add_to_wishlist.hash_key;try{n="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){n=!1}function a(t){if(n){localStorage.setItem(l,t),sessionStorage.setItem(l,t),"false"!==t?jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t):jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products");var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i)}}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o.trim(o(this).html()).length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
|
includes/api/wishlist.class.php
CHANGED
@@ -1,381 +1,381 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* REST API plugin class
|
4 |
-
*
|
5 |
-
* @since 1.13.0
|
6 |
-
* @package TInvWishlist
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
|
15 |
-
/**
|
16 |
-
* REST API plugin class
|
17 |
-
*/
|
18 |
-
class TInvWL_Includes_API_Wishlist {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Endpoint namespace.
|
22 |
-
*
|
23 |
-
* @var string
|
24 |
-
*/
|
25 |
-
protected $namespace = 'wc/v3';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Route base.
|
29 |
-
*
|
30 |
-
* @var string
|
31 |
-
*/
|
32 |
-
protected $rest_base = 'wishlist';
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Register the routes for wishlist.
|
36 |
-
*/
|
37 |
-
public function register_routes() {
|
38 |
-
|
39 |
-
// Get wishlist data by share key.
|
40 |
-
register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_share_key/(?P<share_key>[A-Fa-f0-9]{6})', array(
|
41 |
-
array(
|
42 |
-
'methods' => WP_REST_Server::READABLE,
|
43 |
-
'callback' => array( $this, 'wishlist_get_by_share_key' ),
|
44 |
-
),
|
45 |
-
) );
|
46 |
-
|
47 |
-
// Get wishlist(s) data by user ID.
|
48 |
-
register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_user/(?P<user_id>[\d]+)', array(
|
49 |
-
array(
|
50 |
-
'methods' => WP_REST_Server::READABLE,
|
51 |
-
'callback' => array( $this, 'wishlist_get_by_user' ),
|
52 |
-
),
|
53 |
-
) );
|
54 |
-
|
55 |
-
// Update wishlist data by share key.
|
56 |
-
register_rest_route( $this->namespace, '/' . $this->rest_base . '/update/(?P<share_key>[A-Fa-f0-9]{6})', array(
|
57 |
-
array(
|
58 |
-
'methods' => WP_REST_Server::CREATABLE,
|
59 |
-
'callback' => array( $this, 'wishlist_update' ),
|
60 |
-
),
|
61 |
-
) );
|
62 |
-
|
63 |
-
// Get wishlist products by share key.
|
64 |
-
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/get_products', array(
|
65 |
-
array(
|
66 |
-
'methods' => WP_REST_Server::READABLE,
|
67 |
-
'callback' => array( $this, 'wishlist_get_products' ),
|
68 |
-
),
|
69 |
-
) );
|
70 |
-
|
71 |
-
// Add product to wishlist by share key.
|
72 |
-
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/add_product', array(
|
73 |
-
array(
|
74 |
-
'methods' => WP_REST_Server::CREATABLE,
|
75 |
-
'callback' => array( $this, 'wishlist_add_product' ),
|
76 |
-
),
|
77 |
-
) );
|
78 |
-
|
79 |
-
// Remove product by item ID.
|
80 |
-
register_rest_route( $this->namespace, '/' . $this->rest_base . '/remove_product/(?P<item_id>[\d]+)', array(
|
81 |
-
array(
|
82 |
-
'methods' => WP_REST_Server::READABLE,
|
83 |
-
'callback' => array( $this, 'wishlist_remove_product' ),
|
84 |
-
),
|
85 |
-
) );
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Get wishlist data by share key.
|
90 |
-
*
|
91 |
-
* @param WP_REST_Request $request Request object.
|
92 |
-
*
|
93 |
-
* @return mixed|WP_Error|WP_REST_Response
|
94 |
-
*/
|
95 |
-
public function wishlist_get_by_share_key( $request ) {
|
96 |
-
try {
|
97 |
-
$share_key = $request['share_key'];
|
98 |
-
|
99 |
-
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
100 |
-
$wishlist = tinv_wishlist_get( $share_key );
|
101 |
-
if ( ! $wishlist ) {
|
102 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
103 |
-
}
|
104 |
-
|
105 |
-
$response = $this->prepare_wishlist_data( $wishlist );
|
106 |
-
|
107 |
-
return rest_ensure_response( $response );
|
108 |
-
|
109 |
-
|
110 |
-
}
|
111 |
-
} catch ( WC_REST_Exception $e ) {
|
112 |
-
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Get wishlist(s) data by user ID.
|
118 |
-
*
|
119 |
-
* @param WP_REST_Request $request Request object.
|
120 |
-
*
|
121 |
-
* @return mixed|WP_Error|WP_REST_Response
|
122 |
-
*/
|
123 |
-
public function wishlist_get_by_user( $request ) {
|
124 |
-
try {
|
125 |
-
$user_id = $request['user_id'];
|
126 |
-
|
127 |
-
if ( ! empty( $user_id ) ) {
|
128 |
-
$wl = new TInvWL_Wishlist();
|
129 |
-
$wishlists = $wl->get_by_user( $user_id );
|
130 |
-
|
131 |
-
if ( ! $wishlists ) {
|
132 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_not_found', __( 'No wishlists found for this user.', 'ti-woocommerce-wishlist' ), 400 );
|
133 |
-
}
|
134 |
-
|
135 |
-
$response = array();
|
136 |
-
foreach ( $wishlists as $wishlist ) {
|
137 |
-
$response[] = $this->prepare_wishlist_data( $wishlist );
|
138 |
-
}
|
139 |
-
|
140 |
-
return rest_ensure_response( $response );
|
141 |
-
}
|
142 |
-
} catch ( WC_REST_Exception $e ) {
|
143 |
-
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Update wishlist data by share key.
|
149 |
-
*
|
150 |
-
* @param WP_REST_Request $request Request object.
|
151 |
-
*
|
152 |
-
* @return mixed|WP_Error|WP_REST_Response
|
153 |
-
*/
|
154 |
-
public function wishlist_update( $request ) {
|
155 |
-
try {
|
156 |
-
$share_key = $request['share_key'];
|
157 |
-
|
158 |
-
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
159 |
-
|
160 |
-
$wl = new TInvWL_Wishlist();
|
161 |
-
|
162 |
-
$wishlist = $wl->get_by_share_key( $share_key );
|
163 |
-
|
164 |
-
if ( ! $wishlist ) {
|
165 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
166 |
-
}
|
167 |
-
|
168 |
-
$data = array();
|
169 |
-
if ( ! empty( $request['title'] ) ) {
|
170 |
-
$data['title'] = $request['title'];
|
171 |
-
}
|
172 |
-
|
173 |
-
if ( ! empty( $request['user_id'] ) ) {
|
174 |
-
$data['author'] = $request['user_id'];
|
175 |
-
}
|
176 |
-
|
177 |
-
if ( $data && current_user_can( 'tinvwl_general_settings' ) ) {
|
178 |
-
$update = $wl->update( $wishlist['ID'], $data );
|
179 |
-
|
180 |
-
if ( $update ) {
|
181 |
-
$response = $wl->get_by_share_key( $share_key );
|
182 |
-
|
183 |
-
return rest_ensure_response( $this->prepare_wishlist_data( $response ) );
|
184 |
-
}
|
185 |
-
|
186 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_update_error', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 400 );
|
187 |
-
|
188 |
-
} else {
|
189 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 403 );
|
190 |
-
}
|
191 |
-
}
|
192 |
-
} catch ( WC_REST_Exception $e ) {
|
193 |
-
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Get wishlist products by share key.
|
199 |
-
*
|
200 |
-
* @param WP_REST_Request $request Request object.
|
201 |
-
*
|
202 |
-
* @return mixed|WP_Error|WP_REST_Response
|
203 |
-
*/
|
204 |
-
public function wishlist_get_products( $request ) {
|
205 |
-
try {
|
206 |
-
$share_key = $request['share_key'];
|
207 |
-
|
208 |
-
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
209 |
-
|
210 |
-
$wl = new TInvWL_Wishlist();
|
211 |
-
|
212 |
-
$wishlist = $wl->get_by_share_key( $share_key );
|
213 |
-
|
214 |
-
if ( ! $wishlist ) {
|
215 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
216 |
-
}
|
217 |
-
|
218 |
-
$wlp = new TInvWL_Product();
|
219 |
-
|
220 |
-
$args = array();
|
221 |
-
$args['wishlist_id'] = $wishlist['ID'];
|
222 |
-
$args['external'] = false;
|
223 |
-
|
224 |
-
if ( $request['count'] ) {
|
225 |
-
$args['count'] = $request['count'];
|
226 |
-
}
|
227 |
-
if ( $request['offset'] ) {
|
228 |
-
$args['offset'] = $request['offset'];
|
229 |
-
}
|
230 |
-
if ( $request['order'] ) {
|
231 |
-
$args['order'] = $request['order'];
|
232 |
-
}
|
233 |
-
|
234 |
-
$products = $wlp->get( $args );
|
235 |
-
|
236 |
-
$response = array();
|
237 |
-
|
238 |
-
foreach ( $products as $product ) {
|
239 |
-
$response[] = $this->prepare_product_data( $product );
|
240 |
-
}
|
241 |
-
|
242 |
-
return rest_ensure_response( apply_filters( 'tinvwl_api_wishlist_get_products_response', $response ) );
|
243 |
-
}
|
244 |
-
} catch ( WC_REST_Exception $e ) {
|
245 |
-
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
246 |
-
}
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* Add product to wishlist by share key.
|
251 |
-
*
|
252 |
-
* @param WP_REST_Request $request Request object.
|
253 |
-
*
|
254 |
-
* @return mixed|WP_Error|WP_REST_Response
|
255 |
-
*/
|
256 |
-
public function wishlist_add_product( $request ) {
|
257 |
-
try {
|
258 |
-
$share_key = $request['share_key'];
|
259 |
-
|
260 |
-
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
261 |
-
|
262 |
-
$wl = new TInvWL_Wishlist();
|
263 |
-
|
264 |
-
$wishlist = $wl->get_by_share_key( $share_key );
|
265 |
-
|
266 |
-
if ( ! $wishlist ) {
|
267 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
268 |
-
}
|
269 |
-
|
270 |
-
if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
|
271 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 403 );
|
272 |
-
}
|
273 |
-
|
274 |
-
$wlp = new TInvWL_Product();
|
275 |
-
|
276 |
-
$args = array();
|
277 |
-
$args['wishlist_id'] = $wishlist['ID'];
|
278 |
-
$args['author'] = $wishlist['author'];
|
279 |
-
|
280 |
-
if ( $request['product_id'] ) {
|
281 |
-
$args['product_id'] = $request['product_id'];
|
282 |
-
}
|
283 |
-
if ( $request['variation_id'] ) {
|
284 |
-
$args['variation_id'] = $request['variation_id'];
|
285 |
-
}
|
286 |
-
if ( $request['meta'] ) {
|
287 |
-
$meta = $request['meta'];
|
288 |
-
}
|
289 |
-
|
290 |
-
$product = $wlp->add_product( $args, $meta );
|
291 |
-
|
292 |
-
if ( ! $product ) {
|
293 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_products_not_found', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 400 );
|
294 |
-
}
|
295 |
-
|
296 |
-
$response = array();
|
297 |
-
$products = $wlp->get( array( 'ID' => $product ) );
|
298 |
-
foreach ( $products as $product ) {
|
299 |
-
$response[] = $this->prepare_product_data( $product );
|
300 |
-
}
|
301 |
-
|
302 |
-
return rest_ensure_response( $response );
|
303 |
-
}
|
304 |
-
} catch ( WC_REST_Exception $e ) {
|
305 |
-
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
306 |
-
}
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Remove product by item ID.
|
311 |
-
*
|
312 |
-
* @param WP_REST_Request $request Request object.
|
313 |
-
*
|
314 |
-
* @return mixed|WP_Error|WP_REST_Response
|
315 |
-
*/
|
316 |
-
public function wishlist_remove_product( $request ) {
|
317 |
-
try {
|
318 |
-
$item_id = $request['item_id'];
|
319 |
-
|
320 |
-
if ( ! empty( $item_id ) ) {
|
321 |
-
|
322 |
-
if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
|
323 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 403 );
|
324 |
-
}
|
325 |
-
|
326 |
-
$wlp = new TInvWL_Product();
|
327 |
-
|
328 |
-
$args = array();
|
329 |
-
$args['ID'] = $item_id;
|
330 |
-
|
331 |
-
$result = $wlp->remove( $args );
|
332 |
-
|
333 |
-
if ( ! $result ) {
|
334 |
-
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_product_not_found', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 400 );
|
335 |
-
}
|
336 |
-
|
337 |
-
return rest_ensure_response( __( 'Product removed from a wishlist.', 'ti-woocommerce-wishlist' ) );
|
338 |
-
}
|
339 |
-
} catch ( WC_REST_Exception $e ) {
|
340 |
-
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
341 |
-
}
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Prepare wishlist data.
|
346 |
-
*
|
347 |
-
* @param array $wishlist Default wishlist data.
|
348 |
-
*
|
349 |
-
* @return array
|
350 |
-
*/
|
351 |
-
public function prepare_wishlist_data( $wishlist ) {
|
352 |
-
$response = array();
|
353 |
-
$response['id'] = $wishlist['ID'];
|
354 |
-
$response['user_id'] = $wishlist['author'];
|
355 |
-
$response['date_added'] = $wishlist['date'];
|
356 |
-
$response['title'] = $wishlist['title'];
|
357 |
-
$response['share_key'] = $wishlist['share_key'];
|
358 |
-
|
359 |
-
return $response;
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Prepare wishlist item data.
|
364 |
-
*
|
365 |
-
* @param array $product Default wishlist item data.
|
366 |
-
*
|
367 |
-
* @return array
|
368 |
-
*/
|
369 |
-
public function prepare_product_data( $product ) {
|
370 |
-
$response = array();
|
371 |
-
$response['item_id'] = $product['ID'];
|
372 |
-
$response['product_id'] = $product['product_id'];
|
373 |
-
$response['variation_id'] = $product['variation_id'];
|
374 |
-
$response['meta'] = $product['meta'];
|
375 |
-
$response['date_added'] = $product['date'];
|
376 |
-
$response['price'] = $product['price'];
|
377 |
-
$response['in_stock'] = $product['in_stock'];
|
378 |
-
|
379 |
-
return $response;
|
380 |
-
}
|
381 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* REST API plugin class
|
4 |
+
*
|
5 |
+
* @since 1.13.0
|
6 |
+
* @package TInvWishlist
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* REST API plugin class
|
17 |
+
*/
|
18 |
+
class TInvWL_Includes_API_Wishlist {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Endpoint namespace.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
protected $namespace = 'wc/v3';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Route base.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $rest_base = 'wishlist';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Register the routes for wishlist.
|
36 |
+
*/
|
37 |
+
public function register_routes() {
|
38 |
+
|
39 |
+
// Get wishlist data by share key.
|
40 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_share_key/(?P<share_key>[A-Fa-f0-9]{6})', array(
|
41 |
+
array(
|
42 |
+
'methods' => WP_REST_Server::READABLE,
|
43 |
+
'callback' => array( $this, 'wishlist_get_by_share_key' ),
|
44 |
+
),
|
45 |
+
) );
|
46 |
+
|
47 |
+
// Get wishlist(s) data by user ID.
|
48 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_user/(?P<user_id>[\d]+)', array(
|
49 |
+
array(
|
50 |
+
'methods' => WP_REST_Server::READABLE,
|
51 |
+
'callback' => array( $this, 'wishlist_get_by_user' ),
|
52 |
+
),
|
53 |
+
) );
|
54 |
+
|
55 |
+
// Update wishlist data by share key.
|
56 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/update/(?P<share_key>[A-Fa-f0-9]{6})', array(
|
57 |
+
array(
|
58 |
+
'methods' => WP_REST_Server::CREATABLE,
|
59 |
+
'callback' => array( $this, 'wishlist_update' ),
|
60 |
+
),
|
61 |
+
) );
|
62 |
+
|
63 |
+
// Get wishlist products by share key.
|
64 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/get_products', array(
|
65 |
+
array(
|
66 |
+
'methods' => WP_REST_Server::READABLE,
|
67 |
+
'callback' => array( $this, 'wishlist_get_products' ),
|
68 |
+
),
|
69 |
+
) );
|
70 |
+
|
71 |
+
// Add product to wishlist by share key.
|
72 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/add_product', array(
|
73 |
+
array(
|
74 |
+
'methods' => WP_REST_Server::CREATABLE,
|
75 |
+
'callback' => array( $this, 'wishlist_add_product' ),
|
76 |
+
),
|
77 |
+
) );
|
78 |
+
|
79 |
+
// Remove product by item ID.
|
80 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/remove_product/(?P<item_id>[\d]+)', array(
|
81 |
+
array(
|
82 |
+
'methods' => WP_REST_Server::READABLE,
|
83 |
+
'callback' => array( $this, 'wishlist_remove_product' ),
|
84 |
+
),
|
85 |
+
) );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get wishlist data by share key.
|
90 |
+
*
|
91 |
+
* @param WP_REST_Request $request Request object.
|
92 |
+
*
|
93 |
+
* @return mixed|WP_Error|WP_REST_Response
|
94 |
+
*/
|
95 |
+
public function wishlist_get_by_share_key( $request ) {
|
96 |
+
try {
|
97 |
+
$share_key = $request['share_key'];
|
98 |
+
|
99 |
+
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
100 |
+
$wishlist = tinv_wishlist_get( $share_key );
|
101 |
+
if ( ! $wishlist ) {
|
102 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
103 |
+
}
|
104 |
+
|
105 |
+
$response = $this->prepare_wishlist_data( $wishlist );
|
106 |
+
|
107 |
+
return rest_ensure_response( $response );
|
108 |
+
|
109 |
+
|
110 |
+
}
|
111 |
+
} catch ( WC_REST_Exception $e ) {
|
112 |
+
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Get wishlist(s) data by user ID.
|
118 |
+
*
|
119 |
+
* @param WP_REST_Request $request Request object.
|
120 |
+
*
|
121 |
+
* @return mixed|WP_Error|WP_REST_Response
|
122 |
+
*/
|
123 |
+
public function wishlist_get_by_user( $request ) {
|
124 |
+
try {
|
125 |
+
$user_id = $request['user_id'];
|
126 |
+
|
127 |
+
if ( ! empty( $user_id ) ) {
|
128 |
+
$wl = new TInvWL_Wishlist();
|
129 |
+
$wishlists = $wl->get_by_user( $user_id );
|
130 |
+
|
131 |
+
if ( ! $wishlists ) {
|
132 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_not_found', __( 'No wishlists found for this user.', 'ti-woocommerce-wishlist' ), 400 );
|
133 |
+
}
|
134 |
+
|
135 |
+
$response = array();
|
136 |
+
foreach ( $wishlists as $wishlist ) {
|
137 |
+
$response[] = $this->prepare_wishlist_data( $wishlist );
|
138 |
+
}
|
139 |
+
|
140 |
+
return rest_ensure_response( $response );
|
141 |
+
}
|
142 |
+
} catch ( WC_REST_Exception $e ) {
|
143 |
+
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Update wishlist data by share key.
|
149 |
+
*
|
150 |
+
* @param WP_REST_Request $request Request object.
|
151 |
+
*
|
152 |
+
* @return mixed|WP_Error|WP_REST_Response
|
153 |
+
*/
|
154 |
+
public function wishlist_update( $request ) {
|
155 |
+
try {
|
156 |
+
$share_key = $request['share_key'];
|
157 |
+
|
158 |
+
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
159 |
+
|
160 |
+
$wl = new TInvWL_Wishlist();
|
161 |
+
|
162 |
+
$wishlist = $wl->get_by_share_key( $share_key );
|
163 |
+
|
164 |
+
if ( ! $wishlist ) {
|
165 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
166 |
+
}
|
167 |
+
|
168 |
+
$data = array();
|
169 |
+
if ( ! empty( $request['title'] ) ) {
|
170 |
+
$data['title'] = $request['title'];
|
171 |
+
}
|
172 |
+
|
173 |
+
if ( ! empty( $request['user_id'] ) ) {
|
174 |
+
$data['author'] = $request['user_id'];
|
175 |
+
}
|
176 |
+
|
177 |
+
if ( $data && current_user_can( 'tinvwl_general_settings' ) ) {
|
178 |
+
$update = $wl->update( $wishlist['ID'], $data );
|
179 |
+
|
180 |
+
if ( $update ) {
|
181 |
+
$response = $wl->get_by_share_key( $share_key );
|
182 |
+
|
183 |
+
return rest_ensure_response( $this->prepare_wishlist_data( $response ) );
|
184 |
+
}
|
185 |
+
|
186 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_update_error', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 400 );
|
187 |
+
|
188 |
+
} else {
|
189 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 403 );
|
190 |
+
}
|
191 |
+
}
|
192 |
+
} catch ( WC_REST_Exception $e ) {
|
193 |
+
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get wishlist products by share key.
|
199 |
+
*
|
200 |
+
* @param WP_REST_Request $request Request object.
|
201 |
+
*
|
202 |
+
* @return mixed|WP_Error|WP_REST_Response
|
203 |
+
*/
|
204 |
+
public function wishlist_get_products( $request ) {
|
205 |
+
try {
|
206 |
+
$share_key = $request['share_key'];
|
207 |
+
|
208 |
+
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
209 |
+
|
210 |
+
$wl = new TInvWL_Wishlist();
|
211 |
+
|
212 |
+
$wishlist = $wl->get_by_share_key( $share_key );
|
213 |
+
|
214 |
+
if ( ! $wishlist ) {
|
215 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
216 |
+
}
|
217 |
+
|
218 |
+
$wlp = new TInvWL_Product();
|
219 |
+
|
220 |
+
$args = array();
|
221 |
+
$args['wishlist_id'] = $wishlist['ID'];
|
222 |
+
$args['external'] = false;
|
223 |
+
|
224 |
+
if ( $request['count'] ) {
|
225 |
+
$args['count'] = $request['count'];
|
226 |
+
}
|
227 |
+
if ( $request['offset'] ) {
|
228 |
+
$args['offset'] = $request['offset'];
|
229 |
+
}
|
230 |
+
if ( $request['order'] ) {
|
231 |
+
$args['order'] = $request['order'];
|
232 |
+
}
|
233 |
+
|
234 |
+
$products = $wlp->get( $args );
|
235 |
+
|
236 |
+
$response = array();
|
237 |
+
|
238 |
+
foreach ( $products as $product ) {
|
239 |
+
$response[] = $this->prepare_product_data( $product );
|
240 |
+
}
|
241 |
+
|
242 |
+
return rest_ensure_response( apply_filters( 'tinvwl_api_wishlist_get_products_response', $response ) );
|
243 |
+
}
|
244 |
+
} catch ( WC_REST_Exception $e ) {
|
245 |
+
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Add product to wishlist by share key.
|
251 |
+
*
|
252 |
+
* @param WP_REST_Request $request Request object.
|
253 |
+
*
|
254 |
+
* @return mixed|WP_Error|WP_REST_Response
|
255 |
+
*/
|
256 |
+
public function wishlist_add_product( $request ) {
|
257 |
+
try {
|
258 |
+
$share_key = $request['share_key'];
|
259 |
+
|
260 |
+
if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
|
261 |
+
|
262 |
+
$wl = new TInvWL_Wishlist();
|
263 |
+
|
264 |
+
$wishlist = $wl->get_by_share_key( $share_key );
|
265 |
+
|
266 |
+
if ( ! $wishlist ) {
|
267 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
|
271 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 403 );
|
272 |
+
}
|
273 |
+
|
274 |
+
$wlp = new TInvWL_Product();
|
275 |
+
|
276 |
+
$args = array();
|
277 |
+
$args['wishlist_id'] = $wishlist['ID'];
|
278 |
+
$args['author'] = $wishlist['author'];
|
279 |
+
|
280 |
+
if ( $request['product_id'] ) {
|
281 |
+
$args['product_id'] = $request['product_id'];
|
282 |
+
}
|
283 |
+
if ( $request['variation_id'] ) {
|
284 |
+
$args['variation_id'] = $request['variation_id'];
|
285 |
+
}
|
286 |
+
if ( $request['meta'] ) {
|
287 |
+
$meta = $request['meta'];
|
288 |
+
}
|
289 |
+
|
290 |
+
$product = $wlp->add_product( $args, $meta );
|
291 |
+
|
292 |
+
if ( ! $product ) {
|
293 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_products_not_found', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 400 );
|
294 |
+
}
|
295 |
+
|
296 |
+
$response = array();
|
297 |
+
$products = $wlp->get( array( 'ID' => $product ) );
|
298 |
+
foreach ( $products as $product ) {
|
299 |
+
$response[] = $this->prepare_product_data( $product );
|
300 |
+
}
|
301 |
+
|
302 |
+
return rest_ensure_response( $response );
|
303 |
+
}
|
304 |
+
} catch ( WC_REST_Exception $e ) {
|
305 |
+
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Remove product by item ID.
|
311 |
+
*
|
312 |
+
* @param WP_REST_Request $request Request object.
|
313 |
+
*
|
314 |
+
* @return mixed|WP_Error|WP_REST_Response
|
315 |
+
*/
|
316 |
+
public function wishlist_remove_product( $request ) {
|
317 |
+
try {
|
318 |
+
$item_id = $request['item_id'];
|
319 |
+
|
320 |
+
if ( ! empty( $item_id ) ) {
|
321 |
+
|
322 |
+
if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
|
323 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 403 );
|
324 |
+
}
|
325 |
+
|
326 |
+
$wlp = new TInvWL_Product();
|
327 |
+
|
328 |
+
$args = array();
|
329 |
+
$args['ID'] = $item_id;
|
330 |
+
|
331 |
+
$result = $wlp->remove( $args );
|
332 |
+
|
333 |
+
if ( ! $result ) {
|
334 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_product_not_found', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 400 );
|
335 |
+
}
|
336 |
+
|
337 |
+
return rest_ensure_response( __( 'Product removed from a wishlist.', 'ti-woocommerce-wishlist' ) );
|
338 |
+
}
|
339 |
+
} catch ( WC_REST_Exception $e ) {
|
340 |
+
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Prepare wishlist data.
|
346 |
+
*
|
347 |
+
* @param array $wishlist Default wishlist data.
|
348 |
+
*
|
349 |
+
* @return array
|
350 |
+
*/
|
351 |
+
public function prepare_wishlist_data( $wishlist ) {
|
352 |
+
$response = array();
|
353 |
+
$response['id'] = $wishlist['ID'];
|
354 |
+
$response['user_id'] = $wishlist['author'];
|
355 |
+
$response['date_added'] = $wishlist['date'];
|
356 |
+
$response['title'] = $wishlist['title'];
|
357 |
+
$response['share_key'] = $wishlist['share_key'];
|
358 |
+
|
359 |
+
return $response;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Prepare wishlist item data.
|
364 |
+
*
|
365 |
+
* @param array $product Default wishlist item data.
|
366 |
+
*
|
367 |
+
* @return array
|
368 |
+
*/
|
369 |
+
public function prepare_product_data( $product ) {
|
370 |
+
$response = array();
|
371 |
+
$response['item_id'] = $product['ID'];
|
372 |
+
$response['product_id'] = $product['product_id'];
|
373 |
+
$response['variation_id'] = $product['variation_id'];
|
374 |
+
$response['meta'] = $product['meta'];
|
375 |
+
$response['date_added'] = $product['date'];
|
376 |
+
$response['price'] = $product['price'];
|
377 |
+
$response['in_stock'] = $product['in_stock'];
|
378 |
+
|
379 |
+
return $response;
|
380 |
+
}
|
381 |
+
}
|
includes/form.helper.php
CHANGED
@@ -575,13 +575,12 @@ class TInvWL_Form {
|
|
575 |
$mimefiles = array_filter( $mimefiles );
|
576 |
$mimefiles = wp_json_encode( $mimefiles );
|
577 |
|
578 |
-
$extra_field .= ' disabled="disabled"';
|
579 |
$data['type'] = 'text';
|
580 |
|
581 |
wp_enqueue_media();
|
582 |
|
583 |
return sprintf( "<div class='tinvwl-input-group'>%s%s<div class='tinvwl-input-group-btn'>%s</div></div><script type=\"text/javascript\">jQuery(document).ready(function($){var nn='%s';" . ( empty( $value ) ? "$('.' + nn + '-preview').hide();" : "" ) . "$('input[name=\"'+nn+'-btn\"]').click(function(e){e.preventDefault();var i=wp.media({multiple:false, library:{type:{$mimefiles}}}).open().on('select',function(e){var u=i.state().get('selection').first();var iu=u.toJSON().url;$('input[name=\"'+nn+'\"]').val(iu);$('.' + nn + '-preview').show();$('.' + nn + '-preview span img').attr('src', iu);});});});</script>", // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
584 |
-
'<div class="' . $data['name'] . '-preview tinvwl-input-group-btn"><div class="tinvwl-icon-preview"><span
|
585 |
'name' => $data['name'] . '-btn',
|
586 |
'type' => 'button',
|
587 |
'class' => 'tinvwl-btn white smaller',
|
575 |
$mimefiles = array_filter( $mimefiles );
|
576 |
$mimefiles = wp_json_encode( $mimefiles );
|
577 |
|
|
|
578 |
$data['type'] = 'text';
|
579 |
|
580 |
wp_enqueue_media();
|
581 |
|
582 |
return sprintf( "<div class='tinvwl-input-group'>%s%s<div class='tinvwl-input-group-btn'>%s</div></div><script type=\"text/javascript\">jQuery(document).ready(function($){var nn='%s';" . ( empty( $value ) ? "$('.' + nn + '-preview').hide();" : "" ) . "$('input[name=\"'+nn+'-btn\"]').click(function(e){e.preventDefault();var i=wp.media({multiple:false, library:{type:{$mimefiles}}}).open().on('select',function(e){var u=i.state().get('selection').first();var iu=u.toJSON().url;$('input[name=\"'+nn+'\"]').val(iu);$('.' + nn + '-preview').show();$('.' + nn + '-preview span img').attr('src', iu);});});});</script>", // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
583 |
+
'<div class="' . $data['name'] . '-preview tinvwl-input-group-btn"><div class="tinvwl-icon-preview"><span><img src="' . $value . '" /></span></div></div>', self::_text( $data, $value, $extra_field ), self::_text( array(
|
584 |
'name' => $data['name'] . '-btn',
|
585 |
'type' => 'button',
|
586 |
'class' => 'tinvwl-btn white smaller',
|
includes/product.helper.php
CHANGED
@@ -670,7 +670,6 @@ class TInvWL_Product {
|
|
670 |
if ( empty( $meta ) ) {
|
671 |
return '';
|
672 |
}
|
673 |
-
ksort( $meta );
|
674 |
|
675 |
return json_encode( $meta );
|
676 |
}
|
670 |
if ( empty( $meta ) ) {
|
671 |
return '';
|
672 |
}
|
|
|
673 |
|
674 |
return json_encode( $meta );
|
675 |
}
|
integrations/elex-woocommerce-catalog-mode.php
CHANGED
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
21 |
/**
|
22 |
* Run hooks on page redirect.
|
23 |
*/
|
24 |
-
function
|
25 |
if ( class_exists( 'Elex_CM_Price_Discount_Admin' ) ) {
|
26 |
|
27 |
global $post;
|
@@ -30,21 +30,21 @@ function elex_init() {
|
|
30 |
|
31 |
if ( 'yes' == get_option( 'eh_pricing_discount_cart_catalog_mode' ) && 'yes' == get_option( 'elex_catalog_remove_addtocart_product' ) ) {
|
32 |
if ( ! ( get_option( 'eh_pricing_discount_price_catalog_mode_exclude_admin' ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
|
33 |
-
add_action( 'woocommerce_single_product_summary', '
|
34 |
}
|
35 |
} elseif ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog', true ) ) && ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) || ( '' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) ) ) {
|
36 |
if ( ! ( get_post_meta( $post->ID, 'product_adjustment_exclude_admin_catalog', true ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
|
37 |
-
add_action( 'woocommerce_single_product_summary', '
|
38 |
}
|
39 |
}
|
40 |
}
|
41 |
}
|
42 |
}
|
43 |
|
44 |
-
add_action( 'template_redirect', '
|
45 |
|
46 |
// Add a custom hook for single page.
|
47 |
-
function
|
48 |
add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', '__return_true' );
|
49 |
do_action( 'tinvwl_single_product_summary' );
|
50 |
}
|
21 |
/**
|
22 |
* Run hooks on page redirect.
|
23 |
*/
|
24 |
+
function tinvwl_elex_init() {
|
25 |
if ( class_exists( 'Elex_CM_Price_Discount_Admin' ) ) {
|
26 |
|
27 |
global $post;
|
30 |
|
31 |
if ( 'yes' == get_option( 'eh_pricing_discount_cart_catalog_mode' ) && 'yes' == get_option( 'elex_catalog_remove_addtocart_product' ) ) {
|
32 |
if ( ! ( get_option( 'eh_pricing_discount_price_catalog_mode_exclude_admin' ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
|
33 |
+
add_action( 'woocommerce_single_product_summary', 'tinvwl_elex_single_product_summary', 40 );
|
34 |
}
|
35 |
} elseif ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog', true ) ) && ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) || ( '' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) ) ) {
|
36 |
if ( ! ( get_post_meta( $post->ID, 'product_adjustment_exclude_admin_catalog', true ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
|
37 |
+
add_action( 'woocommerce_single_product_summary', 'tinvwl_elex_single_product_summary', 40 );
|
38 |
}
|
39 |
}
|
40 |
}
|
41 |
}
|
42 |
}
|
43 |
|
44 |
+
add_action( 'template_redirect', 'tinvwl_elex_init' );
|
45 |
|
46 |
// Add a custom hook for single page.
|
47 |
+
function tinvwl_elex_single_product_summary() {
|
48 |
add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', '__return_true' );
|
49 |
do_action( 'tinvwl_single_product_summary' );
|
50 |
}
|
integrations/hide-price-add-to-cart-button.php
CHANGED
@@ -96,7 +96,7 @@ if ( class_exists( 'Addify_Woo_Hide_Price_Front' ) ) {
|
|
96 |
}
|
97 |
|
98 |
//wishlist add to cart button
|
99 |
-
add_filter( 'tinvwl_wishlist_item_action_add_to_cart', '
|
100 |
|
101 |
/**
|
102 |
* Allow show button add to cart
|
@@ -107,7 +107,7 @@ if ( class_exists( 'Addify_Woo_Hide_Price_Front' ) ) {
|
|
107 |
*
|
108 |
* @return boolean
|
109 |
*/
|
110 |
-
function
|
111 |
|
112 |
$args = array(
|
113 |
'post_type' => 'addify_whp',
|
96 |
}
|
97 |
|
98 |
//wishlist add to cart button
|
99 |
+
add_filter( 'tinvwl_wishlist_item_action_add_to_cart', 'tinvwl_product_allow_add_to_cart_afwhp', 10, 3 );
|
100 |
|
101 |
/**
|
102 |
* Allow show button add to cart
|
107 |
*
|
108 |
* @return boolean
|
109 |
*/
|
110 |
+
function tinvwl_product_allow_add_to_cart_afwhp( $allow, $wlproduct, $product ) {
|
111 |
|
112 |
$args = array(
|
113 |
'post_type' => 'addify_whp',
|
integrations/mycred.php
CHANGED
@@ -23,8 +23,8 @@ if ( defined( 'myCRED_VERSION' ) ) {
|
|
23 |
/**
|
24 |
* Register Hook
|
25 |
*/
|
26 |
-
add_filter( 'mycred_setup_hooks', '
|
27 |
-
function
|
28 |
|
29 |
$installed['tinvwl'] = array(
|
30 |
'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
|
@@ -39,8 +39,8 @@ if ( defined( 'myCRED_VERSION' ) ) {
|
|
39 |
/**
|
40 |
* TI WooCommerce Wihslist Hook
|
41 |
*/
|
42 |
-
add_action( 'mycred_load_hooks', '
|
43 |
-
function
|
44 |
|
45 |
// If the hook has been replaced or if plugin is not installed, exit now
|
46 |
if ( class_exists( 'myCRED_Hook_TinvWL' ) ) {
|
23 |
/**
|
24 |
* Register Hook
|
25 |
*/
|
26 |
+
add_filter( 'mycred_setup_hooks', 'tinvwl_mycred_register_ti_woocommerce_wishlist_hook', 100 );
|
27 |
+
function tinvwl_mycred_register_ti_woocommerce_wishlist_hook( $installed ) {
|
28 |
|
29 |
$installed['tinvwl'] = array(
|
30 |
'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
|
39 |
/**
|
40 |
* TI WooCommerce Wihslist Hook
|
41 |
*/
|
42 |
+
add_action( 'mycred_load_hooks', 'tinvwl_mycred_load_ti_woocommerce_wishlist_hook', 100 );
|
43 |
+
function tinvwl_mycred_load_ti_woocommerce_wishlist_hook() {
|
44 |
|
45 |
// If the hook has been replaced or if plugin is not installed, exit now
|
46 |
if ( class_exists( 'myCRED_Hook_TinvWL' ) ) {
|
integrations/theme-divi.php
CHANGED
@@ -21,21 +21,21 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
21 |
/**
|
22 |
* Run hooks on page redirect.
|
23 |
*/
|
24 |
-
function
|
25 |
if ( class_exists( 'ET_Builder_Element' ) && is_product() && version_compare( ET_BUILDER_PRODUCT_VERSION, '4.0.0', '>=' ) ) {
|
26 |
global $post;
|
27 |
$product = wc_get_product( $post->ID );
|
28 |
if ( ! empty( $product ) && ! $product->is_in_stock() ) {
|
29 |
remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 29 );
|
30 |
remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 31 );
|
31 |
-
add_action( 'woocommerce_' . $product->get_type() . '_add_to_cart', '
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
|
36 |
-
add_action( 'template_redirect', '
|
37 |
|
38 |
// Add a custom hook for single page.
|
39 |
-
function
|
40 |
do_action( 'tinvwl_single_product_summary' );
|
41 |
}
|
21 |
/**
|
22 |
* Run hooks on page redirect.
|
23 |
*/
|
24 |
+
function tinvwl_divi_init() {
|
25 |
if ( class_exists( 'ET_Builder_Element' ) && is_product() && version_compare( ET_BUILDER_PRODUCT_VERSION, '4.0.0', '>=' ) ) {
|
26 |
global $post;
|
27 |
$product = wc_get_product( $post->ID );
|
28 |
if ( ! empty( $product ) && ! $product->is_in_stock() ) {
|
29 |
remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 29 );
|
30 |
remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 31 );
|
31 |
+
add_action( 'woocommerce_' . $product->get_type() . '_add_to_cart', 'tinvwl_divi_single_product_summary', 40 );
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
add_action( 'template_redirect', 'tinvwl_divi_init' );
|
37 |
|
38 |
// Add a custom hook for single page.
|
39 |
+
function tinvwl_divi_single_product_summary() {
|
40 |
do_action( 'tinvwl_single_product_summary' );
|
41 |
}
|
integrations/theme-flatsome.php
CHANGED
@@ -17,18 +17,18 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
-
if ( ! function_exists( '
|
21 |
|
22 |
/**
|
23 |
* Run hooks after theme init.
|
24 |
*/
|
25 |
-
function
|
26 |
if ( function_exists( 'flatsome_option' ) ) {
|
27 |
|
28 |
|
29 |
if ( get_theme_mod( 'catalog_mode' ) ) {
|
30 |
|
31 |
-
add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', '
|
32 |
|
33 |
switch ( tinv_get_option( 'add_to_wishlist', 'position' ) ) {
|
34 |
case 'before':
|
@@ -39,28 +39,28 @@ if ( ! function_exists( 'flatsome_init' ) ) {
|
|
39 |
break;
|
40 |
}
|
41 |
|
42 |
-
add_action( 'woocommerce_single_variation', '
|
43 |
|
44 |
|
45 |
}
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
add_action( 'init', '
|
50 |
}
|
51 |
|
52 |
-
if ( ! function_exists( '
|
53 |
|
54 |
/**
|
55 |
* Output variation hidden field.
|
56 |
*
|
57 |
*/
|
58 |
-
function
|
59 |
echo '<input type="hidden" name="variation_id" class="variation_id" value="0" />';
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
if ( ! function_exists( '
|
64 |
|
65 |
/**
|
66 |
* Output wishlist button for Flatsome catalog mode
|
@@ -69,7 +69,7 @@ if ( ! function_exists( 'flatsome_woocommerce_catalog_mode' ) ) {
|
|
69 |
*
|
70 |
* @return bool
|
71 |
*/
|
72 |
-
function
|
73 |
if ( ! $product->is_type( 'variable' ) ) {
|
74 |
return true;
|
75 |
}
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
+
if ( ! function_exists( 'tinvwl_flatsome_init' ) ) {
|
21 |
|
22 |
/**
|
23 |
* Run hooks after theme init.
|
24 |
*/
|
25 |
+
function tinvwl_flatsome_init() {
|
26 |
if ( function_exists( 'flatsome_option' ) ) {
|
27 |
|
28 |
|
29 |
if ( get_theme_mod( 'catalog_mode' ) ) {
|
30 |
|
31 |
+
add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', 'tinvwl_flatsome_woocommerce_catalog_mode', 10, 2 );
|
32 |
|
33 |
switch ( tinv_get_option( 'add_to_wishlist', 'position' ) ) {
|
34 |
case 'before':
|
39 |
break;
|
40 |
}
|
41 |
|
42 |
+
add_action( 'woocommerce_single_variation', 'tinvwl_tinvwl_flatsome_woocommerce_catalog_mode_variable', 20 );
|
43 |
|
44 |
|
45 |
}
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
add_action( 'init', 'tinvwl_flatsome_init' );
|
50 |
}
|
51 |
|
52 |
+
if ( ! function_exists( 'tinvwl_tinvwl_flatsome_woocommerce_catalog_mode_variable' ) ) {
|
53 |
|
54 |
/**
|
55 |
* Output variation hidden field.
|
56 |
*
|
57 |
*/
|
58 |
+
function tinvwl_tinvwl_flatsome_woocommerce_catalog_mode_variable() {
|
59 |
echo '<input type="hidden" name="variation_id" class="variation_id" value="0" />';
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
if ( ! function_exists( 'tinvwl_flatsome_woocommerce_catalog_mode' ) ) {
|
64 |
|
65 |
/**
|
66 |
* Output wishlist button for Flatsome catalog mode
|
69 |
*
|
70 |
* @return bool
|
71 |
*/
|
72 |
+
function tinvwl_flatsome_woocommerce_catalog_mode( $allow, $product ) {
|
73 |
if ( ! $product->is_type( 'variable' ) ) {
|
74 |
return true;
|
75 |
}
|
integrations/theme-kallyas.php
CHANGED
@@ -17,12 +17,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
-
if ( ! function_exists( '
|
21 |
|
22 |
/**
|
23 |
* Run hooks after theme init.
|
24 |
*/
|
25 |
-
function
|
26 |
if ( function_exists( 'zget_option' ) ) {
|
27 |
|
28 |
$show_cart_to_visitors = zget_option( 'show_cart_to_visitors', 'zn_woocommerce_options', false, 'yes' );
|
@@ -34,5 +34,5 @@ if ( ! function_exists( 'kallyas_init' ) ) {
|
|
34 |
}
|
35 |
}
|
36 |
|
37 |
-
add_action( 'init', '
|
38 |
}
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
+
if ( ! function_exists( 'tinvwl_kallyas_init' ) ) {
|
21 |
|
22 |
/**
|
23 |
* Run hooks after theme init.
|
24 |
*/
|
25 |
+
function tinvwl_kallyas_init() {
|
26 |
if ( function_exists( 'zget_option' ) ) {
|
27 |
|
28 |
$show_cart_to_visitors = zget_option( 'show_cart_to_visitors', 'zn_woocommerce_options', false, 'yes' );
|
34 |
}
|
35 |
}
|
36 |
|
37 |
+
add_action( 'init', 'tinvwl_kallyas_init' );
|
38 |
}
|
integrations/theme-oceanwp.php
CHANGED
@@ -18,13 +18,13 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
18 |
}
|
19 |
|
20 |
// OceanWP theme compatibility;
|
21 |
-
if ( ! function_exists( '
|
22 |
-
add_action( 'init', '
|
23 |
|
24 |
/**
|
25 |
* OceanWP theme fix for catalog add to wishlist button position
|
26 |
*/
|
27 |
-
function
|
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 );
|
18 |
}
|
19 |
|
20 |
// OceanWP theme compatibility;
|
21 |
+
if ( ! function_exists( 'tinvwl_oceanwp_fix_archive_markup' ) ) {
|
22 |
+
add_action( 'init', 'tinvwl_oceanwp_fix_archive_markup' );
|
23 |
|
24 |
/**
|
25 |
* OceanWP theme fix for catalog add to wishlist button position
|
26 |
*/
|
27 |
+
function tinvwl_oceanwp_fix_archive_markup() {
|
28 |
if ( class_exists( 'OceanWP_WooCommerce_Config' ) && 'above_thumb' === tinv_get_option( 'add_to_wishlist_catalog', 'position' ) ) {
|
29 |
remove_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 9 );
|
30 |
add_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 10 );
|
integrations/uni-woo-custom-product-options.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @name Product Options and Price Calculation Formulas for WooCommerce – Uni CPO
|
6 |
*
|
7 |
-
* @version 4.7.
|
8 |
*
|
9 |
* @slug uni-woo-custom-product-options
|
10 |
*
|
@@ -30,6 +30,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_uni_woo_custom_product_options'
|
|
30 |
*/
|
31 |
|
32 |
function tinv_wishlist_item_meta_uni_woo_custom_product_options( $item_data, $product_id, $variation_id ) {
|
|
|
33 |
if ( class_exists( 'Uni_Cpo' ) ) {
|
34 |
foreach ( array_keys( $item_data ) as $key ) {
|
35 |
if ( strpos( $key, 'cpo_' ) === 0 ) {
|
@@ -39,7 +40,11 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_uni_woo_custom_product_options'
|
|
39 |
|
40 |
if ( ! empty( $item_data ) ) {
|
41 |
|
42 |
-
$form_data =
|
|
|
|
|
|
|
|
|
43 |
|
44 |
$filtered_form_data = array_filter( $form_data, function ( $k ) use ( $form_data ) {
|
45 |
return false !== strpos( $k, UniCpo()->get_var_slug() ) && ! empty( $form_data[ $k ] );
|
@@ -53,6 +58,26 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_uni_woo_custom_product_options'
|
|
53 |
foreach ( $posts_ids as $post_id ) {
|
54 |
$option = uni_cpo_get_option( $post_id );
|
55 |
if ( is_object( $option ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
$item_data[ $option->get_slug() ]['key'] = uni_cpo_sanitize_label( $option->cpo_order_label() );
|
57 |
}
|
58 |
}
|
4 |
*
|
5 |
* @name Product Options and Price Calculation Formulas for WooCommerce – Uni CPO
|
6 |
*
|
7 |
+
* @version 4.7.5
|
8 |
*
|
9 |
* @slug uni-woo-custom-product-options
|
10 |
*
|
30 |
*/
|
31 |
|
32 |
function tinv_wishlist_item_meta_uni_woo_custom_product_options( $item_data, $product_id, $variation_id ) {
|
33 |
+
|
34 |
if ( class_exists( 'Uni_Cpo' ) ) {
|
35 |
foreach ( array_keys( $item_data ) as $key ) {
|
36 |
if ( strpos( $key, 'cpo_' ) === 0 ) {
|
40 |
|
41 |
if ( ! empty( $item_data ) ) {
|
42 |
|
43 |
+
$form_data = array();
|
44 |
+
|
45 |
+
foreach ( $item_data as $key => $value ) {
|
46 |
+
$form_data[ $key ] = $value['display'];
|
47 |
+
}
|
48 |
|
49 |
$filtered_form_data = array_filter( $form_data, function ( $k ) use ( $form_data ) {
|
50 |
return false !== strpos( $k, UniCpo()->get_var_slug() ) && ! empty( $form_data[ $k ] );
|
58 |
foreach ( $posts_ids as $post_id ) {
|
59 |
$option = uni_cpo_get_option( $post_id );
|
60 |
if ( is_object( $option ) ) {
|
61 |
+
$calculate_result = $option->calculate( $filtered_form_data );
|
62 |
+
if ( is_array( $calculate_result ) && isset( $calculate_result[ $option->get_slug() ] ) ) {
|
63 |
+
if ( is_array( $calculate_result[ $option->get_slug() ]['order_meta'] ) ) {
|
64 |
+
$calculate_result[ $option->get_slug() ]['order_meta'] = array_map( function ( $item ) {
|
65 |
+
if ( ! is_numeric( $item ) ) {
|
66 |
+
return esc_html__( $item );
|
67 |
+
} else {
|
68 |
+
return $item;
|
69 |
+
}
|
70 |
+
}, $calculate_result[ $option->get_slug() ]['order_meta'] );
|
71 |
+
$display_value = implode( ', ', $calculate_result[ $option->get_slug() ]['order_meta'] );
|
72 |
+
} else {
|
73 |
+
if ( ! is_numeric( $calculate_result[ $option->get_slug() ]['order_meta'] ) ) {
|
74 |
+
$display_value = esc_html__( $calculate_result[ $option->get_slug() ]['order_meta'] );
|
75 |
+
} else {
|
76 |
+
$display_value = $calculate_result[ $option->get_slug() ]['order_meta'];
|
77 |
+
}
|
78 |
+
}
|
79 |
+
$item_data[ $option->get_slug() ]['display'] = $display_value;
|
80 |
+
}
|
81 |
$item_data[ $option->get_slug() ]['key'] = uni_cpo_sanitize_label( $option->cpo_order_label() );
|
82 |
}
|
83 |
}
|
integrations/woocommerce-gravityforms-product-addons.php
CHANGED
@@ -17,12 +17,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
-
if ( ! function_exists( '
|
21 |
|
22 |
/**
|
23 |
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
24 |
*/
|
25 |
-
function
|
26 |
if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
|
27 |
return false;
|
28 |
}
|
@@ -85,7 +85,7 @@ if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
|
85 |
}
|
86 |
}
|
87 |
|
88 |
-
add_action( 'init', '
|
89 |
} // End if().
|
90 |
|
91 |
if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
+
if ( ! function_exists( 'tinvwl_gf_productaddon_support' ) ) {
|
21 |
|
22 |
/**
|
23 |
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
24 |
*/
|
25 |
+
function tinvwl_gf_productaddon_support() {
|
26 |
if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
|
27 |
return false;
|
28 |
}
|
85 |
}
|
86 |
}
|
87 |
|
88 |
+
add_action( 'init', 'tinvwl_gf_productaddon_support' );
|
89 |
} // End if().
|
90 |
|
91 |
if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
|
integrations/woocommerce-product-table.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name WooCommerce Product Table
|
6 |
+
*
|
7 |
+
* @version 2.6.3
|
8 |
+
*
|
9 |
+
* @slug woocommerce-product-table
|
10 |
+
*
|
11 |
+
* @url https://barn2.co.uk/wordpress-plugins/woocommerce-product-table/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! class_exists( 'Abstract_Product_Table_Data' ) ) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Gets data for the 'wishlist' column to use in the product table.
|
26 |
+
*
|
27 |
+
* @license GPL-3.0
|
28 |
+
*/
|
29 |
+
class TINVWL_Product_Table_Data_Wishlist extends Abstract_Product_Table_Data {
|
30 |
+
|
31 |
+
public function get_data() {
|
32 |
+
return apply_filters( 'wc_product_table_data_wishlist', do_shortcode( '[ti_wishlists_addtowishlist]' ), $this->product );
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
add_filter( 'wc_product_table_custom_table_data_wishlist', function ( $data_obj, $product, $args ) {
|
38 |
+
return new TINVWL_Product_Table_Data_Wishlist( $product );
|
39 |
+
}, 10, 3 );
|
languages/ti-woocommerce-wishlist.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
# Copyright (C) 2020 TI WooCommerce Wishlist Plugin - 1.20.
|
2 |
-
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.20.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.20.
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -988,6 +988,18 @@ msgstr ""
|
|
988 |
msgid "Note"
|
989 |
msgstr ""
|
990 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
#: integrations/gift-cards-for-woocommerce.php:104
|
992 |
msgid "Reload existing Gift Card"
|
993 |
msgstr ""
|
@@ -1036,6 +1048,14 @@ msgstr ""
|
|
1036 |
msgid "Flat rate cost"
|
1037 |
msgstr ""
|
1038 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
#: integrations/wp-grid-builder.php:72
|
1040 |
msgid "Wishlist Button"
|
1041 |
msgstr ""
|
1 |
+
# Copyright (C) 2020 TI WooCommerce Wishlist Plugin - 1.20.2
|
2 |
+
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.20.2 package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.20.2\n"
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
988 |
msgid "Note"
|
989 |
msgstr ""
|
990 |
|
991 |
+
#: integrations/gift-cards-for-woocommerce.php:95
|
992 |
+
msgid "To"
|
993 |
+
msgstr ""
|
994 |
+
|
995 |
+
#: integrations/gift-cards-for-woocommerce.php:98
|
996 |
+
msgid "To Email"
|
997 |
+
msgstr ""
|
998 |
+
|
999 |
+
#: integrations/gift-cards-for-woocommerce.php:101
|
1000 |
+
msgid "Address"
|
1001 |
+
msgstr ""
|
1002 |
+
|
1003 |
#: integrations/gift-cards-for-woocommerce.php:104
|
1004 |
msgid "Reload existing Gift Card"
|
1005 |
msgstr ""
|
1048 |
msgid "Flat rate cost"
|
1049 |
msgstr ""
|
1050 |
|
1051 |
+
#: integrations/woocommerce-composite-products.php:116, integrations/woocommerce-mix-and-match-products.php:86, integrations/woocommerce-product-bundles.php:110, integrations/yith-woocommerce-product-bundles.php:138, templates/ti-wishlist-user.php:143, templates/ti-wishlist.php:151
|
1052 |
+
msgid "In stock"
|
1053 |
+
msgstr ""
|
1054 |
+
|
1055 |
+
#: integrations/woocommerce-gravityforms-product-addons.php:43
|
1056 |
+
msgid "Select options"
|
1057 |
+
msgstr ""
|
1058 |
+
|
1059 |
#: integrations/wp-grid-builder.php:72
|
1060 |
msgid "Wishlist Button"
|
1061 |
msgstr ""
|
public/tinvwl.class.php
CHANGED
@@ -105,7 +105,7 @@ class TInvWL_Public_TInvWL {
|
|
105 |
* @return mixed
|
106 |
*/
|
107 |
function add_rewrite_rules_raw( $rules ) {
|
108 |
-
if ( tinv_get_option( 'permalinks', 'force' ) ) {
|
109 |
self::add_rewrite_rules();
|
110 |
$rules = self::$rules_raw + $rules;
|
111 |
}
|
105 |
* @return mixed
|
106 |
*/
|
107 |
function add_rewrite_rules_raw( $rules ) {
|
108 |
+
if ( is_array( self::$rules_raw ) && tinv_get_option( 'permalinks', 'force' ) ) {
|
109 |
self::add_rewrite_rules();
|
110 |
$rules = self::$rules_raw + $rules;
|
111 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: templateinvaders
|
|
3 |
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.4
|
6 |
-
Stable tag: 1.20.
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
@@ -163,6 +163,16 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
|
|
163 |
|
164 |
|
165 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
= 1.20.1 =
|
167 |
*Release Date - 14 May 2020*
|
168 |
|
3 |
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.4
|
6 |
+
Stable tag: 1.20.2
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
163 |
|
164 |
|
165 |
== Changelog ==
|
166 |
+
= 1.20.2 =
|
167 |
+
*Release Date - 4 June 2020*
|
168 |
+
|
169 |
+
* Added compatibility with WooCommerce 4.2.x
|
170 |
+
* Added integration with WooCommerce Product Table plugin as a custom table column 'wishlist'
|
171 |
+
* Improved integration with [Product Options and Price Calculation Formulas for WooCommerce – Uni CPO](https://wordpress.org/plugins/uni-woo-custom-product-options/) plugin
|
172 |
+
* Fixed PHP Fatal error in case wishlist page doesn't set and forced permalinks option is active
|
173 |
+
* Fixed an issue when custom button icon didn't save in settings
|
174 |
+
|
175 |
+
|
176 |
= 1.20.1 =
|
177 |
*Release Date - 14 May 2020*
|
178 |
|
ti-woocommerce-wishlist.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Plugin Name: TI WooCommerce Wishlist
|
5 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
-
* Version: 1.20.
|
8 |
* Requires at least: 4.7
|
9 |
* Tested up to: 5.4
|
10 |
* WC requires at least: 2.6
|
11 |
-
* WC tested up to: 4.
|
12 |
* Author: TemplateInvaders
|
13 |
* Author URI: https://templateinvaders.com/
|
14 |
* License: GPL-2.0+
|
@@ -41,7 +41,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
|
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
-
define( 'TINVWL_FVERSION', '1.20.
|
45 |
}
|
46 |
|
47 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
4 |
* Plugin Name: TI WooCommerce Wishlist
|
5 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
+
* Version: 1.20.2
|
8 |
* Requires at least: 4.7
|
9 |
* Tested up to: 5.4
|
10 |
* WC requires at least: 2.6
|
11 |
+
* WC tested up to: 4.2.0
|
12 |
* Author: TemplateInvaders
|
13 |
* Author URI: https://templateinvaders.com/
|
14 |
* License: GPL-2.0+
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
+
define( 'TINVWL_FVERSION', '1.20.2' );
|
45 |
}
|
46 |
|
47 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|