CTX Feed – WooCommerce Product Feed Manager Plugin - Version 3.2.17

Version Description

(2020-02-09) = * Fix Tax calculation based on store address. * Localize Javascript based Messages.

Download this release

Release Info

Developer wahid0003
Plugin Icon 128x128 CTX Feed – WooCommerce Product Feed Manager Plugin
Version 3.2.17
Comparing to
See all releases

Code changes from version 3.2.16 to 3.2.17

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags:product feed,woocommerce product feed,google shopping feed,google shopping,
5
  Requires at least: 3.6
6
  Tested Up To: 5.3.2
7
  Requires PHP: 5.6
8
- Stable tag: 3.2.16
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -305,6 +305,10 @@ Using pro version:
305
 
306
  == Changelog ==
307
 
 
 
 
 
308
  = 3.2.16 (2020-02-02) =
309
  * Tested upto current WordPress and WooCommerce
310
  * PHPCS config added and tested for WPCS Issues
5
  Requires at least: 3.6
6
  Tested Up To: 5.3.2
7
  Requires PHP: 5.6
8
+ Stable tag: 3.2.17
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
305
 
306
  == Changelog ==
307
 
308
+ = 3.2.17 (2020-02-09) =
309
+ * Fix Tax calculation based on store address.
310
+ * Localize Javascript based Messages.
311
+
312
  = 3.2.16 (2020-02-02) =
313
  * Tested upto current WordPress and WooCommerce
314
  * PHPCS config added and tested for WPCS Issues
admin/class-woo-feed-admin.php CHANGED
@@ -96,46 +96,66 @@ class Woo_Feed_Admin
96
  * between the defined hooks and the functions defined in this
97
  * class.
98
  */
99
- if( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
100
- wp_register_script( "jquery-selectize", plugin_dir_url(__FILE__) . 'js/selectize.min.js', array( 'jquery' ), $this->version, false );
101
- wp_register_script( "jquery-validate", plugin_dir_url(__FILE__) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version, false );
102
- wp_register_script( "jquery-validate-additional-methods", plugin_dir_url(__FILE__) . 'js/additional-methods.min.js', array( 'jquery', 'jquery-validate' ), $this->version, false );
103
- wp_register_script( "jquery-sortable", plugin_dir_url(__FILE__) . 'js/jquery-sortable.js', array( 'jquery' ), $this->version, false );
104
 
105
- wp_register_script( "jquery-slick", plugin_dir_url(__FILE__) . 'js/slick.js', array( 'jquery' ), $this->version, false );
 
106
 
107
- if( ! wp_script_is( 'clipboard', 'registered' ) ) {
108
- wp_register_script( 'clipboard', plugin_dir_url(__FILE__) . 'js/clipboard.min.js', [], '2.0.4', false);
109
  }
110
 
111
  $feedScriptDependency = [
112
- 'jquery', 'clipboard',
113
- 'jquery-selectize', 'jquery-sortable',
114
- 'jquery-validate', 'jquery-validate-additional-methods',
 
 
 
115
  'wp-util',
116
  'utils',
117
  'wp-lists',
118
  'postbox',
119
  'tags-box',
120
  // 'underscore', 'word-count', 'jquery-ui-autocomplete',
121
- 'jquery-touch-punch'
122
  ];
123
- if( $hook == 'woo-feed_page_webappick-feed-pro-vs-free' ) {
124
  $feedScriptDependency[] = 'jquery-slick';
 
125
  }
126
 
127
  wp_register_script($this->woo_feed, plugin_dir_url(__FILE__) . 'js/woo-feed-admin.js', $feedScriptDependency, $this->version, false);
128
- wp_localize_script($this->woo_feed, 'wpf_ajax_obj', array(
129
- 'wpf_ajax_url' => admin_url( 'admin-ajax.php' ),
130
- 'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
131
- 'na' => esc_html__( 'N/A', 'woo-feed' ),
132
- 'regenerate' => esc_html__( 'Generating...', 'woo-feed' ),
133
- 'form' => [
134
- 'loading_tmpl' => esc_html__( 'Loading Template...', 'woo-feed' ),
135
- 'generate' => esc_html__( 'Delivering Configuration...', 'woo-feed' ),
136
- 'save' => esc_html__( 'Saving Configuration...', 'woo-feed' ),
137
- ],
138
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  wp_enqueue_script($this->woo_feed);
140
  }
141
  }
96
  * between the defined hooks and the functions defined in this
97
  * class.
98
  */
99
+ if ( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
100
+ wp_register_script( 'jquery-selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.min.js', array( 'jquery' ), $this->version, false );
101
+ wp_register_script( 'jquery-validate', plugin_dir_url( __FILE__ ) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version, false );
102
+ wp_register_script( 'jquery-validate-additional-methods', plugin_dir_url( __FILE__ ) . 'js/additional-methods.min.js', array( 'jquery', 'jquery-validate' ), $this->version, false );
103
+ wp_register_script( 'jquery-sortable', plugin_dir_url( __FILE__ ) . 'js/jquery-sortable.js', array( 'jquery' ), $this->version, false );
104
 
105
+ wp_register_script( 'jquery-slick', plugin_dir_url( __FILE__ ) . 'js/slick.js', array( 'jquery' ), $this->version, false );
106
+ wp_register_script( 'feed-pro', plugin_dir_url( __FILE__ ) . 'js/pro.js', array( 'jquery', 'jquery-slick' ), $this->version, false );
107
 
108
+ if ( ! wp_script_is( 'clipboard', 'registered' ) ) {
109
+ wp_register_script( 'clipboard', plugin_dir_url( __FILE__ ) . 'js/clipboard.min.js', [], '2.0.4', false );
110
  }
111
 
112
  $feedScriptDependency = [
113
+ 'jquery',
114
+ 'clipboard',
115
+ 'jquery-selectize',
116
+ 'jquery-sortable',
117
+ 'jquery-validate',
118
+ 'jquery-validate-additional-methods',
119
  'wp-util',
120
  'utils',
121
  'wp-lists',
122
  'postbox',
123
  'tags-box',
124
  // 'underscore', 'word-count', 'jquery-ui-autocomplete',
125
+ 'jquery-touch-punch',
126
  ];
127
+ if ( 'woo-feed_page_webappick-feed-pro-vs-free' === $hook ) {
128
  $feedScriptDependency[] = 'jquery-slick';
129
+ $feedScriptDependency[] = 'feed-pro';
130
  }
131
 
132
  wp_register_script($this->woo_feed, plugin_dir_url(__FILE__) . 'js/woo-feed-admin.js', $feedScriptDependency, $this->version, false);
133
+ wp_localize_script(
134
+ $this->woo_feed,
135
+ 'wpf_ajax_obj',
136
+ array(
137
+ 'wpf_ajax_url' => admin_url( 'admin-ajax.php' ),
138
+ 'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
139
+ 'is_feed_edit' => isset( $_GET['page'], $_GET['action'] ) && 'webappick-manage-feeds' == $_GET['page'] && 'edit-feed' == $_GET['action'], // phpcs:ignore WordPress.Security.NonceVerification.Recommended
140
+ 'is_feed_add' => isset( $_GET['page'] ) && 'webappick-new-feed' == $_GET['page'], // phpcs:ignore WordPress.Security.NonceVerification.Recommended
141
+ 'na' => esc_html__( 'N/A', 'woo-feed' ),
142
+ 'regenerate' => esc_html__( 'Generating...', 'woo-feed' ),
143
+ 'form' => array(
144
+ 'loading_tmpl' => esc_html__( 'Loading Template...', 'woo-feed' ),
145
+ 'generate' => esc_html__( 'Delivering Configuration...', 'woo-feed' ),
146
+ 'save' => esc_html__( 'Saving Configuration...', 'woo-feed' ),
147
+ 'sftp_checking' => esc_html__( 'Wait! Checking Extensions ...', 'woo-feed' ),
148
+ 'sftp_warning' => esc_html__( 'Warning! Enable PHP ssh2 extension to use SFTP. Contact your server administrator.',
149
+ 'woo-feed' ),
150
+ 'sftp_available' => esc_html__( 'SFTP Available!', 'woo-feed' ),
151
+ ),
152
+ 'ajax' => [
153
+ 'url' => admin_url( 'admin-ajax.php' ),
154
+ 'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
155
+ 'error' => esc_html__( 'There was an error processing ajax request.', 'woo-feed' ),
156
+ ],
157
+ )
158
+ );
159
  wp_enqueue_script($this->woo_feed);
160
  }
161
  }
