fix merge conflicts

This commit is contained in:
Ron Rennick 2020-05-06 14:05:00 -03:00
commit 0f2fb4f8d5
169 changed files with 745 additions and 317 deletions

View File

@ -1,26 +0,0 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"es3": true,
"expr": true,
"immed": true,
"noarg": true,
"onevar": true,
"quotmark": "single",
"trailing": true,
"undef": true,
"unused": true,
"multistr": true,
"browser": true,
"globals": {
"_": false,
"Backbone": false,
"jQuery": false,
"JSON": false,
"wp": false
}
}

View File

@ -1 +1 @@
FROM wordpress:5.4.0 FROM wordpress:5.4.1

View File

@ -1,4 +1,3 @@
/* jshint node:true */
module.exports = function( grunt ) { module.exports = function( grunt ) {
'use strict'; 'use strict';
var sass = require( 'node-sass' ); var sass = require( 'node-sass' );
@ -14,12 +13,9 @@ module.exports = function( grunt ) {
php: 'includes' php: 'includes'
}, },
// JavaScript linting with JSHint. // JavaScript linting with ESLint.
jshint: { eslint: {
options: { src: [
jshintrc: '.jshintrc'
},
all: [
'<%= dirs.js %>/admin/*.js', '<%= dirs.js %>/admin/*.js',
'!<%= dirs.js %>/admin/*.min.js', '!<%= dirs.js %>/admin/*.min.js',
'<%= dirs.js %>/frontend/*.js', '<%= dirs.js %>/frontend/*.js',
@ -192,12 +188,13 @@ module.exports = function( grunt ) {
}, },
js: { js: {
files: [ files: [
'GruntFile.js',
'<%= dirs.js %>/admin/*js', '<%= dirs.js %>/admin/*js',
'<%= dirs.js %>/frontend/*js', '<%= dirs.js %>/frontend/*js',
'!<%= dirs.js %>/admin/*.min.js', '!<%= dirs.js %>/admin/*.min.js',
'!<%= dirs.js %>/frontend/*.min.js' '!<%= dirs.js %>/frontend/*.min.js'
], ],
tasks: ['jshint', 'uglify'] tasks: ['eslint','uglify']
} }
}, },
@ -291,7 +288,7 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks( 'grunt-rtlcss' ); grunt.loadNpmTasks( 'grunt-rtlcss' );
grunt.loadNpmTasks( 'grunt-postcss' ); grunt.loadNpmTasks( 'grunt-postcss' );
grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' ); grunt.loadNpmTasks( 'gruntify-eslint' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' ); grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-concat' ); grunt.loadNpmTasks( 'grunt-contrib-concat' );
@ -307,7 +304,7 @@ module.exports = function( grunt ) {
]); ]);
grunt.registerTask( 'js', [ grunt.registerTask( 'js', [
'jshint', 'eslint',
'uglify:admin', 'uglify:admin',
'uglify:frontend' 'uglify:frontend'
]); ]);

View File

@ -142,7 +142,9 @@
$( '#key_permissions', self.el ).val( data.permissions ); $( '#key_permissions', self.el ).val( data.permissions );
} }
} else { } else {
$( 'h2, h3', self.el ).first().append( '<div class="wc-api-message error"><p>' + response.data.message + '</p></div>' ); $( 'h2, h3', self.el )
.first()
.append( '<div class="wc-api-message error"><p>' + response.data.message + '</p></div>' );
} }
self.unblock(); self.unblock();

View File