admin/js/pro.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // noinspection JSUnresolvedVariable,ES6ConvertVarToLetConst,SpellCheckingInspection
2
+ (function ($, window, document) {
3
+ /* global ajaxurl, wpAjax, postboxes, pagenow, alert, deleteUserSetting, typenow, adminpage, thousandsSeparator, decimalPoint, isRtl */
4
+ $(window).load(function () {
5
+ // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
6
+ var sliders = $('.wapk-slider');
7
+ if( sliders.length ) {
8
+ sliders.slick({
9
+ autoplay: true,
10
+ dots: true,
11
+ centerMode: true,
12
+ arrows: false,
13
+ slidesToShow: 1,
14
+ slidesToScroll: 1,
15
+ lazyLoad: 'progressive'
16
+ });
17
+ }
18
+ } );
19
+ }( jQuery, window, document ) );
admin/js/woo-feed-admin.js CHANGED
@@ -1,5 +1,5 @@
1
  // noinspection JSUnresolvedVariable,ES6ConvertVarToLetConst,SpellCheckingInspection
2
- ( function ($, window, document, wpAjax, opts) {
3
  "use strict";
4
  /**
5
  * All of the code for your admin-facing JavaScript source
@@ -14,7 +14,7 @@
14
 
15
  /**
16
  * disable element utility
17
- * @since 3.1.32
18
  */
19
  $.fn.disabled = function( status ) {
20
  $(this).each( function(){
@@ -23,7 +23,7 @@
23
  if( typeof( self.prop( prop ) ) !== 'undefined' ) {
24
  self.prop( prop, status === void 0 || status === true );
25
  } else {
26
- !0===status?self.addClass( prop ):self.removeClass( prop );
27
  }
28
  } );
29
  return self; // method chaining
@@ -31,7 +31,7 @@
31
  $.fn.isDisabled = function() {
32
  // noinspection ES6ConvertVarToLetConst
33
  var self = $(this), prop = 'disabled';
34
- return ( typeof( self.prop( prop ) ) !== 'undefined' )? self.prop( prop ) : self.hasClass( prop );
35
  };
36
 
37
  function clearTooltip( event ) {
@@ -59,9 +59,173 @@
59
  return actionMsg;
60
  }
61
 
 
62
  $(window).load(function () {
63
- // noinspection ES6ConvertVarToLetConst
64
- var $copyBtn = $('.toClipboard'), clipboard, sliders = $('.wapk-slider');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  $('[data-toggle_slide]').on('click', function(e) {
66
  e.preventDefault();
67
  $($(this).data('toggle_slide')).slideToggle('fast');
@@ -77,20 +241,8 @@
77
  clipboard.on( 'error', function( event ) { showTooltip( event.trigger, fallbackMessage( event.action ) ) } )
78
  .on( 'success', function( event ) { showTooltip( event.trigger, 'Copied!' ) } );
79
  }
80
- if( sliders.length ) {
81
- sliders.slick({
82
- autoplay: true,
83
- dots: true,
84
- centerMode: true,
85
- arrows: false,
86
- slidesToShow: 1,
87
- slidesToScroll: 1,
88
- lazyLoad: 'progressive'
89
- });
90
- }
91
- });
92
-
93
- $(function () {
94
  // Template loading ui conflict
95
  if( $(location). attr("href").match( /webappick.*feed/g ) != null ) {
96
  $('#wpbody-content').addClass('woofeed-body-content');
@@ -106,9 +258,10 @@
106
  });
107
 
108
  // XML Feed Wrapper
109
- $(document).on('change', '#feedType', function () {
110
  // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
111
- var type = $(this).val(), provider = $("#provider").val(), itemWrapper = $(".itemWrapper"), wf_csvtxt = $(".wf_csvtxt");
 
112
  if ( type === 'xml' ) {
113
  itemWrapper.show(); wf_csvtxt.hide();
114
  } else if ( type === 'csv' || type === 'txt' ) {
@@ -122,7 +275,7 @@
122
  itemWrapper.find('input[name="itemsWrapper"]').val("channel");
123
  itemWrapper.find('input[name="itemWrapper"]').val("item");
124
  }
125
- });
126
  // Tooltip only Text
127
  {
128
  // noinspection SpellCheckingInspection
@@ -149,17 +302,9 @@
149
  });
150
  }
151
 
152
- // Dynamic Attribute Add New Condition
153
- $(document).on('click', '#wf_newCon', function () {
154
- $("#table-1 tbody tr:first").show().clone().find('input').val('').end().insertAfter("#table-1 tbody tr:last");
155
- // noinspection SpellCheckingInspection
156
- $(".fsrow:gt(5)").prop('disabled', false);
157
- $(".daRow:eq(0)").hide();
158
- });
159
-
160
- // Add New Condition for Filter @TODO may be deleted... not in use
161
  $(document).on('click', '#wf_newFilter', function () {
162
- $("#table-filter tbody tr:eq(0)").show().clone().find('input').val('').end().find('select').val('').end().insertAfter("#table-filter tbody tr:last");
163
  // noinspection SpellCheckingInspection
164
  $(".fsrow:gt(2)").prop('disabled', false);
165
  $(".daRow:eq(0)").hide();
@@ -220,7 +365,7 @@
220
  $(this).validate();
221
  if ($(this).valid()) {
222
  // noinspection SpellCheckingInspection
223
- $(".makeFeedResponse").show().html( '<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> '+opts.form.generate+'</b>' );
224
  }
225
  });
226
 
@@ -234,158 +379,12 @@
234
  $(document).on('submit', '#updatefeed', function ( e, data ) {
235
  // Feed Generating form validation
236
  $(this).validate();
237
- if ($(this).valid()) {
238
  // noinspection SpellCheckingInspection
239
- $(".makeFeedResponse").show().html( '<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> '+ ( data && data.save ? opts.form.save : opts.form.generate ) +'</b>' );
240
  }
241
  });
242
 
243
- // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
244
- var googleCategories,
245
- helper = {
246
- in_array: function( needle, haystack ) {
247
- try {
248
- return haystack.indexOf( needle ) !== -1;
249
- } catch( e ) {
250
- return false;
251
- }
252
- },
253
- selectize_render_item: function( data, escape ) {
254
- return '<div class="item wapk-selectize-item">' + escape(data.text) + '</div>';
255
- },
256
- ajax_fail: function ( e ) {
257
- console.log( e );
258
- alert( ( e.hasOwnProperty( 'statusText' ) && e.hasOwnProperty( 'status' ) ) ? e.statusText + ' (' + e.status + ')' : e );
259
- }
260
- }, // helper functions
261
- feedEditor = {
262
- init: function() {
263
- // Initialize Table Sorting
264
- // noinspection SpellCheckingInspection,JSUnresolvedFunction
265
- $('.sorted_table').sortablesd({
266
- containerSelector: 'table',
267
- itemPath: '> tbody',
268
- itemSelector: 'tr',
269
- handle: 'i.wf_sortedtable',
270
- placeholder: '<tr class="placeholder"><td colspan="100"></td></tr>',
271
- });
272
- $('.selectize').each(function(){
273
- // noinspection ES6ConvertVarToLetConst
274
- var self = $(this), plugins = self.data('plugins');
275
- self.selectize({
276
- plugins: plugins ? plugins.split(',') : [],//['remove_button'],
277
- render: { item: helper.selectize_render_item, }
278
- })
279
- });
280
- // Attribute type selection
281
- $(document).on('change', '.attr_type', function () {
282
- // noinspection ES6ConvertVarToLetConst
283
- var type = $(this).val(), row = $(this).closest('tr');
284
- row.find('.wf_attr').prop('required',false);
285
- row.find('.wf_default').prop('required',false);
286
- if (type === 'pattern') {
287
- row.find('.wf_attr').hide();
288
- row.find('.wf_attr').val('');
289
- row.find('.wf_default').show();
290
- } else {
291
- row.find('.wf_attr').show();
292
- row.find('.wf_default').hide();
293
- row.find('.wf_default').val('');
294
- }
295
- });
296
- $(document).on( 'change', '.wf_mattributes, .attr_type', function( e ) {
297
- // noinspection ES6ConvertVarToLetConst
298
- var row = $(this).closest( 'tr' ), attribute = row.find( '.wf_mattributes' ), type = row.find('.attr_type'), valueColumn = row.find('td:eq(4)');
299
- if( attribute.val() === 'current_category' && type.val() === 'pattern' && helper.in_array( $('#provider').val(), [ 'google', 'facebook', 'pinterest' ] ) ) {
300
- if( valueColumn.find('select.selectize').length === 0 ) {
301
- // noinspection ES6ConvertVarToLetConst
302
- var selectizeOpts = {
303
- options: googleCategories,
304
- config: { render: { item: helper.selectize_render_item, } },
305
- };
306
- valueColumn.find('input.wf_default').remove();
307
- valueColumn.append('<span class="wf_default wf_attributes"><select name="default[]" class="selectize"></select></span>');
308
- valueColumn.find('.wf_attributes select').selectize({render: {item: helper.selectize_render_item,}});
309
- valueColumn.append('<span style="font-size:x-small;"><a style="color: red" href="http://webappick.helpscoutdocs.com/article/19-how-to-map-store-category-with-merchant-category" target="_blank">Learn More..</a></span>');
310
- valueColumn.append('<span class="spinner is-active" style="margin: 0;"></span>');
311
- var select = valueColumn.find('.wf_attributes select');
312
- if( ! googleCategories ) {
313
- wpAjax.send( 'get_google_categories', {
314
- type: 'GET',
315
- data: { _ajax_nonce: opts.nonce, action: "get_google_categories", provider: $('#provider').val() }
316
- } ).then( function( r ) {
317
- googleCategories = r;
318
- selectizeOpts.options = r;
319
- feedEditor.renderSelectize( select, selectizeOpts );
320
- valueColumn.find('.spinner').remove();
321
- } ).fail( helper.ajax_fail );
322
- } else {
323
- feedEditor.renderSelectize( select, selectizeOpts );
324
- valueColumn.find('.spinner').remove();
325
- }
326
- }
327
- } else {
328
- if( attribute.val() !== 'current_category' && valueColumn.find('input.wf_default').length === 0 ) {
329
- valueColumn.find('span').remove();
330
- valueColumn.append( '<input autocomplete="off" class="wf_default wf_attributes" type="text" name="default[]" value="">' );
331
- if( type.val() !== 'pattern' ) {
332
- valueColumn.find('input.wf_default').hide();
333
- }
334
- }
335
- }
336
- } );
337
- },
338
- renderSelectize: function( el, config ) {
339
-
340
- var c = $.extend({}, {
341
- options: {},
342
- settings: {render: {item: helper.selectize_render_item,}}
343
- }, config);
344
- el.selectize(c.settings);
345
- var s = el[0].selectize;
346
- s.clearOptions();
347
- if( Object.keys(c.options).length ) {
348
- for( var i in c.options ) {
349
- s.addOption( c.options[i] );
350
- }
351
- }
352
- s.refreshOptions();
353
- return el;
354
- },
355
- renderMerchantInfo: function( merchantInfo, feedType, r ) {
356
- // noinspection ES6ConvertVarToLetConst
357
- for( var k in r ) {
358
- if( r.hasOwnProperty( k ) ) {
359
- merchantInfo.find( '.merchant-info-section.' + k + ' .data' ).html( r[k] );
360
- if( k === 'feed_file_type' ) {
361
- // noinspection ES6ConvertVarToLetConst,JSUnresolvedVariable
362
- var types = r[k].split(",").map(function(t){return t.trim().toLowerCase()}).filter(function(t){return t!==''&&t!==opts.na.toLowerCase()});
363
- if( types.length ) {
364
- feedType.find('option').removeAttr('selected').each( function(){
365
- // noinspection ES6ConvertVarToLetConst
366
- var opt = $(this);
367
- opt.val()&&!helper.in_array(opt.val(),types)?opt.disabled(!0):opt.disabled(!1);
368
- } );
369
- if( types.length===1 ) feedType.find('option[value="'+types[0]+'"]').attr( 'selected', 'selected' );
370
- } else feedType.find('option').disabled( !1 );
371
- }
372
- }
373
- }
374
- merchantInfo.find( '.spinner' ).removeClass( 'is-active' );
375
- feedType.disabled( !1 );
376
- feedType.trigger('change');
377
- feedType.parent().find('.spinner').removeClass( 'is-active' );
378
- },
379
- renderMerchantTemplate: function( feedForm, r ) {
380
- // insert server response
381
- feedForm.html( r );
382
- feedEditor.init();
383
- }
384
- }, // Feed Editor Table
385
- merchantInfoCache = [],
386
- merchantTemplateCache = [];
387
- // initialize editor
388
- feedEditor.init();
389
  // Get Merchant View
390
  $("#provider").on('change', function ( event ) {
391
  event.preventDefault();
@@ -396,9 +395,10 @@
396
  feedForm = $("#providerPage"),
397
  merchantInfo = $('#feed_merchant_info');
398
  // set loading..
399
- feedForm.html('<h3><span style="float:none;margin: -3px 0 0;" class="spinner is-active"></span> '+opts.form.loading_tmpl+'</h3>');
 
400
  merchantInfo.find( '.spinner' ).addClass( 'is-active' );
401
- feedType.disabled( !0 ); // disable dropdown
402
  feedType.parent().find('.spinner').addClass( 'is-active' );
403
  merchantInfo.find( '.merchant-info-section .data' ).html(''); // remove previous data
404
  // Get Merchant info for selected Provider/Merchant
@@ -413,6 +413,7 @@
413
  feedEditor.renderMerchantInfo( merchantInfo, feedType, r );
414
  } ).fail( helper.ajax_fail );
415
  }
 
416
  // Get FeedForm For Selected Provider/Merchant
417
  if( merchantTemplateCache.hasOwnProperty( merchant ) ) {
418
  feedEditor.renderMerchantTemplate( feedForm, merchantTemplateCache[merchant] );
@@ -441,43 +442,39 @@
441
  if (window.getSelection) {window.getSelection().removeAllRanges();}
442
  else if (document.selection) {document.selection.empty();}
443
  });
444
- });
445
 