@ -130,7 +130,10 @@
var button = e.keyCode || e.which; var button = e.keyCode || e.which;
// Enter key // Enter key
if ( 13 === button && ! ( e.target.tagName && ( e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea' ) ) ) { if (
13 === button &&
! ( e.target.tagName && ( e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea' ) )
) {
this.addButton( e ); this.addButton( e );
} }

View File

@ -1,3 +1,4 @@
// eslint-disable-next-line max-len
/*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order, wcSetClipboard, wcClearClipboard */ /*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order, wcSetClipboard, wcClearClipboard */
jQuery( function ( $ ) { jQuery( function ( $ ) {
@ -11,7 +12,12 @@ jQuery( function ( $ ) {
var wc_meta_boxes_order = { var wc_meta_boxes_order = {
states: null, states: null,
init: function() { init: function() {
if ( ! ( typeof woocommerce_admin_meta_boxes_order === 'undefined' || typeof woocommerce_admin_meta_boxes_order.countries === 'undefined' ) ) { if (
! (
typeof woocommerce_admin_meta_boxes_order === 'undefined' ||
typeof woocommerce_admin_meta_boxes_order.countries === 'undefined'
)
) {
/* State/Country select boxes */ /* State/Country select boxes */
this.states = $.parseJSON( woocommerce_admin_meta_boxes_order.countries.replace( /&quot;/g, '"' ) ); this.states = $.parseJSON( woocommerce_admin_meta_boxes_order.countries.replace( /&quot;/g, '"' ) );
} }
@ -380,11 +386,19 @@ jQuery( function ( $ ) {
$( 'input.line_tax', $row ).each( function() { $( 'input.line_tax', $row ).each( function() {
var $line_total_tax = $( this ); var $line_total_tax = $( this );
var tax_id = $line_total_tax.data( 'tax_id' ); var tax_id = $line_total_tax.data( 'tax_id' );
var unit_total_tax = accounting.unformat( $line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point ) / o_qty; var unit_total_tax = accounting.unformat(
$line_total_tax.attr( 'data-total_tax' ),
woocommerce_admin.mon_decimal_point
) / o_qty;
var $line_subtotal_tax = $( 'input.line_subtotal_tax[data-tax_id="' + tax_id + '"]', $row ); var $line_subtotal_tax = $( 'input.line_subtotal_tax[data-tax_id="' + tax_id + '"]', $row );
var unit_subtotal_tax = accounting.unformat( $line_subtotal_tax.attr( 'data-subtotal_tax' ), woocommerce_admin.mon_decimal_point ) / o_qty; var unit_subtotal_tax = accounting.unformat(
$line_subtotal_tax.attr( 'data-subtotal_tax' ),
woocommerce_admin.mon_decimal_point
) / o_qty;
var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal; var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal;
var precision = woocommerce_admin_meta_boxes[ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals' ]; var precision = woocommerce_admin_meta_boxes[
round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals'
];
if ( 0 < unit_total_tax ) { if ( 0 < unit_total_tax ) {
$line_total_tax.val( $line_total_tax.val(
@ -877,7 +891,10 @@ jQuery( function ( $ ) {
$( '.refund input.refund_line_total' ).each(function( index, item ) { $( '.refund input.refund_line_total' ).each(function( index, item ) {
if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) { if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) {
line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point ); line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat(
item.value,
woocommerce_admin.mon_decimal_point
);
} }
}); });
@ -889,7 +906,10 @@ jQuery( function ( $ ) {
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = {}; line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = {};
} }
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point ); line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat(
item.value,
woocommerce_admin.mon_decimal_point
);
} }
}); });
@ -1018,11 +1038,16 @@ jQuery( function ( $ ) {
var $refund_line_total_tax = $( this ); var $refund_line_total_tax = $( this );
var tax_id = $refund_line_total_tax.data( 'tax_id' ); var tax_id = $refund_line_total_tax.data( 'tax_id' );
var line_total_tax = $( 'input.line_tax[data-tax_id="' + tax_id + '"]', $row ); var line_total_tax = $( 'input.line_tax[data-tax_id="' + tax_id + '"]', $row );
var unit_total_tax = accounting.unformat( line_total_tax.data( 'total_tax' ), woocommerce_admin.mon_decimal_point ) / qty; var unit_total_tax = accounting.unformat(
line_total_tax.data( 'total_tax' ),
woocommerce_admin.mon_decimal_point
) / qty;
if ( 0 < unit_total_tax ) { if ( 0 < unit_total_tax ) {
var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal; var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal;
var precision = woocommerce_admin_meta_boxes[ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals' ]; var precision = woocommerce_admin_meta_boxes[
round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals'
];
$refund_line_total_tax.val( $refund_line_total_tax.val(
parseFloat( accounting.formatNumber( unit_total_tax * refund_qty, precision, '' ) ) parseFloat( accounting.formatNumber( unit_total_tax * refund_qty, precision, '' ) )
@ -1059,8 +1084,17 @@ jQuery( function ( $ ) {
var index = $items.find('tr').length + 1; var index = $items.find('tr').length + 1;
var $row = '<tr data-meta_id="0">' + var $row = '<tr data-meta_id="0">' +
'<td>' + '<td>' +
'<input type="text" maxlength="255" placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_name + '" name="meta_key[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']" />' + '<input type="text" maxlength="255" placeholder="' +
'<textarea placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_value + '" name="meta_value[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']"></textarea>' + woocommerce_admin_meta_boxes_order.placeholder_name +
'" name="meta_key[' + $item.attr( 'data-order_item_id' ) +
'][new-' + index + ']" />' +
'<textarea placeholder="' +
woocommerce_admin_meta_boxes_order.placeholder_value +
'" name="meta_value[' +
$item.attr( 'data-order_item_id' ) +
'][new-' +
index +
']"></textarea>' +
'</td>' + '</td>' +
'<td width="1%"><button class="remove_order_item_meta button">&times;</button></td>' + '<td width="1%"><button class="remove_order_item_meta button">&times;</button></td>' +
'</tr>'; '</tr>';

View File

@ -476,7 +476,9 @@ jQuery( function( $ ) {
$( '.product_attributes .woocommerce_attribute' ).each( function( index, el ) { $( '.product_attributes .woocommerce_attribute' ).each( function( index, el ) {
if ( $( el ).css( 'display' ) !== 'none' && $( el ).is( '.taxonomy' ) ) { if ( $( el ).css( 'display' ) !== 'none' && $( el ).is( '.taxonomy' ) ) {
$( 'select.attribute_taxonomy' ).find( 'option[value="' + $( el ).data( 'taxonomy' ) + '"]' ).prop( 'disabled', true ); $( 'select.attribute_taxonomy' )
.find( 'option[value="' + $( el ).data( 'taxonomy' ) + '"]' )
.prop( 'disabled', true );
} }
}); });

View File

@ -38,17 +38,24 @@ jQuery( function( $ ) {
var nextpostid = ui.item.next().find( '.check-column input' ).val(); var nextpostid = ui.item.next().find( '.check-column input' ).val();
// Show Spinner // Show Spinner
ui.item.find( '.check-column input' ).hide().after( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' ); ui.item
.find( '.check-column input' )
.hide()
.after( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
// Go do the sorting stuff via ajax // Go do the sorting stuff via ajax
$.post( ajaxurl, { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function( response ) { $.post(
$.each( response, function( key, value ) { ajaxurl,
$( '#inline_' + key + ' .menu_order' ).html( value ); { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid },
}); function( response ) {
ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove(); $.each( response, function( key, value ) {
$( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' ); $( '#inline_' + key + ' .menu_order' ).html( value );
$( 'table.widefat tbody' ).sortable( 'enable' ); });
}); ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove();
$( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' );
$( 'table.widefat tbody' ).sortable( 'enable' );
}
);
// fix cell colors // fix cell colors
$( 'table.widefat tbody tr' ).each( function() { $( 'table.widefat tbody tr' ).each( function() {

View File

@ -45,6 +45,7 @@ jQuery(function( $ ) {
$( 'input[name="_stock"]', '.inline-edit-row' ).val( stock ); $( 'input[name="_stock"]', '.inline-edit-row' ).val( stock );
$( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order ); $( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order );
// eslint-disable-next-line max-len
$( 'select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option' ).removeAttr( 'selected' ); $( 'select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option' ).removeAttr( 'selected' );
$( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); $( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' );

View File

@ -222,7 +222,13 @@ jQuery(function( $ ) {
csv_data += '"' + index + '",'; csv_data += '"' + index + '",';
} else { } else {
if ( groupby === 'day' ) { if ( groupby === 'day' ) {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",'; csv_data += '"' +
date.getUTCFullYear() +
'-' +
parseInt( date.getUTCMonth() + 1, 10 ) +
'-' +
date.getUTCDate() +
'",';
} else { } else {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",'; csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
} }

View File

@ -165,7 +165,8 @@
minLength: 3 minLength: 3
}); });
// Postcode and city don't have `name` values by default. They're only created if the contents changes, to save on database queries (I think) // Postcode and city don't have `name` values by default.
// They're only created if the contents changes, to save on database queries (I think)
this.$el.find( 'td.postcode input, td.city input' ).change( function() { this.$el.find( 'td.postcode input, td.city input' ).change( function() {
$( this ).attr( 'name', $( this ).data( 'name' ) ); $( this ).attr( 'name', $( this ).data( 'name' ) );
}); });
@ -232,7 +233,9 @@
reordered_rates = _.map( rates_to_reorder, function( rate ) { reordered_rates = _.map( rates_to_reorder, function( rate ) {
rate.tax_rate_order++; rate.tax_rate_order++;
changes[ rate.tax_rate_id ] = _.extend( changes[ rate.tax_rate_id ] || {}, { tax_rate_order : rate.tax_rate_order } ); changes[ rate.tax_rate_id ] = _.extend(
changes[ rate.tax_rate_id ] || {}, { tax_rate_order : rate.tax_rate_order }
);
return rate; return rate;
} ); } );
} else { } else {

View File

@ -30,7 +30,13 @@ jQuery( function( $ ) {
}; };
$( document ).ajaxComplete( function( event, request, options ) { $( document ).ajaxComplete( function( event, request, options ) {
if ( request && 4 === request.readyState && 200 === request.status && options.data && ( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) ) ) { if (
request &&
4 === request.readyState &&
200 === request.status &&
options.data &&
( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) )
) {
$.wc_add_missing_sort_handles(); $.wc_add_missing_sort_handles();
$( document.body ).trigger( 'init_tooltips' ); $( document.body ).trigger( 'init_tooltips' );
} }
@ -80,25 +86,41 @@ jQuery( function( $ ) {
} }
} }
// If previous and next not at same tree level, or next not at same tree level and the previous is the parent of the next, or just moved item beneath its own children // If previous and next not at same tree level, or next not at same tree level and
if ( ( prevtermid === undefined && nexttermid === undefined ) || ( nexttermid === undefined && nexttermparent === prevtermid ) || ( nexttermid !== undefined && prevtermparent === termid ) ) { // the previous is the parent of the next, or just moved item beneath its own children.
if (
( prevtermid === undefined && nexttermid === undefined ) ||
( nexttermid === undefined && nexttermparent === prevtermid ) ||
( nexttermid !== undefined && prevtermparent === termid )
) {
$( table_selector ).sortable( 'cancel' ); $( table_selector ).sortable( 'cancel' );
return; return;
} }
// Show Spinner // Show Spinner
ui.item.find( '.check-column input' ).hide(); ui.item.find( '.check-column input' ).hide();
ui.item.find( '.check-column' ).append( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' ); ui.item
.find( '.check-column' )
.append( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
// Go do the sorting stuff via ajax // Go do the sorting stuff via ajax.
$.post( ajaxurl, { action: 'woocommerce_term_ordering', id: termid, nextid: nexttermid, thetaxonomy: woocommerce_term_ordering_params.taxonomy }, function(response){ $.post(
if ( response === 'children' ) { ajaxurl,
window.location.reload(); {
} else { action: 'woocommerce_term_ordering',
ui.item.find( '.check-column input' ).show(); id: termid,
ui.item.find( '.check-column' ).find( 'img' ).remove(); nextid: nexttermid,
thetaxonomy: woocommerce_term_ordering_params.taxonomy
},
function(response) {
if ( response === 'children' ) {
window.location.reload();
} else {
ui.item.find( '.check-column input' ).show();
ui.item.find( '.check-column' ).find( 'img' ).remove();
}
} }
}); );
// Fix cell colors // Fix cell colors
$( 'table.widefat tbody tr' ).each( function() { $( 'table.widefat tbody tr' ).each( function() {

View File

@ -58,7 +58,15 @@
$this.$form.find('.woocommerce-importer-progress').val( response.data.percentage ); $this.$form.find('.woocommerce-importer-progress').val( response.data.percentage );
if ( 'done' === response.data.position ) { if ( 'done' === response.data.position ) {
window.location = response.data.url + '&products-imported=' + parseInt( $this.imported, 10 ) + '&products-failed=' + parseInt( $this.failed, 10 ) + '&products-updated=' + parseInt( $this.updated, 10 ) + '&products-skipped=' + parseInt( $this.skipped, 10 ); window.location = response.data.url +
'&products-imported=' +
parseInt( $this.imported, 10 ) +
'&products-failed=' +
parseInt( $this.failed, 10 ) +
'&products-updated=' +
parseInt( $this.updated, 10 ) +
'&products-skipped=' +
parseInt( $this.skipped, 10 );
} else { } else {
$this.run_import(); $this.run_import();
} }

View File

@ -34,11 +34,16 @@
this.trigger( 'change:methods' ); this.trigger( 'change:methods' );
}, },
save: function() { save: function() {
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes', { $.post(
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce, ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes',
changes : this.changes, {
zone_id : data.zone_id wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
}, this.onSaveResponse, 'json' ); changes : this.changes,
zone_id : data.zone_id
},
this.onSaveResponse,
'json'
);
}, },
onSaveResponse: function( response, textStatus ) { onSaveResponse: function( response, textStatus ) {
if ( 'success' === textStatus ) { if ( 'success' === textStatus ) {
@ -46,7 +51,11 @@
if ( response.data.zone_id !== data.zone_id ) { if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id; data.zone_id = response.data.zone_id;
if ( window.history.pushState ) { if ( window.history.pushState ) {
window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id ); window.history.pushState(
{},
'',
'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id
);
} }
} }
shippingMethod.set( 'methods', response.data.methods ); shippingMethod.set( 'methods', response.data.methods );
@ -72,7 +81,12 @@
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation ); $( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
$save_button.on( 'click', { view: this }, this.onSubmit ); $save_button.on( 'click', { view: this }, this.onSubmit );
$( document.body ).on( 'input change', '#zone_name, #zone_locations, #zone_postcodes', { view: this }, this.onUpdateZone ); $( document.body ).on(
'input change',
'#zone_name, #zone_locations, #zone_postcodes',
{ view: this },
this.onUpdateZone
);
$( document.body ).on( 'click', '.wc-shipping-zone-method-settings', { view: this }, this.onConfigureShippingMethod ); $( document.body ).on( 'click', '.wc-shipping-zone-method-settings', { view: this }, this.onConfigureShippingMethod );
$( document.body ).on( 'click', '.wc-shipping-zone-add-method', { view: this }, this.onAddShippingMethod ); $( document.body ).on( 'click', '.wc-shipping-zone-add-method', { view: this }, this.onAddShippingMethod );
$( document.body ).on( 'wc_backbone_modal_response', this.onConfigureShippingMethodSubmitted ); $( document.body ).on( 'wc_backbone_modal_response', this.onConfigureShippingMethodSubmitted );
@ -128,9 +142,13 @@
// Populate $tbody with the current methods // Populate $tbody with the current methods
$.each( methods, function( id, rowData ) { $.each( methods, function( id, rowData ) {
if ( 'yes' === rowData.enabled ) { if ( 'yes' === rowData.enabled ) {
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' + data.strings.yes + '</span>'; rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' +
data.strings.yes +
'</span>';
} else { } else {
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled">' + data.strings.no + '</span>'; rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled">' +
data.strings.no +
'</span>';
} }
view.$el.append( view.rowTemplate( rowData ) ); view.$el.append( view.rowTemplate( rowData ) );
@ -138,7 +156,9 @@
var $tr = view.$el.find( 'tr[data-id="' + rowData.instance_id + '"]'); var $tr = view.$el.find( 'tr[data-id="' + rowData.instance_id + '"]');
if ( ! rowData.has_settings ) { if ( ! rowData.has_settings ) {
$tr.find( '.wc-shipping-zone-method-title > a' ).replaceWith('<span>' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '</span>' ); $tr
.find( '.wc-shipping-zone-method-title > a' )
.replaceWith('<span>' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '</span>' );
var $del = $tr.find( '.wc-shipping-zone-method-delete' ); var $del = $tr.find( '.wc-shipping-zone-method-delete' );
$tr.find( '.wc-shipping-zone-method-title .row-actions' ).empty().html($del); $tr.find( '.wc-shipping-zone-method-title .row-actions' ).empty().html($del);
} }
@ -241,7 +261,9 @@
if ( old_position !== new_position ) { if ( old_position !== new_position ) {
methods[ method.instance_id ].method_order = new_position; methods[ method.instance_id ].method_order = new_position;
changes.methods = changes.methods || { methods : {} }; changes.methods = changes.methods || { methods : {} };
changes.methods[ method.instance_id ] = _.extend( changes.methods[ method.instance_id ] || {}, { method_order : new_position } ); changes.methods[ method.instance_id ] = _.extend(
changes.methods[ method.instance_id ] || {}, { method_order : new_position }
);
} }
} ); } );
@ -281,30 +303,35 @@
shippingMethodView.block(); shippingMethodView.block();
// Save method settings via ajax call // Save method settings via ajax call
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_settings', { $.post(
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce, ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_settings',
instance_id : posted_data.instance_id, {
data : posted_data wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
}, function( response, textStatus ) { instance_id : posted_data.instance_id,
if ( 'success' === textStatus && response.success ) { data : posted_data
$( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove(); },
function( response, textStatus ) {
if ( 'success' === textStatus && response.success ) {
$( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove();
// If there were errors, prepend the form. // If there were errors, prepend the form.
if ( response.data.errors.length > 0 ) { if ( response.data.errors.length > 0 ) {
shippingMethodView.showErrors( response.data.errors ); shippingMethodView.showErrors( response.data.errors );
} }
// Method was saved. Re-render. // Method was saved. Re-render.
if ( _.size( shippingMethodView.model.changes ) ) { if ( _.size( shippingMethodView.model.changes ) ) {
shippingMethodView.model.save(); shippingMethodView.model.save();
} else {
shippingMethodView.model.onSaveResponse( response, textStatus );
}
} else { } else {
shippingMethodView.model.onSaveResponse( response, textStatus ); window.alert( data.strings.save_failed );
shippingMethodView.unblock();
} }
} else { },
window.alert( data.strings.save_failed ); 'json'
shippingMethodView.unblock(); );
}
}, 'json' );
} }
}, },
showErrors: function( errors ) { showErrors: function( errors ) {
@ -343,7 +370,11 @@
if ( response.data.zone_id !== data.zone_id ) { if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id; data.zone_id = response.data.zone_id;
if ( window.history.pushState ) { if ( window.history.pushState ) {
window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id ); window.history.pushState(
{},
'',
'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id
);
} }
} }
// Trigger save if there are changes, or just re-render // Trigger save if there are changes, or just re-render

View File

@ -161,7 +161,9 @@
class_name = 'method_enabled'; class_name = 'method_enabled';
} }
$method_list.append( '<li class="wc-shipping-zone-method ' + class_name + '">' + shipping_method.title + '</li>' ); $method_list.append(
'<li class="wc-shipping-zone-method ' + class_name + '">' + shipping_method.title + '</li>'
);
} ); } );
} else { } else {
$method_list.append( '<li class="wc-shipping-zone-method">' + data.strings.no_shipping_methods_offered + '</li>' ); $method_list.append( '<li class="wc-shipping-zone-method">' + data.strings.no_shipping_methods_offered + '</li>' );

View File

@ -12,10 +12,22 @@
if ( 0 === $blankslate.length ) { if ( 0 === $blankslate.length ) {
if ( woocommerce_admin.urls.export_products ) { if ( woocommerce_admin.urls.export_products ) {
$title_action.after('<a href="' + woocommerce_admin.urls.export_products + '" class="page-title-action">' + woocommerce_admin.strings.export_products + '</a>'); $title_action.after(
'<a href="' +
woocommerce_admin.urls.export_products +
'" class="page-title-action">' +
woocommerce_admin.strings.export_products +
'</a>'
);
} }
if ( woocommerce_admin.urls.import_products ) { if ( woocommerce_admin.urls.import_products ) {
$title_action.after( '<a href="' + woocommerce_admin.urls.import_products + '" class="page-title-action">' + woocommerce_admin.strings.import_products + '</a>' ); $title_action.after(
'<a href="' +
woocommerce_admin.urls.import_products +
'" class="page-title-action">' +
woocommerce_admin.strings.import_products +
'</a>'
);
} }
} else { } else {
$title_action.hide(); $title_action.hide();
@ -60,70 +72,85 @@
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } ); $( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
}) })
.on( 'change', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]', function() { .on(
var regex, decimalRegex, 'change',
decimailPoint = woocommerce_admin.decimal_point; '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]',
function() {
var regex, decimalRegex,
decimailPoint = woocommerce_admin.decimal_point;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) { if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
decimailPoint = woocommerce_admin.mon_decimal_point; decimailPoint = woocommerce_admin.mon_decimal_point;
}
regex = new RegExp( '[^\-0-9\%\\' + decimailPoint + ']+', 'gi' );
decimalRegex = new RegExp( '\\' + decimailPoint + '+', 'gi' );
var value = $( this ).val();
var newvalue = value.replace( regex, '' ).replace( decimalRegex, decimailPoint );
if ( value !== newvalue ) {
$( this ).val( newvalue );
}
} }
)
regex = new RegExp( '[^\-0-9\%\\' + decimailPoint + ']+', 'gi' ); .on(
decimalRegex = new RegExp( '\\' + decimailPoint + '+', 'gi' ); 'keyup',
// eslint-disable-next-line max-len
'.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]',
function() {
var regex, error, decimalRegex;
var checkDecimalNumbers = false;
var value = $( this ).val(); if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
var newvalue = value.replace( regex, '' ).replace( decimalRegex, decimailPoint ); checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.mon_decimal_point + ']', 'gi' );
error = 'i18n_mon_decimal_error';
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
error = 'i18n_country_iso_error';
} else {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.decimal_point + ']', 'gi' );
error = 'i18n_decimal_error';
}
if ( value !== newvalue ) { var value = $( this ).val();
$( this ).val( newvalue ); var newvalue = value.replace( regex, '' );
// Check if newvalue have more than one decimal point.
if ( checkDecimalNumbers && 1 < newvalue.replace( decimalRegex, '' ).length ) {
newvalue = newvalue.replace( decimalRegex, '' );
}
if ( value !== newvalue ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
}
} }
}) )
.on( 'keyup', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex, error, decimalRegex;
var checkDecimalNumbers = false;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.mon_decimal_point + ']', 'gi' );
error = 'i18n_mon_decimal_error';
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
error = 'i18n_country_iso_error';
} else {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.decimal_point + ']', 'gi' );
error = 'i18n_decimal_error';
}
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
// Check if newvalue have more than one decimal point.
if ( checkDecimalNumbers && 1 < newvalue.replace( decimalRegex, '' ).length ) {
newvalue = newvalue.replace( decimalRegex, '' );
}
if ( value !== newvalue ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
}
})
.on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() { .on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field; var sale_price_field = $( this ), regular_price_field;
if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) { if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' ); regular_price_field = sale_price_field
.parents( '.variable_pricing' )
.find( '.wc_input_price[name^=variable_regular_price]' );
} else { } else {
regular_price_field = $( '#_regular_price' ); regular_price_field = $( '#_regular_price' );
} }
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) ); var sale_price = parseFloat(
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) ); window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point )
);
var regular_price = parseFloat(
window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point )
);
if ( sale_price >= regular_price ) { if ( sale_price >= regular_price ) {
$( this ).val( '' ); $( this ).val( '' );
@ -134,13 +161,19 @@
var sale_price_field = $( this ), regular_price_field; var sale_price_field = $( this ), regular_price_field;
if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) { if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' ); regular_price_field = sale_price_field
.parents( '.variable_pricing' )
.find( '.wc_input_price[name^=variable_regular_price]' );
} else { } else {
regular_price_field = $( '#_regular_price' ); regular_price_field = $( '#_regular_price' );
} }
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) ); var sale_price = parseFloat(
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) ); window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point )
);
var regular_price = parseFloat(
window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point )
);
if ( sale_price >= regular_price ) { if ( sale_price >= regular_price ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] ); $( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
@ -236,9 +269,13 @@
if ( $( 'tr.last_selected', $this_table ).length > 0 ) { if ( $( 'tr.last_selected', $this_table ).length > 0 ) {
if ( $this_row.index() > $( 'tr.last_selected', $this_table ).index() ) { if ( $this_row.index() > $( 'tr.last_selected', $this_table ).index() ) {
$( 'tr', $this_table ).slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() ).addClass( 'current' ); $( 'tr', $this_table )
.slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() )
.addClass( 'current' );
} else { } else {
$( 'tr', $this_table ).slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 ).addClass( 'current' ); $( 'tr', $this_table )
.slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 )
.addClass( 'current' );
} }
} }
@ -260,7 +297,8 @@
}); });
// Additional cost and Attribute term tables // Additional cost and Attribute term tables
$( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' ); $( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' )
.addClass( 'alternate' );
// Show order items on orders page // Show order items on orders page
$( document.body ).on( 'click', '.show_order_items', function() { $( document.body ).on( 'click', '.show_order_items', function() {
@ -281,9 +319,15 @@
$( '.hide_options_if_checked' ).each( function() { $( '.hide_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() { $( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) { if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide(); $( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.hide();
} else { } else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show(); $( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.show();
} }
}).change(); }).change();
}); });
@ -291,9 +335,15 @@
$( '.show_options_if_checked' ).each( function() { $( '.show_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() { $( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) { if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show(); $( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.show();
} else { } else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide(); $( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.hide();
} }
}).change(); }).change();
}); });