446
- //Checking whether php ssh2 extension is added or not
447
- // noinspection SpellCheckingInspection
448
- $(document).on('change', '.ftporsftp', function () {
449
- // noinspection ES6ConvertVarToLetConst
450
- var server = $(this).val(),
451
- ssh2Status = $('.ssh2_status');
452
- if (server === 'sftp') {
453
- ssh2Status.show();
454
- ssh2Status.css('color','dodgerblue');
455
- ssh2Status.text('Wait! Checking Extensions ...');
456
- // noinspection JSUnresolvedVariable
457
- $.ajax({
458
- url: opts.wpf_ajax_url,
459
- type: 'post',
460
- data: {
461
- _ajax_nonce: opts.nonce,
462
- action: "get_ssh2_status",
463
- server: server
464
- },
465
- success: function (response) {
466
- if (response.success) {
467
- if(response.data === 'exists') {
468
- ssh2Status.hide();
469
  } else {
470
- ssh2Status.show();
471
- ssh2Status.css('color','red');
472
- ssh2Status.text('Warning! Enable PHP ssh2 extension to use SFTP. Contact your server administrator.');
473
  }
474
- }
475
- }
476
- });
477
- }else{
478
- ssh2Status.hide();
479
- }
 
 
 
480
  });
 
481
  $(document).on('click', '.woo-feed-notice ul li a', function (e) {
482
  e.preventDefault();
483
  // noinspection ES6ConvertVarToLetConst
@@ -495,4 +492,4 @@
495
  var which = $(this).parent().data('which');
496
  which && wpAjax.post( 'woo_feed_hide_notice', { _wpnonce: opts.nonce, which: which, } );
497
  });