View File

@ -72,8 +72,14 @@
*/ */
VariationForm.prototype.onHide = function( event ) { VariationForm.prototype.onHide = function( event ) {
event.preventDefault(); event.preventDefault();
event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'wc-variation-is-unavailable' ).addClass( 'disabled wc-variation-selection-needed' ); event.data.variationForm.$form
event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-enabled' ).addClass( 'woocommerce-variation-add-to-cart-disabled' ); .find( '.single_add_to_cart_button' )
.removeClass( 'wc-variation-is-unavailable' )
.addClass( 'disabled wc-variation-selection-needed' );
event.data.variationForm.$form
.find( '.woocommerce-variation-add-to-cart' )
.removeClass( 'woocommerce-variation-add-to-cart-enabled' )
.addClass( 'woocommerce-variation-add-to-cart-disabled' );
}; };
/** /**
@ -82,11 +88,22 @@
VariationForm.prototype.onShow = function( event, variation, purchasable ) { VariationForm.prototype.onShow = function( event, variation, purchasable ) {
event.preventDefault(); event.preventDefault();
if ( purchasable ) { if ( purchasable ) {
event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' ); event.data.variationForm.$form
event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-disabled' ).addClass( 'woocommerce-variation-add-to-cart-enabled' ); .find( '.single_add_to_cart_button' )
.removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' );
event.data.variationForm.$form
.find( '.woocommerce-variation-add-to-cart' )
.removeClass( 'woocommerce-variation-add-to-cart-disabled' )
.addClass( 'woocommerce-variation-add-to-cart-enabled' );
} else { } else {
event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'wc-variation-selection-needed' ).addClass( 'disabled wc-variation-is-unavailable' ); event.data.variationForm.$form
event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-enabled' ).addClass( 'woocommerce-variation-add-to-cart-disabled' ); .find( '.single_add_to_cart_button' )
.removeClass( 'wc-variation-selection-needed' )
.addClass( 'disabled wc-variation-is-unavailable' );
event.data.variationForm.$form
.find( '.woocommerce-variation-add-to-cart' )
.removeClass( 'woocommerce-variation-add-to-cart-enabled' )
.addClass( 'woocommerce-variation-add-to-cart-disabled' );
} }
// If present, the media element library needs initialized on the variation description. // If present, the media element library needs initialized on the variation description.
@ -123,8 +140,12 @@
VariationForm.prototype.onResetDisplayedVariation = function( event ) { VariationForm.prototype.onResetDisplayedVariation = function( event ) {
var form = event.data.variationForm; var form = event.data.variationForm;
form.$product.find( '.product_meta' ).find( '.sku' ).wc_reset_content(); form.$product.find( '.product_meta' ).find( '.sku' ).wc_reset_content();
form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ).wc_reset_content(); form.$product
form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ).wc_reset_content(); .find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' )
.wc_reset_content();
form.$product
.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' )
.wc_reset_content();
form.$form.trigger( 'reset_image' ); form.$form.trigger( 'reset_image' );
form.$singleVariation.slideUp( 200 ).trigger( 'hide_variation' ); form.$singleVariation.slideUp( 200 ).trigger( 'hide_variation' );
}; };
@ -164,7 +185,13 @@
attributes.chosenCount = 0; attributes.chosenCount = 0;
if ( ! form.loading ) { if ( ! form.loading ) {
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' ); form.$form
.find( '.single_variation' )
.after(
'<p class="wc-no-matching-variations woocommerce-info">' +
wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
'</p>'
);
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 ); form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
} }
} }
@ -186,7 +213,13 @@
attributes.chosenCount = 0; attributes.chosenCount = 0;
if ( ! form.loading ) { if ( ! form.loading ) {
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' ); form.$form
.find( '.single_variation' )
.after(
'<p class="wc-no-matching-variations woocommerce-info">' +
wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
'</p>'
);
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 ); form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
} }
} }
@ -206,8 +239,12 @@
VariationForm.prototype.onFoundVariation = function( event, variation ) { VariationForm.prototype.onFoundVariation = function( event, variation ) {
var form = event.data.variationForm, var form = event.data.variationForm,
$sku = form.$product.find( '.product_meta' ).find( '.sku' ), $sku = form.$product.find( '.product_meta' ).find( '.sku' ),
$weight = form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ), $weight = form.$product.find(
$dimensions = form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ), '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value'
),
$dimensions = form.$product.find(
'.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value'
),
$qty = form.$singleVariationWrap.find( '.quantity' ), $qty = form.$singleVariationWrap.find( '.quantity' ),
purchasable = true, purchasable = true,
variation_id = '', variation_id = '',
@ -333,7 +370,11 @@
refSelect.find( 'option' ).removeAttr( 'disabled attached' ).removeAttr( 'selected' ); refSelect.find( 'option' ).removeAttr( 'disabled attached' ).removeAttr( 'selected' );
current_attr_select.data( 'attribute_options', refSelect.find( 'option' + option_gt_filter ).get() ); // Legacy data attribute. // Legacy data attribute.
current_attr_select.data(
'attribute_options',
refSelect.find( 'option' + option_gt_filter ).get()
);
current_attr_select.data( 'attribute_html', refSelect.html() ); current_attr_select.data( 'attribute_html', refSelect.html() );
} }
@ -597,7 +638,9 @@
$product_gallery = $product.find( '.images' ), $product_gallery = $product.find( '.images' ),
$gallery_nav = $product.find( '.flex-control-nav' ), $gallery_nav = $product.find( '.flex-control-nav' ),
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ), $gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
$product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ), $product_img_wrap = $product_gallery
.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' )
.eq( 0 ),
$product_img = $product_img_wrap.find( '.wp-post-image' ), $product_img = $product_img_wrap.find( '.wp-post-image' ),
$product_link = $product_img_wrap.find( 'a' ).eq( 0 ); $product_link = $product_img_wrap.find( 'a' ).eq( 0 );
@ -658,7 +701,9 @@
$product_gallery = $product.find( '.images' ), $product_gallery = $product.find( '.images' ),
$gallery_nav = $product.find( '.flex-control-nav' ), $gallery_nav = $product.find( '.flex-control-nav' ),
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ), $gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
$product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ), $product_img_wrap = $product_gallery
.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' )
.eq( 0 ),
$product_img = $product_img_wrap.find( '.wp-post-image' ), $product_img = $product_img_wrap.find( '.wp-post-image' ),
$product_link = $product_img_wrap.find( 'a' ).eq( 0 ); $product_link = $product_img_wrap.find( 'a' ).eq( 0 );

View File

@ -134,7 +134,9 @@ jQuery( function( $ ) {
*/ */
var show_notice = function( html_element, $target ) { var show_notice = function( html_element, $target ) {
if ( ! $target ) { if ( ! $target ) {
$target = $( '.woocommerce-notices-wrapper:first' ) || $( '.cart-empty' ).closest( '.woocommerce' ) || $( '.woocommerce-cart-form' ); $target = $( '.woocommerce-notices-wrapper:first' ) ||
$( '.cart-empty' ).closest( '.woocommerce' ) ||
$( '.woocommerce-cart-form' );
} }
$target.prepend( html_element ); $target.prepend( html_element );
}; };
@ -188,6 +190,7 @@ jQuery( function( $ ) {
shipping_method_selected: function() { shipping_method_selected: function() {
var shipping_methods = {}; var shipping_methods = {};
// eslint-disable-next-line max-len
$( 'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() { $( 'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val(); shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
} ); } );

View File

@ -22,7 +22,12 @@ jQuery( function( $ ) {
this.hideSaveNewCheckbox = this.hideSaveNewCheckbox.bind( this ); this.hideSaveNewCheckbox = this.hideSaveNewCheckbox.bind( this );
// When a radio button is changed, make sure to show/hide our new CC info area. // When a radio button is changed, make sure to show/hide our new CC info area.
this.$target.on( 'click change', ':input.woocommerce-SavedPaymentMethods-tokenInput', { tokenizationForm: this }, this.onTokenChange ); this.$target.on(
'click change',
':input.woocommerce-SavedPaymentMethods-tokenInput',
{ tokenizationForm: this },
this.onTokenChange
);
// OR if create account is checked. // OR if create account is checked.
$( 'input#createaccount' ).change( { tokenizationForm: this }, this.onCreateAccountChange ); $( 'input#createaccount' ).change( { tokenizationForm: this }, this.onCreateAccountChange );

View File

@ -43,6 +43,11 @@
"Automattic\\WooCommerce\\": "src/" "Automattic\\WooCommerce\\": "src/"
} }
}, },
"autoload-dev": {
"psr-4": {
"Automattic\\WooCommerce\\Tests\\": "tests/php/"
}
},
"scripts": { "scripts": {
"post-install-cmd": [ "post-install-cmd": [
"sh ./bin/package-update.sh" "sh ./bin/package-update.sh"

View File

@ -97,10 +97,11 @@ class WC_Helper_API {
$args['headers'] = array(); $args['headers'] = array();
} }
$args['headers'] = array( $headers = array(
'Authorization' => 'Bearer ' . $auth['access_token'], 'Authorization' => 'Bearer ' . $auth['access_token'],
'X-Woo-Signature' => $signature, 'X-Woo-Signature' => $signature,
); );
$args['headers'] = wp_parse_args( $headers, $args['headers'] );
$url = add_query_arg( $url = add_query_arg(
array( array(
@ -139,6 +140,19 @@ class WC_Helper_API {
return self::request( $endpoint, $args ); return self::request( $endpoint, $args );
} }
/**
* Wrapper for self::request().
*
* @param string $endpoint The helper API endpoint to request.
* @param array $args Arguments passed to wp_remote_request().
*
* @return array The response object from wp_safe_remote_request().
*/
public static function put( $endpoint, $args = array() ) {
$args['method'] = 'PUT';
return self::request( $endpoint, $args );
}
/** /**
* Using the API base, form a request URL from a given endpoint. * Using the API base, form a request URL from a given endpoint.
* *

325
package-lock.json generated
View File

@ -7216,16 +7216,6 @@
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
"dev": true "dev": true
}, },
"cli": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz",
"integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=",
"dev": true,
"requires": {
"exit": "0.1.2",
"glob": "^7.1.1"
}
},
"cli-cursor": { "cli-cursor": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
@ -7494,9 +7484,9 @@
"dev": true "dev": true
}, },
"compare-versions": { "compare-versions": {
"version": "3.5.1", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.5.1.tgz", "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz",
"integrity": "sha512-9fGPIB7C6AyM18CJJBHt5EnCZDG3oiTJYy0NjfIAGjKpzv0tkxWko7TNQHF5ymqm7IH03tqmeuBxtvD+Izh6mg==", "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==",
"dev": true "dev": true
}, },
"component-emitter": { "component-emitter": {
@ -7533,13 +7523,10 @@
} }
}, },
"console-browserify": { "console-browserify": {
"version": "1.1.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz",
"integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==",
"dev": true, "dev": true
"requires": {
"date-now": "^0.1.4"
}
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
@ -7865,12 +7852,6 @@
"integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==", "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==",
"dev": true "dev": true
}, },
"date-now": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
"integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
"dev": true
},
"dateformat": { "dateformat": {
"version": "1.0.12", "version": "1.0.12",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz",
@ -8368,12 +8349,6 @@
} }
} }
}, },
"entities": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz",
"integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=",
"dev": true
},
"errno": { "errno": {
"version": "0.1.7", "version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
@ -10571,17 +10546,6 @@
"maxmin": "^2.1.0" "maxmin": "^2.1.0"
} }
}, },
"grunt-contrib-jshint": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-2.1.0.tgz",
"integrity": "sha512-65S2/C/6RfjY/umTxfwXXn+wVvaYmykHkHSsW6Q6rhkbv3oudTEgqnFFZvWzWCoHUb+3GMZLbP3oSrNyvshmIQ==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
"hooker": "^0.2.3",
"jshint": "~2.10.2"
}
},
"grunt-contrib-uglify": { "grunt-contrib-uglify": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-4.0.1.tgz", "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-4.0.1.tgz",
@ -10949,6 +10913,190 @@
"chalk": "^2.4.2" "chalk": "^2.4.2"
} }
}, },
"gruntify-eslint": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/gruntify-eslint/-/gruntify-eslint-5.0.0.tgz",
"integrity": "sha512-pa2sXHK9+U4dCGdGSIMkpJARNwRStdLBsddNxmSHSSWROUdhWMrXvFWm6pj48zJhyV3Qy068VIuF1seYIvc0cw==",
"dev": true,
"requires": {
"eslint": "^5.0.0"
},
"dependencies": {
"acorn": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
"integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
"dev": true
},
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
"dev": true,
"requires": {
"restore-cursor": "^2.0.0"
}
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dev": true,
"requires": {
"ms": "^2.1.1"
}
},
"eslint": {
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz",
"integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"ajv": "^6.9.1",
"chalk": "^2.1.0",
"cross-spawn": "^6.0.5",
"debug": "^4.0.1",
"doctrine": "^3.0.0",
"eslint-scope": "^4.0.3",
"eslint-utils": "^1.3.1",
"eslint-visitor-keys": "^1.0.0",
"espree": "^5.0.1",
"esquery": "^1.0.1",
"esutils": "^2.0.2",
"file-entry-cache": "^5.0.1",
"functional-red-black-tree": "^1.0.1",
"glob": "^7.1.2",
"globals": "^11.7.0",
"ignore": "^4.0.6",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"inquirer": "^6.2.2",
"js-yaml": "^3.13.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.3.0",
"lodash": "^4.17.11",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"natural-compare": "^1.4.0",
"optionator": "^0.8.2",
"path-is-inside": "^1.0.2",
"progress": "^2.0.0",
"regexpp": "^2.0.1",
"semver": "^5.5.1",
"strip-ansi": "^4.0.0",
"strip-json-comments": "^2.0.1",
"table": "^5.2.3",
"text-table": "^0.2.0"
}
},
"eslint-scope": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz",
"integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==",
"dev": true,
"requires": {
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
}
},
"espree": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz",
"integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==",
"dev": true,
"requires": {
"acorn": "^6.0.7",
"acorn-jsx": "^5.0.0",
"eslint-visitor-keys": "^1.0.0"
}
},
"figures": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
}
},
"globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
"dev": true
},
"inquirer": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz",
"integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==",
"dev": true,
"requires": {
"ansi-escapes": "^3.2.0",
"chalk": "^2.4.2",
"cli-cursor": "^2.1.0",
"cli-width": "^2.0.0",
"external-editor": "^3.0.3",
"figures": "^2.0.0",
"lodash": "^4.17.12",
"mute-stream": "0.0.7",
"run-async": "^2.2.0",
"rxjs": "^6.4.0",
"string-width": "^2.1.0",
"strip-ansi": "^5.1.0",
"through": "^2.3.6"
},
"dependencies": {
"strip-ansi": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"dev": true,
"requires": {
"ansi-regex": "^4.1.0"
}
}
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"mute-stream": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",
"dev": true
},
"onetime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"dev": true,
"requires": {
"mimic-fn": "^1.0.0"
}
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
"dev": true,
"requires": {
"onetime": "^2.0.0",
"signal-exit": "^3.0.2"
}
}
}
},
"gzip-size": { "gzip-size": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz",
@ -11169,39 +11317,6 @@
"integrity": "sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==", "integrity": "sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==",
"dev": true "dev": true
}, },
"htmlparser2": {
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz",
"integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=",
"dev": true,
"requires": {
"domelementtype": "1",
"domhandler": "2.3",
"domutils": "1.5",
"entities": "1.0",
"readable-stream": "1.1"
},
"dependencies": {
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
}
}
},
"http-parser-js": { "http-parser-js": {
"version": "0.5.0", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.0.tgz", "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.0.tgz",
@ -11259,14 +11374,14 @@
"dev": true "dev": true
}, },
"husky": { "husky": {
"version": "4.2.1", "version": "4.2.5",
"resolved": "https://registry.npmjs.org/husky/-/husky-4.2.1.tgz", "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.5.tgz",
"integrity": "sha512-Qa0lRreeIf4Tl92sSs42ER6qc3hzoyQPPorzOrFWfPEVbdi6LuvJEqWKPk905fOWIR76iBpp7ECZNIwk+a8xuQ==", "integrity": "sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"chalk": "^3.0.0", "chalk": "^4.0.0",
"ci-info": "^2.0.0", "ci-info": "^2.0.0",
"compare-versions": "^3.5.1", "compare-versions": "^3.6.0",
"cosmiconfig": "^6.0.0", "cosmiconfig": "^6.0.0",
"find-versions": "^3.2.0", "find-versions": "^3.2.0",
"opencollective-postinstall": "^2.0.2", "opencollective-postinstall": "^2.0.2",
@ -11287,9 +11402,9 @@
} }
}, },
"chalk": { "chalk": {
"version": "3.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz",
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==",
"dev": true, "dev": true,
"requires": { "requires": {
"ansi-styles": "^4.1.0", "ansi-styles": "^4.1.0",
@ -11879,12 +11994,6 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"isexe": { "isexe": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -14082,30 +14191,6 @@
"integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
"dev": true "dev": true
}, },
"jshint": {
"version": "2.10.2",
"resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz",
"integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==",
"dev": true,
"requires": {
"cli": "~1.0.0",
"console-browserify": "1.1.x",
"exit": "0.1.x",
"htmlparser2": "3.8.x",
"lodash": "~4.17.11",
"minimatch": "~3.0.2",
"shelljs": "0.3.x",
"strip-json-comments": "1.0.x"
},
"dependencies": {
"strip-json-comments": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
"integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=",
"dev": true
}
}
},
"json-parse-better-errors": { "json-parse-better-errors": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
@ -16092,6 +16177,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true "dev": true
}, },
"path-is-inside": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz",
"integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=",
"dev": true
},
"path-key": { "path-key": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
@ -19511,12 +19602,6 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true "dev": true
}, },
"shelljs": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz",
"integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=",
"dev": true
},
"shellwords": { "shellwords": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",

View File

@ -46,7 +46,6 @@
"grunt-contrib-concat": "1.0.1", "grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0", "grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "3.0.0", "grunt-contrib-cssmin": "3.0.0",
"grunt-contrib-jshint": "2.1.0",
"grunt-contrib-uglify": "4.0.1", "grunt-contrib-uglify": "4.0.1",
"grunt-contrib-watch": "1.1.0", "grunt-contrib-watch": "1.1.0",
"grunt-phpcs": "0.4.0", "grunt-phpcs": "0.4.0",
@ -56,7 +55,8 @@
"grunt-sass": "3.1.0", "grunt-sass": "3.1.0",
"grunt-shell": "3.0.1", "grunt-shell": "3.0.1",
"grunt-stylelint": "0.14.0", "grunt-stylelint": "0.14.0",
"husky": "4.2.1", "gruntify-eslint": "5.0.0",
"husky": "4.2.5",
"istanbul": "1.0.0-alpha.2", "istanbul": "1.0.0-alpha.2",
"jest": "25.1.0", "jest": "25.1.0",
"jest-puppeteer": "4.4.0", "jest-puppeteer": "4.4.0",

View File

@ -6,6 +6,7 @@
<!-- Exclude paths --> <!-- Exclude paths -->
<exclude-pattern>tests/cli/</exclude-pattern> <exclude-pattern>tests/cli/</exclude-pattern>
<exclude-pattern>tests/legacy/</exclude-pattern>
<exclude-pattern>includes/libraries/</exclude-pattern> <exclude-pattern>includes/libraries/</exclude-pattern>
<exclude-pattern>includes/legacy/</exclude-pattern> <exclude-pattern>includes/legacy/</exclude-pattern>
<exclude-pattern>includes/api/legacy/</exclude-pattern> <exclude-pattern>includes/api/legacy/</exclude-pattern>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
bootstrap="tests/bootstrap.php" bootstrap="tests/legacy/bootstrap.php"
backupGlobals="false" backupGlobals="false"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
@ -10,7 +10,8 @@
> >
<testsuites> <testsuites>
<testsuite name="WooCommerce Test Suite"> <testsuite name="WooCommerce Test Suite">
<directory suffix=".php">./tests/unit-tests</directory> <directory suffix=".php">./tests/legacy/unit-tests</directory>
<directory suffix=".php">./tests/php</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
@ -46,6 +47,6 @@
</whitelist> </whitelist>
</filter> </filter>
<listeners> <listeners>
<listener class="SpeedTrapListener" file="tests/includes/listener-loader.php" /> <listener class="SpeedTrapListener" file="tests/legacy/includes/listener-loader.php" />
</listeners> </listeners>
</phpunit> </phpunit>

5
src/Admin/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Prevent anyone from accidentally adding code to these directories.
# This will break any PRs that do, revealing ths mistake they made.
*
!.gitignore
!README.md

3
src/Admin/README.md Normal file
View File

@ -0,0 +1,3 @@
# WARNING
The namespace of this folder belongs to the [WC-Admin Plugin](https://github.com/woocommerce/woocommerce-admin) that is included in Core via composer. Any contributions to this namespace should be made in the corresponding repository to prevent conflicts.

5
src/Blocks/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Prevent anyone from accidentally adding code to these directories.
# This will break any PRs that do, revealing ths mistake they made.
*
!.gitignore
!README.md

3
src/Blocks/README.md Normal file
View File

@ -0,0 +1,3 @@
# WARNING
The namespace of this folder belongs to the [Product Blocks Plugin](https://github.com/woocommerce/woocommerce-gutenberg-products-block) that is included in Core via composer. Any contributions to this namespace should be made in the corresponding repository to prevent conflicts.

View File

@ -46,7 +46,7 @@ The tests will execute and you'll be presented with a summary.
You can run specific tests by providing the path and filename to the test class: You can run specific tests by providing the path and filename to the test class:
$ vendor/bin/phpunit tests/unit-tests/importer/product.php $ vendor/bin/phpunit tests/legacy/unit-tests/importer/product.php
A text code coverage summary can be displayed using the `--coverage-text` option: A text code coverage summary can be displayed using the `--coverage-text` option:
@ -54,6 +54,7 @@ A text code coverage summary can be displayed using the `--coverage-text` option
### Writing Tests ### Writing Tests
* There are two different PHPUnit directories, `tests/legacy` and `tests/php`. The `tests/legacy` directory contains all of the tests for code in the `includes` directory, and the `tests/php` directory is a PSR-4 namespaced directory for tests of code in the `src` directory.
* Each test file should roughly correspond to an associated source file, e.g. the `formatting/functions.php` test file covers code in the `wc-formatting-functions.php` file * Each test file should roughly correspond to an associated source file, e.g. the `formatting/functions.php` test file covers code in the `wc-formatting-functions.php` file
* Each test method should cover a single method or function with one or more assertions * Each test method should cover a single method or function with one or more assertions
* A single method or function can have multiple associated test methods if it's a large or complex method * A single method or function can have multiple associated test methods if it's a large or complex method

View File

@ -41,7 +41,7 @@ class WC_Unit_Tests_Bootstrap {
// phpcs:enable WordPress.VIP.SuperGlobalInputUsage.AccessDetected // phpcs:enable WordPress.VIP.SuperGlobalInputUsage.AccessDetected
$this->tests_dir = dirname( __FILE__ ); $this->tests_dir = dirname( __FILE__ );
$this->plugin_dir = dirname( $this->tests_dir ); $this->plugin_dir = dirname( dirname( $this->tests_dir ) );
$this->wp_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : sys_get_temp_dir() . '/wordpress-tests-lib'; $this->wp_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : sys_get_temp_dir() . '/wordpress-tests-lib';
// load test function so tests_add_filter() is available. // load test function so tests_add_filter() is available.

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -41,7 +41,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
* @since 2.2 * @since 2.2
*/ */
public function test_constants() { public function test_constants() {
$this->assertEquals( str_replace( 'tests/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE ); $this->assertEquals( str_replace( 'tests/legacy/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE );
$this->assertEquals( $this->wc->version, Constants::get_constant( 'WC_VERSION' ) ); $this->assertEquals( $this->wc->version, Constants::get_constant( 'WC_VERSION' ) );
$this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION ); $this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION );
$this->assertEquals( 6, WC_ROUNDING_PRECISION ); $this->assertEquals( 6, WC_ROUNDING_PRECISION );

Some files were not shown because too many files have changed in this diff Show More