498
- }( jQuery, window, document, wp.ajax, wpf_ajax_obj ) );
1
  // noinspection JSUnresolvedVariable,ES6ConvertVarToLetConst,SpellCheckingInspection
2
+ (function ($, window, document, wpAjax, opts) {
3
  "use strict";
4
  /**
5
  * All of the code for your admin-facing JavaScript source
14
 
15
  /**
16
  * disable element utility
17
+ * @since 3.1.9
18
  */
19
  $.fn.disabled = function( status ) {
20
  $(this).each( function(){
23
  if( typeof( self.prop( prop ) ) !== 'undefined' ) {
24
  self.prop( prop, status === void 0 || status === true );
25
  } else {
26
+ ! 0 === status ? self.addClass( prop ) : self.removeClass( prop );
27
  }
28
  } );
29
  return self; // method chaining
31
  $.fn.isDisabled = function() {
32
  // noinspection ES6ConvertVarToLetConst
33
  var self = $(this), prop = 'disabled';
34
+ return ( typeof( self.prop( prop ) ) !== 'undefined' ) ? self.prop( prop ) : self.hasClass( prop );
35
  };
36
 
37
  function clearTooltip( event ) {
59
  return actionMsg;
60
  }
61
 
62
+ /* global ajaxurl, wpAjax, postboxes, pagenow, alert, deleteUserSetting, typenow, adminpage, thousandsSeparator, decimalPoint, isRtl */
63
  $(window).load(function () {
64
+ // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
65
+ var $copyBtn = $('.toClipboard'), clipboard,
66
+ googleCategories,
67
+ helper = {
68
+ in_array: function( needle, haystack ) {
69
+ try {
70
+ return haystack.indexOf( needle ) !== -1;
71
+ } catch( e ) {
72
+ return false;
73
+ }
74
+ },
75
+ selectize_render_item: function( data, escape ) {
76
+ return '<div class="item wapk-selectize-item">' + escape(data.text) + '</div>'; // phpcs:ignore WordPressVIPMinimum.JS.StringConcat.Found
77
+ },
78
+ ajax_fail: function ( e ) {
79
+ console.log( e );
80
+ alert( ( e.hasOwnProperty( 'statusText' ) && e.hasOwnProperty( 'status' ) ) ? opts.ajax.error + '\n' + e.statusText + ' (' + e.status + ')' : e );
81
+ }
82
+ }, // helper functions
83
+ feedEditor = {
84
+ init: function() {
85
+ // noinspection ES6ConvertVarToLetConst
86
+ var outOfStockVisibilityRow = $('.out-of-stock-visibility');
87
+ // Initialize Table Sorting
88
+ // noinspection SpellCheckingInspection,JSUnresolvedFunction
89
+ $('.sorted_table').sortablesd({
90
+ containerSelector: 'table',
91
+ itemPath: '> tbody',
92
+ itemSelector: 'tr',
93
+ handle: 'i.wf_sortedtable',
94
+ placeholder: '<tr class="placeholder"><td colspan="9"></td></tr>',
95
+ });
96
+ $('.selectize').each(function(){
97
+ // noinspection ES6ConvertVarToLetConst
98
+ var self = $(this), plugins = self.data('plugins');
99
+ self.selectize({
100
+ plugins: plugins ? plugins.split(',') : [],//['remove_button'],
101
+ render: { item: helper.selectize_render_item, }
102
+ })
103
+ });
104
+ $('[name="is_outOfStock"], [name="product_visibility"]').on( 'change', function(){
105
+ if( $('[name="is_outOfStock"]:checked').val() === 'n' && $('[name="product_visibility"]:checked').val() === '1' ) {
106
+ outOfStockVisibilityRow.show();
107
+ } else {
108
+ outOfStockVisibilityRow.hide();
109
+ }
110
+ } ).trigger( 'change' );
111
+ // Attribute type selection
112
+ $(document).on('change', '.attr_type', function () {
113
+ // noinspection ES6ConvertVarToLetConst
114
+ var type = $(this).val(), row = $(this).closest('tr');
115
+ if (type === 'pattern') {
116
+ row.find('.wf_attr').hide();
117
+ row.find('.wf_attr').val('');
118
+ row.find('.wf_default').show();
119
+ } else {
120
+ row.find('.wf_attr').show();
121
+ row.find('.wf_default').hide();
122
+ row.find('.wf_default').val('');
123
+ }
124
+ });
125
+ $(document).on( 'change', '.wf_mattributes, .attr_type', function() {
126
+ // noinspection ES6ConvertVarToLetConst
127
+ var row = $(this).closest( 'tr' ),
128
+ attribute = row.find( '.wf_mattributes' ),
129
+ type = row.find('.attr_type'),
130
+ valueColumn = row.find('td:eq(4)'),
131
+ provider = $('#provider').val();
132
+ if( attribute.val() === 'current_category' && type.val() === 'pattern' && helper.in_array( provider, [ 'google', 'facebook', 'pinterest' ] ) ) {
133
+ if( valueColumn.find('select.selectize').length === 0 ) {
134
+ // noinspection ES6ConvertVarToLetConst
135
+ var selectizeOpts = {
136
+ options: googleCategories,
137
+ config: { render: { item: helper.selectize_render_item, } },
138
+ },
139
+ select = valueColumn.find('.wf_attributes select');
140
+ valueColumn.find('input.wf_default').remove();
141
+ valueColumn.append('<span class="wf_default wf_attributes"><select name="default[]" class="selectize"></select></span>');
142
+ valueColumn.find('.wf_attributes select').selectize({render: {item: helper.selectize_render_item,}});
143
+ valueColumn.append('<span style="font-size:x-small;"><a style="color: red" href="http://webappick.helpscoutdocs.com/article/19-how-to-map-store-category-with-merchant-category" target="_blank">Learn More..</a></span>');
144
+ valueColumn.append('<span class="spinner is-active" style="margin: 0;"></span>');
145
+ if( ! googleCategories ) {
146
+ wpAjax.send( 'get_google_categories', {
147
+ type: 'GET',
148
+ data: { _ajax_nonce: opts.nonce, action: "get_google_categories", provider: provider }
149
+ } ).then( function( r ) {
150
+ googleCategories = r;
151
+ selectizeOpts.options = r;
152
+ feedEditor.renderSelectize( select, selectizeOpts );
153
+ valueColumn.find('.spinner').remove();
154
+ } ).fail( helper.ajax_fail );
155
+ } else {
156
+ feedEditor.renderSelectize( select, selectizeOpts );
157
+ valueColumn.find('.spinner').remove();
158
+ }
159
+ }
160
+ } else {
161
+ if( attribute.val() !== 'current_category' && valueColumn.find('input.wf_default').length === 0 ) {
162
+ valueColumn.find('span').remove();
163
+ valueColumn.append( '<input autocomplete="off" class="wf_default wf_attributes" type="text" name="default[]" value="">' );
164
+ if( type.val() !== 'pattern' ) {
165
+ valueColumn.find('input.wf_default').hide();
166
+ }
167
+ }
168
+ }
169
+ } );
170
+ },
171
+ renderSelectize: function( el, config ) {
172
+ // noinspection ES6ConvertVarToLetConst
173
+ var c = $.extend({}, {
174
+ options: {},
175
+ settings: {render: {item: helper.selectize_render_item,}}
176
+ }, config);
177
+ el.selectize(c.settings);
178
+ // noinspection ES6ConvertVarToLetConst
179
+ var s = el[0].selectize;
180
+ s.clearOptions();
181
+ if( Object.keys(c.options).length ) {
182
+ // noinspection ES6ConvertVarToLetConst
183
+ for( var i in c.options ) {
184
+ if( c.options.hasOwnProperty( i ) ) {
185
+ s.addOption( c.options[i] );
186
+ }
187
+ }
188
+ }
189
+ s.refreshOptions( true );
190
+ return el;
191
+ },
192
+ renderMerchantInfo: function( merchantInfo, feedType, r ) {
193
+ // noinspection ES6ConvertVarToLetConst
194
+ for( var k in r ) {
195
+ if( r.hasOwnProperty( k ) ) {
196
+ merchantInfo.find( '.merchant-info-section.' + k + ' .data' ).html( r[k] ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
197
+ if( k === 'feed_file_type' ) {
198
+ // noinspection ES6ConvertVarToLetConst,JSUnresolvedVariable
199
+ var types = r[k].split(",").map(function(t){return t.trim().toLowerCase()}).filter(function(t){
200
+ // noinspection JSUnresolvedVariable
201
+ return t !== '' && t !== opts.na.toLowerCase()
202
+ });
203
+ if( types.length ) {
204
+ feedType.find('option').removeAttr('selected').each( function(){
205
+ // noinspection ES6ConvertVarToLetConst
206
+ var opt = $(this);
207
+ opt.val() && ! helper.in_array(opt.val(),types) ? opt.disabled( ! 0) : opt.disabled( ! 1);
208
+ } );
209
+ if( types.length === 1 ) feedType.find('option[value="' + types[0] + '"]').attr( 'selected', 'selected' );
210
+ } else feedType.find('option').disabled( ! 1 );
211
+ }
212
+ }
213
+ }
214
+ merchantInfo.find( '.spinner' ).removeClass( 'is-active' );
215
+ feedType.disabled( ! 1 );
216
+ feedType.trigger('change');
217
+ feedType.parent().find('.spinner').removeClass( 'is-active' );
218
+ },
219
+ renderMerchantTemplate: function( feedForm, r ) {
220
+ // insert server response
221
+ feedForm.html( r ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
222
+ feedEditor.init();
223
+ }
224
+ }, // Feed Editor Table
225
+ merchantInfoCache = [],
226
+ merchantTemplateCache = [];
227
+
228
+
229
  $('[data-toggle_slide]').on('click', function(e) {
230
  e.preventDefault();
231
  $($(this).data('toggle_slide')).slideToggle('fast');
241
  clipboard.on( 'error', function( event ) { showTooltip( event.trigger, fallbackMessage( event.action ) ) } )
242
  .on( 'success', function( event ) { showTooltip( event.trigger, 'Copied!' ) } );
243
  }
244
+ // initialize editor
245
+ feedEditor.init();
 
 
 
 
 
 
 
 
 
 
 
 
246
  // Template loading ui conflict
247
  if( $(location). attr("href").match( /webappick.*feed/g ) != null ) {
248
  $('#wpbody-content').addClass('woofeed-body-content');
258
  });
259
 
260
  // XML Feed Wrapper
261
+ $('#feedType,#provider').on('change', function () {
262
  // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
263
+ var type = $('#feedType').val(), provider = $('#provider').val(), itemWrapper = $('.itemWrapper'), wf_csvtxt = $('.wf_csvtxt');
264
+ // noinspection JSUnresolvedVariable
265
  if ( type === 'xml' ) {
266
  itemWrapper.show(); wf_csvtxt.hide();
267
  } else if ( type === 'csv' || type === 'txt' ) {
275
  itemWrapper.find('input[name="itemsWrapper"]').val("channel");
276
  itemWrapper.find('input[name="itemWrapper"]').val("item");
277
  }
278
+ }).trigger( 'change' );
279
  // Tooltip only Text
280
  {
281
  // noinspection SpellCheckingInspection
302
  });
303
  }
304
 
305
+ // Add New Condition for Filter
 
 
 
 
 
 
 
 
306
  $(document).on('click', '#wf_newFilter', function () {
307
+ $("#table-advanced-filter tbody tr:eq(0)").show().clone().find('input').val('').end().find('select').val('').end().insertAfter("#table-advanced-filter tbody tr:last");
308
  // noinspection SpellCheckingInspection
309
  $(".fsrow:gt(2)").prop('disabled', false);
310
  $(".daRow:eq(0)").hide();
365
  $(this).validate();
366
  if ($(this).valid()) {
367
  // noinspection SpellCheckingInspection
368
+ $(".makeFeedResponse").show().html( '<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> ' + opts.form.generate + '</b>' ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html, WordPressVIPMinimum.JS.StringConcat.Found
369
  }
370
  });
371
 
379
  $(document).on('submit', '#updatefeed', function ( e, data ) {
380
  // Feed Generating form validation
381
  $(this).validate();
382
+ if ( $(this).valid() ) {
383
  // noinspection SpellCheckingInspection
384
+ $(".makeFeedResponse").show().html( '<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> ' + ( data && data.save ? opts.form.save : opts.form.generate ) + '</b>' ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html, WordPressVIPMinimum.JS.StringConcat.Found
385
  }
386
  });
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  // Get Merchant View
389
  $("#provider").on('change', function ( event ) {
390
  event.preventDefault();
395
  feedForm = $("#providerPage"),
396
  merchantInfo = $('#feed_merchant_info');
397
  // set loading..
398
+ // noinspection JSUnresolvedVariable
399
+ feedForm.html('<h3><span style="float:none;margin: -3px 0 0;" class="spinner is-active"></span> ' + opts.form.loading_tmpl + '</h3>'); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html, WordPressVIPMinimum.JS.StringConcat.Found
400
  merchantInfo.find( '.spinner' ).addClass( 'is-active' );
401
+ feedType.disabled( ! 0 ); // disable dropdown
402
  feedType.parent().find('.spinner').addClass( 'is-active' );
403
  merchantInfo.find( '.merchant-info-section .data' ).html(''); // remove previous data
404
  // Get Merchant info for selected Provider/Merchant
413
  feedEditor.renderMerchantInfo( merchantInfo, feedType, r );
414
  } ).fail( helper.ajax_fail );
415
  }
416
+
417
  // Get FeedForm For Selected Provider/Merchant
418
  if( merchantTemplateCache.hasOwnProperty( merchant ) ) {
419
  feedEditor.renderMerchantTemplate( feedForm, merchantTemplateCache[merchant] );
442
  if (window.getSelection) {window.getSelection().removeAllRanges();}
443
  else if (document.selection) {document.selection.empty();}
444
  });
 
445
 
446
+ //Checking whether php ssh2 extension is added or not
447
+ // noinspection SpellCheckingInspection
448
+ $(document).on('change', '.ftporsftp', function () {
449
+ // noinspection ES6ConvertVarToLetConst
450
+ var server = $(this).val(), status = $('.ssh2_status');
451
+ if (server === 'sftp') {
452
+ // noinspection JSUnresolvedVariable
453
+ status.show().css('color', 'dodgerblue').text(opts.form.sftp_checking);
454
+ // noinspection JSUnresolvedVariable
455
+ wpAjax.post('get_ssh2_status', {_ajax_nonce: opts.nonce, server: server})
456
+ .then(function (response) {
457
+ if ( response === 'exists' ) {
458
+ // noinspection JSUnresolvedVariable
459
+ status.css('color', '#2CC185').text(opts.form.sftp_available);
460
+ setTimeout( function () {
461
+ status.hide();
462
+ }, 1500 );
 
 
 
 
 
 
463
  } else {
464
+ // noinspection JSUnresolvedVariable
465
+ status.show().css('color', 'red').text(opts.form.sftp_warning);
 
466
  }
467
+ })
468
+ .fail( function( e ) {
469
+ status.hide();
470
+ helper.ajax_fail( e );
471
+ } );
472
+ } else {
473
+ status.hide();
474
+ }
475
+ });
476
  });
477
+
478
  $(document).on('click', '.woo-feed-notice ul li a', function (e) {
479
  e.preventDefault();
480
  // noinspection ES6ConvertVarToLetConst
492
  var which = $(this).parent().data('which');
493
  which && wpAjax.post( 'woo_feed_hide_notice', { _wpnonce: opts.nonce, which: which, } );
494
  });
495
+ }( jQuery, window, document, wp.ajax, wpf_ajax_obj ));
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -1619,22 +1619,24 @@ class Woo_Feed_Products_v3 {
1619
  * Get Product Regular Price with Tax
1620
  * @since 3.2.0
1621
  *
1622
- * @param WC_Product $product
1623
  *
1624
  * @return mixed
1625
  */
1626
  private function price_with_tax( $product ) {
1627
  $price = $this->price( $product );
1628
- # Set variable product regular price according to setting
1629
  if ( $product->is_type( 'variable' ) ) {
1630
  $price = $this->getVariableProductPrice( $product, 'regular_price' );
1631
- } else if ( $product->is_type( 'grouped' ) ) {
1632
  return $this->getGroupProductPrice( $product, 'regular', true );
 
 
1633
  }
1634
 
1635
- # Get price with tax
1636
  if ( $product->is_taxable() && ! empty( $price ) ) {
1637
- $price = $this->getPriceWithTax( $product, $price, 'woo_feed_price_with_tax' );
1638
  }
1639
 
1640
  return $price;
@@ -1644,22 +1646,24 @@ class Woo_Feed_Products_v3 {
1644
  * Get Product Regular Price with Tax
1645
  * @since 3.2.0
1646
  *
1647
- * @param WC_Product $product
1648
  *
1649
  * @return mixed
1650
  */
1651
  private function current_price_with_tax( $product ) {
1652
  $price = $this->current_price( $product );
1653
- # Set variable product regular price according to setting
1654
  if ( $product->is_type( 'variable' ) ) {
1655
  $price = $this->getVariableProductPrice( $product, 'current_price' );
1656
- } else if ( $product->is_type( 'grouped' ) ) {
1657
  return $this->getGroupProductPrice( $product, 'current', true );
 
 
1658
  }
1659
 
1660
- # Get price with tax
1661
  if ( $product->is_taxable() && ! empty( $price ) ) {
1662
- $price = $this->getPriceWithTax( $product, $price, 'woo_feed_current_price_with_tax' );
1663
  }
1664
 
1665
  return $price;
@@ -1669,23 +1673,25 @@ class Woo_Feed_Products_v3 {
1669
  * Get Product Regular Price with Tax
1670
  * @since 3.2.0
1671
  *
1672
- * @param WC_Product $product
1673
  *
1674
  * @return mixed
1675
  */
1676
  private function sale_price_with_tax( $product ) {
1677
  $price = $this->sale_price( $product );
1678
 
1679
- # Set variable product regular price according to setting
1680
  if ( $product->is_type( 'variable' ) ) {
1681
  $price = $this->getVariableProductPrice( $product, 'sale_price' );
1682
- } else if ( $product->is_type( 'grouped' ) ) {
1683
  return $this->getGroupProductPrice( $product, 'sale', true );
 
 
1684
  }
1685
 
1686
- # Get price with tax
1687
  if ( $product->is_taxable() && ! empty( $price ) ) {
1688
- $price = $this->getPriceWithTax( $product, $price, 'woo_feed_sale_price_with_tax' );
1689
  }
1690
 
1691
  return $price;
@@ -1761,32 +1767,22 @@ class Woo_Feed_Products_v3 {
1761
  return $variable->get_variation_price();
1762
  }
1763
  }
1764
-
1765
- /** Return product price with tax
 
1766
  * @since 3.2.0
1767
  *
1768
- * @param object $product
1769
- * @param float $price
1770
- * @param string $meta Meta Names (woo_feed_price_with_tax,woo_feed_current_price_with_tax and woo_feed_sale_price_with_tax)
1771
  *
1772
  * @return float|string
1773
  */
1774
- public function getPriceWithTax( $product, $price, $meta ) {
1775
  if ( woo_feed_wc_version_check( 3.0 ) ) {
1776
- $priceWithTax = wc_get_price_including_tax( $product, array( 'price' => $price ) );
1777
  } else {
1778
- $priceWithTax = $product->get_price_including_tax();
1779
  }
1780
-
1781
- if ( $price != $priceWithTax && empty( $product->get_meta( $meta ) ) ) {
1782
- update_post_meta( $product->get_id(), $meta, $priceWithTax );
1783
- } else if ( $price != $priceWithTax && $product->get_meta( $meta ) != $priceWithTax ) {
1784
- update_post_meta( $product->get_id(), $meta, $priceWithTax );
1785
- } else if ( $priceWithTax == $price && ! empty( $product->get_meta( $meta ) ) ) {
1786
- return $product->get_meta( $meta );
1787
- }
1788
-
1789
- return $priceWithTax;
1790
  }
1791
 
1792
  /**
1619
  * Get Product Regular Price with Tax
1620
  * @since 3.2.0
1621
  *
1622
+ * @param WC_Product|WC_Product_Variable|WC_Product_Grouped|WC_Product_Composite $product Product Object.
1623
  *
1624
  * @return mixed
1625
  */
1626
  private function price_with_tax( $product ) {
1627
  $price = $this->price( $product );
1628
+ // Set variable product regular price according to setting.
1629
  if ( $product->is_type( 'variable' ) ) {
1630
  $price = $this->getVariableProductPrice( $product, 'regular_price' );
1631
+ } elseif ( $product->is_type( 'grouped' ) ) {
1632
  return $this->getGroupProductPrice( $product, 'regular', true );
1633
+ } elseif ( $product->is_type( 'composite' ) || $product->is_type( 'yith-composite' ) ) {
1634
+ return $this->getCompositeProductPrice( $product, 'regular_price' );
1635
  }
1636
 
1637
+ // Get price with tax.
1638
  if ( $product->is_taxable() && ! empty( $price ) ) {
1639
+ $price = $this->get_price_with_tax( $product, $price );
1640
  }
1641
 
1642
  return $price;
1646
  * Get Product Regular Price with Tax
1647
  * @since 3.2.0
1648
  *
1649
+ * @param WC_Product|WC_Product_Variable|WC_Product_Grouped|WC_Product_Composite $product
1650
  *
1651
  * @return mixed
1652
  */
1653
  private function current_price_with_tax( $product ) {
1654
  $price = $this->current_price( $product );
1655
+ // Set variable product regular price according to setting
1656
  if ( $product->is_type( 'variable' ) ) {
1657
  $price = $this->getVariableProductPrice( $product, 'current_price' );
1658
+ } elseif ( $product->is_type( 'grouped' ) ) {
1659
  return $this->getGroupProductPrice( $product, 'current', true );
1660
+ } elseif ( $product->is_type( 'composite' ) || $product->is_type( 'yith-composite' ) ) {
1661
+ return $this->getCompositeProductPrice( $product, 'current_price' );
1662
  }
1663
 
1664
+ // Get price with tax
1665
  if ( $product->is_taxable() && ! empty( $price ) ) {
1666
+ $price = $this->get_price_with_tax( $product, $price );
1667
  }
1668
 
1669
  return $price;
1673
  * Get Product Regular Price with Tax
1674
  * @since 3.2.0
1675
  *
1676
+ * @param WC_Product|WC_Product_Variable|WC_Product_Grouped|WC_Product_Composite $product
1677
  *
1678
  * @return mixed
1679
  */
1680
  private function sale_price_with_tax( $product ) {
1681
  $price = $this->sale_price( $product );
1682
 
1683
+ // Set variable product regular price according to setting
1684
  if ( $product->is_type( 'variable' ) ) {
1685
  $price = $this->getVariableProductPrice( $product, 'sale_price' );
1686
+ } elseif ( $product->is_type( 'grouped' ) ) {
1687
  return $this->getGroupProductPrice( $product, 'sale', true );
1688
+ } elseif ( $product->is_type( 'composite' ) || $product->is_type( 'yith-composite' ) ) {
1689
+ return $this->getCompositeProductPrice( $product, 'sale_price' );
1690
  }
1691
 
1692
+ // Get price with tax
1693
  if ( $product->is_taxable() && ! empty( $price ) ) {
1694
+ $price = $this->get_price_with_tax( $product, $price );
1695
  }
1696
 
1697
  return $price;
1767
  return $variable->get_variation_price();
1768
  }
1769
  }
1770
+
1771
+ /**
1772
+ * Return product price with tax
1773
  * @since 3.2.0
1774
  *
1775
+ * @param WC_Product $product Product.
1776
+ * @param float $price Price.
 
1777
  *
1778
  * @return float|string
1779
  */
1780
+ public function get_price_with_tax( $product, $price ) {
1781
  if ( woo_feed_wc_version_check( 3.0 ) ) {
1782
+ return wc_get_price_including_tax( $product, array( 'price' => $price ) );
1783
  } else {
1784
+ return $product->get_price_including_tax( 1, $price );
1785
  }
 
 
 
 
 
 
 
 
 
 
1786
  }
1787
 
1788
  /**
includes/helper.php CHANGED
@@ -1130,4 +1130,53 @@ if ( ! function_exists( 'woo_feed_log_feed_process' ) ) {
1130
  woo_feed_log( $feed_name, $message, 'debug', $data, $force_log, false );
1131
  }
1132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1133
  // End of file helper.php
1130
  woo_feed_log( $feed_name, $message, 'debug', $data, $force_log, false );
1131
  }
1132
  }
1133
+
1134
+ // Hooks on feed generating process...
1135
+ if ( ! function_exists( 'woo_feed_apply_hooks_before_product_loop' ) ) {
1136
+ add_action( 'woo_feed_before_product_loop', 'woo_feed_apply_hooks_before_product_loop', 10, 1 );
1137
+ /**
1138
+ * Apply Hooks Before Looping through ProductIds
1139
+ * @param array $feedConfig
1140
+ */
1141
+ function woo_feed_apply_hooks_before_product_loop( $feedConfig ) {
1142
+ // Tax will be the first things to taken care of
1143
+ add_filter( 'woocommerce_get_tax_location', 'woo_feed_apply_tax_location_data', 10, 3 );
1144
+ }
1145
+ }
1146
+ if ( ! function_exists( 'woo_feed_remove_hooks_before_product_loop' ) ) {
1147
+ add_action( 'woo_feed_after_product_loop', 'woo_feed_remove_hooks_before_product_loop', 10, 1 );
1148
+ /**
1149
+ * Remove Applied Hooks Looping through ProductIds
1150
+ * @see woo_feed_apply_hooks_before_product_loop
1151
+ * @param array $feedConfig the feed array.
1152
+ */
1153
+ function woo_feed_remove_hooks_before_product_loop( $feedConfig ) {
1154
+ remove_filter( 'woocommerce_get_tax_location', 'woo_feed_apply_tax_location_data', 10 );
1155
+ }
1156
+ }
1157
+
1158
+ // Price And Tax.
1159
+ if ( ! function_exists( 'woo_feed_apply_tax_location_data' ) ) {
1160
+ /**
1161
+ * Filter and Change Location data for tax calculation
1162
+ *
1163
+ * @param array $location Location array.
1164
+ * @param string $tax_class Tax class.
1165
+ * @param WC_Customer $customer WooCommerce Customer Object.
1166
+ *
1167
+ * @return array
1168
+ */
1169
+ function woo_feed_apply_tax_location_data( $location, $tax_class, $customer ) {
1170
+ // @TODO use filter. add tab in feed editor so user can set custom settings.
1171
+ // @TODO tab should not list all country and cities. it only list available tax settings and user can just select one.
1172
+ // @TODO then it will extract the location data from it to use here.
1173
+ // @TODO with extra input for static tax rate input from user, which will override all other tax setting for the feed.
1174
+ return [
1175
+ WC()->countries->get_base_country(),
1176
+ WC()->countries->get_base_state(),
1177
+ WC()->countries->get_base_postcode(),
1178
+ WC()->countries->get_base_city(),
1179
+ ];
1180
+ }
1181
+ }
1182
  // End of file helper.php
phpcs.xml CHANGED
@@ -5,8 +5,15 @@
5
  <file>.</file>
6
 
7
  <!-- Exclude paths -->
 
 
 
 
 
8
  <exclude-pattern>tests/cli/</exclude-pattern>
9
  <exclude-pattern>includes/wc-legacy-support.php</exclude-pattern>
 
 
10
  <exclude-pattern>*/node_modules/*</exclude-pattern>
11
  <exclude-pattern>*/vendor/*</exclude-pattern>
12
 
@@ -24,8 +31,18 @@
24
  <!-- <config name="testVersion" value="5.6-" />-->
25
 
26
  <!-- Rules -->
 
 
 
27
  <rule ref="WordPress">
28
  <exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
 
 
 
 
 
 
 
29
  </rule>
30
  <rule ref="WordPress-Core" />
31
  <rule ref="WordPress-Extra" />
@@ -39,6 +56,8 @@
39
 
40
  <rule ref="PHPCompatibility">
41
  <exclude-pattern>tests/</exclude-pattern>
 
 
42
  </rule>
43
 
44
  <rule ref="WordPress.Files.FileName.InvalidClassFileName">
@@ -47,6 +66,11 @@
47
  <exclude-pattern>src/*</exclude-pattern>
48
  </rule>
49
 
 
 
 
 
 
50
  <rule ref="Generic.Commenting">
51
  <exclude-pattern>tests/</exclude-pattern>
52
  </rule>
5
  <file>.</file>
6
 
7
  <!-- Exclude paths -->
8
+ <exclude-pattern>min.js</exclude-pattern>
9
+ <exclude-pattern>js/localization/</exclude-pattern>
10
+ <exclude-pattern>js/jquery-sortable.js</exclude-pattern>
11
+ <exclude-pattern>min.css</exclude-pattern>
12
+ <exclude-pattern>libs/WebAppick/</exclude-pattern>
13
  <exclude-pattern>tests/cli/</exclude-pattern>
14
  <exclude-pattern>includes/wc-legacy-support.php</exclude-pattern>
15
+ <exclude-pattern>includes/classes/class-woo-feed-engine.php</exclude-pattern>
16
+ <exclude-pattern>includes/classes/class-woo-feed-list-table.php</exclude-pattern>
17
  <exclude-pattern>*/node_modules/*</exclude-pattern>
18
  <exclude-pattern>*/vendor/*</exclude-pattern>
19
 
31
  <!-- <config name="testVersion" value="5.6-" />-->
32
 
33
  <!-- Rules -->
34
+ <rule ref="Squiz">
35
+ <exclude name="Squiz"/>
36
+ </rule>
37
  <rule ref="WordPress">
38
  <exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
39
+ <exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
40
+ <exclude name="WordPress.NamingConventions"/>
41
+ <!-- Temporary Exclusion-->
42
+ <exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize"/>
43
+ <exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize"/>
44
+ <exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/>
45
+ <exclude name="WordPress.DB.SlowDBQuery"/>
46
  </rule>
47
  <rule ref="WordPress-Core" />
48
  <rule ref="WordPress-Extra" />
56
 
57
  <rule ref="PHPCompatibility">
58
  <exclude-pattern>tests/</exclude-pattern>
59
+ <!-- Temporary Exclusion-->
60
+ <exclude name="PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore"/>
61
  </rule>
62
 
63
  <rule ref="WordPress.Files.FileName.InvalidClassFileName">
66
  <exclude-pattern>src/*</exclude-pattern>
67
  </rule>
68
 
69
+ <rule ref="PEAR">
70
+ <exclude-pattern>.</exclude-pattern>
71
+ <exclude name="PEAR.NamingConventions.ValidClassName.Invalid"/>
72
+ </rule>
73
+
74
  <rule ref="Generic.Commenting">
75
  <exclude-pattern>tests/</exclude-pattern>
76
  </rule>
woo-feed.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: WooCommerce Product Feed
16
  * Plugin URI: https://webappick.com/
17
  * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
18
- * Version: 3.2.16
19
  * Author: WebAppick
20
  * Author URI: https://webappick.com/
21
  * License: GPL v2
@@ -30,7 +30,7 @@
30
  *
31
  * WC Requirement & Test
32
  * WC requires at least: 3.2
33
- * WC tested up to: 3.9
34
  *
35
  */
36
  // Exit if accessed directly
@@ -41,7 +41,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
41
  * Plugin Version
42
  * @var string
43
  */
44
- define( 'WOO_FEED_FREE_VERSION', '3.2.16' );
45
  }
46
  if ( ! defined( 'WOO_FEED_FREE_FILE') ) {
47
  /**
15
  * Plugin Name: WooCommerce Product Feed
16
  * Plugin URI: https://webappick.com/
17
  * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
18
+ * Version: 3.2.17
19
  * Author: WebAppick
20
  * Author URI: https://webappick.com/
21
  * License: GPL v2
30
  *
31
  * WC Requirement & Test
32
  * WC requires at least: 3.2
33
+ * WC tested up to: 3.9.1
34
  *
35
  */
36
  // Exit if accessed directly
41
  * Plugin Version
42
  * @var string
43
  */
44
+ define( 'WOO_FEED_FREE_VERSION', '3.2.17' );
45
  }
46
  if ( ! defined( 'WOO_FEED_FREE_FILE') ) {
47
  /**