Merge pull request #2 from woocommerce/master

Merge updates
This commit is contained in:
Rami Yushuvaev 2016-10-11 21:09:14 +03:00 committed by GitHub
commit 39bdb3ee2e
26 changed files with 5880 additions and 2408 deletions

File diff suppressed because one or more lines are too long

View File

@ -2555,23 +2555,104 @@ table.wc_shipping {
}
}
}
.wc-shipping-zone-settings {
th {
padding: 24px 24px 24px 0;
}
td.forminp {
padding: 15px 10px;
input, textarea {
padding: 8px;
width: 448px;
max-width: 100% !important;
}
.wc-shipping-zone-region-select {
width: 448px;
max-width: 100% !important;
.select2-choices {
padding: 8px 8px 4px;
border-color: #DDDDDD;
min-height: 0;
line-height: 1;
input {
padding: 0;
}
li {
margin: 0 4px 4px 0;
}
}
}
.select2-container-active {
.select2-choices {
border-color: #777;
}
}
}
.wc-shipping-zone-postcodes-toggle {
margin: 0;
font-size: 0.9em;
text-decoration: underline;
}
.wc-shipping-zone-postcodes-toggle + .wc-shipping-zone-postcodes {
display:none;
}
.wc-shipping-zone-postcodes {
textarea {
margin: 10px 0;
}
.description {
font-size: 0.9em;
color: #999;
}
}
}
table {
tr, tr:hover {
table.wc-shipping-zone-methods {
tr {
.row-actions {
position: relative;
}
}
tr:hover {
.row-actions {
position: static;
}
}
}
}
}
table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-classes {
td, th {
vertical-align: top;
line-height: 24px;
padding: 1em;
padding: 1em !important;
font-size: 14px;
background: #fff;
li {
line-height: 24px;
font-size: 14px;
}
.woocommerce-help-tip {
margin: 0 !important;
}
}
thead {
th {
vertical-align: middle;
}
.wc-shipping-zone-sort {
text-align: center;
}
}
tbody td {
padding: 1.5em 1em !important;
}
td.wc-shipping-zones-blank-state, td.wc-shipping-zone-method-blank-state {
background: #f7f1f6 !important;
overflow: hidden;
position: relative;
padding: 7.5em 7.5%;
padding: 7.5em 7.5% !important;
border-bottom: 2px solid #eee2ec;
p, li {
color: #a46497;
@ -2690,54 +2771,29 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
a.wc-shipping-zone-delete:hover, a.wc-shipping-class-delete:hover {
color: red;
}
.wc-shipping-zone-postcodes-toggle {
float: right;
margin: 0;
font-size: 0.9em;
text-decoration: underline;
}
.wc-shipping-zone-postcodes {
display:none;
textarea {
margin-top: 1em;
}
.description {
font-size: 0.9em;
color: #999;
}
}
}
.wc-shipping-class-count {
text-align: center;
}
td.wc-shipping-zone-methods {
color: #999;
color: #555;
.method_disabled {
text-decoration: line-through;
}
ul {
color: #999;
position: relative;
padding-right: 32px;
li {
color: #555;
display: inline;
margin: 0;
}
li::before {
content: ', ';
}
li:first-child::before,
li:nth-child( 2 )::before {
li:first-child::before {
content: '';
}
li:first-child {
display: block;
}
li.wc-shipping-zone-methods-add-row {
position: absolute;
right: 0;
top: 0;
}
}
.add_shipping_method {
display: block;
@ -2774,19 +2830,13 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
}
.wc-shipping-zone-method-enabled {
text-align: center;
.status-enabled {
margin-top: 1px;
a {
display: inline-block;
&::before {
line-height: inherit;
}
}
.status-disabled {
margin-top: 1px;
display: inline-block;
&::before {
line-height: inherit;
}
.woocommerce-input-toggle {
margin-top: 3px;
}
}
tfoot {
@ -2804,6 +2854,39 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
}
}
.woocommerce-input-toggle {
height: 16px;
width: 32px;
border: 2px solid #935687;
background-color: #935687;
display: inline-block;
text-indent: -9999px;
border-radius: 10em;
position: relative;
&:before {
content: "";
display: block;
width: 16px;
height: 16px;
background: #fff;
position: absolute;
top: 0;
right: 0;
border-radius: 100%;
}
&.woocommerce-input-toggle--disabled {
border-color: #999;
background-color: #999;
&:before {
right: auto;
left: 0;
}
}
}
.wc-modal-shipping-method-settings {
background: #f8f8f8;
padding: 1em !important;

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,15 @@
}
}).change();
// Stock management
$( 'input#woocommerce_manage_stock' ).change( function() {
if ( $( this ).is(':checked') ) {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).show();
} else {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).hide();
}
}).change();
// Color picker
$( '.colorpick' ).iris({
change: function( event, ui ) {

View File

@ -1 +1 @@
!function(a){a("select#woocommerce_allowed_countries").change(function(){"specific"===a(this).val()?(a(this).closest("tr").next("tr").hide(),a(this).closest("tr").next().next("tr").show()):"all_except"===a(this).val()?(a(this).closest("tr").next("tr").show(),a(this).closest("tr").next().next("tr").hide()):(a(this).closest("tr").next("tr").hide(),a(this).closest("tr").next().next("tr").hide())}).change(),a("select#woocommerce_ship_to_countries").change(function(){"specific"===a(this).val()?a(this).closest("tr").next("tr").show():a(this).closest("tr").next("tr").hide()}).change(),a(".colorpick").iris({change:function(b,c){a(this).parent().find(".colorpickpreview").css({backgroundColor:c.color.toString()})},hide:!0,border:!0}).click(function(){a(".iris-picker").hide(),a(this).closest("td").find(".iris-picker").show()}),a("body").click(function(){a(".iris-picker").hide()}),a(".colorpick").click(function(a){a.stopPropagation()}),a(function(){var b=!1;a("input, textarea, select, checkbox").change(function(){b=!0}),a(".woo-nav-tab-wrapper a").click(function(){b?window.onbeforeunload=function(){return woocommerce_settings_params.i18n_nav_warning}:window.onbeforeunload=""}),a(".submit input").click(function(){window.onbeforeunload=""})}),a("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(b,c){return c.children().each(function(){a(this).width(a(this).width())}),c.css("left","0"),c},start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")}}),a(".woocommerce").on("click",".select_all",function(){return a(this).closest("td").find("select option").attr("selected","selected"),a(this).closest("td").find("select").trigger("change"),!1}),a(".woocommerce").on("click",".select_none",function(){return a(this).closest("td").find("select option").removeAttr("selected"),a(this).closest("td").find("select").trigger("change"),!1})}(jQuery);
!function(a){a("select#woocommerce_allowed_countries").change(function(){"specific"===a(this).val()?(a(this).closest("tr").next("tr").hide(),a(this).closest("tr").next().next("tr").show()):"all_except"===a(this).val()?(a(this).closest("tr").next("tr").show(),a(this).closest("tr").next().next("tr").hide()):(a(this).closest("tr").next("tr").hide(),a(this).closest("tr").next().next("tr").hide())}).change(),a("select#woocommerce_ship_to_countries").change(function(){"specific"===a(this).val()?a(this).closest("tr").next("tr").show():a(this).closest("tr").next("tr").hide()}).change(),a("input#woocommerce_manage_stock").change(function(){a(this).is(":checked")?a(this).closest("tbody").find(".manage_stock_field").closest("tr").show():a(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),a(".colorpick").iris({change:function(b,c){a(this).parent().find(".colorpickpreview").css({backgroundColor:c.color.toString()})},hide:!0,border:!0}).click(function(){a(".iris-picker").hide(),a(this).closest("td").find(".iris-picker").show()}),a("body").click(function(){a(".iris-picker").hide()}),a(".colorpick").click(function(a){a.stopPropagation()}),a(function(){var b=!1;a("input, textarea, select, checkbox").change(function(){b=!0}),a(".woo-nav-tab-wrapper a").click(function(){b?window.onbeforeunload=function(){return woocommerce_settings_params.i18n_nav_warning}:window.onbeforeunload=""}),a(".submit input").click(function(){window.onbeforeunload=""})}),a("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(b,c){return c.children().each(function(){a(this).width(a(this).width())}),c.css("left","0"),c},start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")}}),a(".woocommerce").on("click",".select_all",function(){return a(this).closest("td").find("select option").attr("selected","selected"),a(this).closest("td").find("select").trigger("change"),!1}),a(".woocommerce").on("click",".select_none",function(){return a(this).closest("td").find("select option").removeAttr("selected"),a(this).closest("td").find("select").trigger("change"),!1})}(jQuery);

View File

@ -13,27 +13,42 @@
logChanges: function( changedRows ) {
var changes = this.changes || {};
_.each( changedRows, function( row, id ) {
changes[ id ] = _.extend( changes[ id ] || { instance_id : id }, row );
_.each( changedRows.methods, function( row, id ) {
changes.methods = changes.methods || { methods : {} };
changes.methods[ id ] = _.extend( changes.methods[ id ] || { instance_id : id }, row );
} );
if ( changedRows.zone_name ) {
changes.zone_name = changedRows.zone_name;
}
if ( changedRows.zone_locations ) {
changes.zone_locations = changedRows.zone_locations;
}
if ( changedRows.zone_postcodes ) {
changes.zone_postcodes = changedRows.zone_postcodes;
}
this.changes = changes;
this.trigger( 'change:methods' );
},
save: function() {
if ( _.size( this.changes ) ) {
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes', {
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
changes : this.changes,
zone_id : data.zone_id
}, this.onSaveResponse, 'json' );
} else {
shippingMethod.trigger( 'saved:methods' );
}
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes', {
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
changes : this.changes,
zone_id : data.zone_id
}, this.onSaveResponse, 'json' );
},
onSaveResponse: function( response, textStatus ) {
if ( 'success' === textStatus ) {
if ( response.success ) {
if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id;
if ( window.history.pushState ) {
window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id );
}
}
shippingMethod.set( 'methods', response.data.methods );
shippingMethod.trigger( 'change:methods' );
shippingMethod.changes = {};
@ -57,12 +72,28 @@
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
$save_button.on( 'click', { view: this }, this.onSubmit );
// Settings modals
$( 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-add-method', { view: this }, this.onAddShippingMethod );
$( document.body ).on( 'wc_backbone_modal_response', this.onConfigureShippingMethodSubmitted );
$( document.body ).on( 'wc_backbone_modal_response', this.onAddShippingMethodSubmitted );
$( document.body ).on( 'change', '.wc-shipping-zone-method-selector select', this.onChangeShippingMethodSelector );
$( document.body ).on( 'click', '.wc-shipping-zone-postcodes-toggle', this.onTogglePostcodes );
},
onUpdateZone: function( event ) {
var view = event.data.view,
model = view.model,
value = $( this ).val(),
$target = $( event.target ),
attribute = $target.data( 'attribute' ),
changes = {};
event.preventDefault();
changes[ attribute ] = value;
model.set( attribute, value );
model.logChanges( changes );
view.render();
},
block: function() {
$( this.el ).block({
@ -78,8 +109,12 @@
},
render: function() {
var methods = _.indexBy( this.model.get( 'methods' ), 'instance_id' ),
zone_name = this.model.get( 'zone_name' ),
view = this;
// Set name.
$('.wc-shipping-zone-name').text( zone_name );
// Blank out the contents.
this.$el.empty();
this.unblock();
@ -93,9 +128,9 @@
// Populate $tbody with the current methods
$.each( methods, function( id, rowData ) {
if ( 'yes' === rowData.enabled ) {
rowData.enabled_icon = '<span class="status-enabled">' + data.strings.yes + '</span>';
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' + data.strings.yes + '</span>';
} else {
rowData.enabled_icon = '<span class="status-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 ) );
@ -137,7 +172,8 @@
event.preventDefault();
delete methods[ instance_id ];
changes[ instance_id ] = _.extend( changes[ instance_id ] || {}, { deleted : 'deleted' } );
changes.methods = changes.methods || { methods : {} };
changes.methods[ instance_id ] = _.extend( changes.methods[ instance_id ] || {}, { deleted : 'deleted' } );
model.set( 'methods', methods );
model.logChanges( changes );
view.render();
@ -153,7 +189,8 @@
event.preventDefault();
methods[ instance_id ].enabled = enabled;
changes[ instance_id ] = _.extend( changes[ instance_id ] || {}, { enabled : enabled } );
changes.methods = changes.methods || { methods : {} };
changes.methods[ instance_id ] = _.extend( changes.methods[ instance_id ] || {}, { enabled : enabled } );
model.set( 'methods', methods );
model.logChanges( changes );
view.render();
@ -183,8 +220,8 @@
changes = {};
if ( methods[ instance_id ][ attribute ] !== value ) {
changes[ instance_id ] = {};
changes[ instance_id ][ attribute ] = value;
changes.methods[ instance_id ] = {};
changes.methods[ instance_id ][ attribute ] = value;
methods[ instance_id ][ attribute ] = value;
}
@ -201,7 +238,9 @@
var new_position = parseInt( $table.find( 'tr[data-id="' + method.instance_id + '"]').index() + 1, 10 );
if ( old_position !== new_position ) {
changes[ method.instance_id ] = _.extend( changes[ method.instance_id ] || {}, { method_order : new_position } );
methods[ method.instance_id ].method_order = new_position;
changes.methods = changes.methods || { methods : {} };
changes.methods[ method.instance_id ] = _.extend( changes.methods[ method.instance_id ] || {}, { method_order : new_position } );
}
} );
@ -300,6 +339,12 @@
zone_id : data.zone_id
}, function( response, textStatus ) {
if ( 'success' === textStatus && response.success ) {
if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id;
if ( window.history.pushState ) {
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
if ( _.size( shippingMethodView.model.changes ) ) {
shippingMethodView.model.save();
@ -319,10 +364,17 @@
$( this ).parent().find( '.wc-shipping-zone-method-description' ).remove();
$( this ).after( '<p class="wc-shipping-zone-method-description">' + description + '</p>' );
$( this ).closest( 'article' ).height( $( this ).parent().height() );
},
onTogglePostcodes: function( event ) {
event.preventDefault();
var $tr = $( this ).closest( 'tr');
$tr.find( '.wc-shipping-zone-postcodes' ).show();
$tr.find( '.wc-shipping-zone-postcodes-toggle' ).hide();
}
} ),
shippingMethod = new ShippingMethod({
methods: data.methods
methods: data.methods,
zone_name: data.zone_name
} ),
shippingMethodView = new ShippingMethodView({
model: shippingMethod,

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/* global wc_enhanced_select_params, shippingZonesLocalizeScript, ajaxurl */
/* global shippingZonesLocalizeScript, ajaxurl */
( function( $, data, wp, ajaxurl ) {
$( function() {
var $table = $( '.wc-shipping-zones' ),
@ -6,14 +6,6 @@
$save_button = $( '.wc-shipping-zone-save' ),
$row_template = wp.template( 'wc-shipping-zone-row' ),
$blank_template = wp.template( 'wc-shipping-zone-row-blank' ),
select2_args = $.extend({
minimumResultsForSearch: 10,
allowClear: $( this ).data( 'allow_clear' ) ? true : false,
placeholder: $( this ).data( 'placeholder' ),
matcher: function( term, text, opt ) {
return text.toUpperCase().indexOf( term.toUpperCase() ) >= 0 || opt.attr( 'alt' ).toUpperCase().indexOf( term.toUpperCase() ) >= 0;
}
}, getEnhancedSelectFormatString() ),
// Backbone model
ShippingZone = Backbone.Model.extend({
@ -87,11 +79,7 @@
$tbody.on( 'change', { view: this }, this.updateModelOnChange );
$tbody.on( 'sortupdate', { view: this }, this.updateModelOnSort );
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
$save_button.on( 'click', { view: this }, this.onSubmit );
$( document.body ).on( 'click', '.add_shipping_method:not(.disabled)', { view: this }, this.onAddShippingMethod );
$( document.body ).on( 'click', '.wc-shipping-zone-add', { view: this }, this.onAddNewRow );
$( document.body ).on( 'wc_backbone_modal_response', this.onAddShippingMethodSubmitted );
$( document.body ).on( 'change', '.wc-shipping-zone-method-selector select', this.onChangeShippingMethodSelector );
},
block: function() {
$( this.el ).block({
@ -137,57 +125,9 @@
var view = this;
var $tr = view.$el.find( 'tr[data-id="' + rowData.zone_id + '"]');
// Select values in region select
_.each( rowData.zone_locations, function( location ) {
if ( 'string' === jQuery.type( location ) ) {
$tr.find( 'option[value="' + location + '"]' ).prop( 'selected', true );
} else {
if ( 'postcode' === location.type ) {
var postcode_field = $tr.find( '.wc-shipping-zone-postcodes :input' );
if ( postcode_field.val() ) {
postcode_field.val( postcode_field.val() + '\n' + location.code );
} else {
postcode_field.val( location.code );
}
$tr.find( '.wc-shipping-zone-postcodes' ).show();
$tr.find( '.wc-shipping-zone-postcodes-toggle' ).hide();
} else {
$tr.find( 'option[value="' + location.type + ':' + location.code + '"]' ).prop( 'selected', true );
}
}
} );
if ( rowData.zone_postcodes ) {
_.each( rowData.zone_postcodes, function( location ) {
var postcode_field = $tr.find( '.wc-shipping-zone-postcodes :input' );
if ( postcode_field.val() ) {
postcode_field.val( postcode_field.val() + '\n' + location.code );
} else {
postcode_field.val( location.code );
}
$tr.find( '.wc-shipping-zone-postcodes' ).show();
$tr.find( '.wc-shipping-zone-postcodes-toggle' ).hide();
} );
}
// List shipping methods
view.renderShippingMethods( rowData.zone_id, rowData.shipping_methods );
// Make the row function
$tr.find( '.view' ).show();
$tr.find( '.edit' ).hide();
$tr.find( '.wc-shipping-zone-edit' ).on( 'click', { view: this }, this.onEditRow );
$tr.find( '.wc-shipping-zone-cancel-edit' ).on( 'click', { view: this }, this.onCancelEditRow );
$tr.find( '.wc-shipping-zone-delete' ).on( 'click', { view: this }, this.onDeleteRow );
$tr.find( '.wc-shipping-zone-postcodes-toggle' ).on( 'click', { view: this }, this.onTogglePostcodes );
// Editing?
if ( true === rowData.editing ) {
$tr.addClass( 'editing' );
$tr.find( '.wc-shipping-zone-edit' ).trigger( 'click' );
}
},
initRows: function() {
// Stripe
@ -196,7 +136,6 @@
} else {
$table.find( 'tbody.wc-shipping-zone-rows' ).next( 'tbody' ).find( 'tr' ).removeClass( 'odd' );
}
// Tooltips
$( '#tiptip_holder' ).removeAttr( 'style' );
$( '#tiptip_arrow' ).removeAttr( 'style' );
@ -220,103 +159,32 @@
class_name = 'method_enabled';
}
$method_list.append( '<li class="wc-shipping-zone-method"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' + shipping_method.instance_id + '" class="' + class_name + '">' + shipping_method.title + '</a></li>' );
$method_list.append( '<li class="wc-shipping-zone-method ' + class_name + '">' + shipping_method.title + '</li>' );
} );
} else {
$method_list.append( '<li class="wc-shipping-zone-method">' + data.strings.no_shipping_methods_offered + '</li>' );
}
},
onSubmit: function( event ) {
event.data.view.block();
event.data.view.model.save();
event.preventDefault();
},
onAddNewRow: function( event ) {
event.preventDefault();
var view = event.data.view,
model = view.model,
zones = _.indexBy( model.get( 'zones' ), 'zone_id' ),
changes = {},
size = _.size( zones ),
newRow = _.extend( {}, data.default_zone, {
zone_id : 'new-' + size + '-' + Date.now(),
editing : true
} );
$( '.wc-shipping-zones-blank-state' ).closest( 'tr' ).remove();
newRow.zone_order = 1 + _.max(
_.pluck( zones, 'zone_order' ),
function ( val ) {
// Cast them all to integers, because strings compare funky. Sighhh.
return parseInt( val, 10 );
}
);
changes[ newRow.zone_id ] = newRow;
model.logChanges( changes );
view.renderRow( newRow );
view.initRows();
},
onTogglePostcodes: function( event ) {
event.preventDefault();
var $tr = $( this ).closest( 'tr');
$tr.find( '.wc-shipping-zone-postcodes' ).show();
$tr.find( '.wc-shipping-zone-postcodes-toggle' ).hide();
},
onEditRow: function( event ) {
event.preventDefault();
event.data.view.model.trigger( 'change:zones' );
$( this ).closest('tr').addClass( 'editing' );
$( this ).closest('tr').find('.view').hide();
$( this ).closest('tr').find('.edit').show();
$( '.wc-shipping-zone-region-select:not(.enhanced)' ).select2( select2_args );
$( '.wc-shipping-zone-region-select:not(.enhanced)' ).addClass('enhanced');
var addShippingMethod = $( this ).closest('tr').find('.add_shipping_method');
addShippingMethod.addClass( 'disabled' );
addShippingMethod.tipTip({ 'attribute': 'data-disabled-tip', 'fadeIn': 50, 'fadeOut': 50, 'delay': 50 });
},
onCancelEditRow: function( event ) {
var view = event.data.view,
model = view.model,
row = $( this ).closest('tr'),
zone_id = row.data('id'),
zones = _.indexBy( model.get( 'zones' ), 'zone_id' );
event.preventDefault();
model.discardChanges( zone_id );
if ( zones[ zone_id ] ) {
zones[ zone_id ].editing = false;
row.after( view.rowTemplate( zones[ zone_id ] ) );
view.initRow( zones[ zone_id ] );
}
row.remove();
view.initRows();
},
onDeleteRow: function( event ) {
var view = event.data.view,
model = view.model,
zones = _.indexBy( model.get( 'zones' ), 'zone_id' ),
changes = {},
row = $( this ).closest('tr'),
zone_id = $( this ).closest('tr').data('id');
zone_id = row.data('id');
event.preventDefault();
if ( zones[ zone_id ] ) {
delete zones[ zone_id ];
changes[ zone_id ] = _.extend( changes[ zone_id ] || {}, { deleted : 'deleted' } );
model.set( 'zones', zones );
model.logChanges( changes );
if ( window.confirm( data.strings.delete_confirmation_msg ) ) {
if ( zones[ zone_id ] ) {
delete zones[ zone_id ];
changes[ zone_id ] = _.extend( changes[ zone_id ] || {}, { deleted : 'deleted' } );
model.set( 'zones', zones );
model.logChanges( changes );
event.data.view.block();
event.data.view.model.save();
}
}
row.remove();
view.initRows();
},
setUnloadConfirmation: function() {
this.needsUnloadConfirm = true;
@ -373,45 +241,9 @@
if ( _.size( changes ) ) {
model.logChanges( changes );
event.data.view.block();
event.data.view.model.save();
}
},
onAddShippingMethod: function( event ) {
var zone_id = $( this ).closest('tr').data('id');
event.preventDefault();
$( this ).WCBackboneModal({
template : 'wc-modal-add-shipping-method',
variable : {
zone_id : zone_id
}
});
$( '.wc-shipping-zone-method-selector select' ).change();
},
onAddShippingMethodSubmitted: function( event, target, posted_data ) {
if ( 'wc-modal-add-shipping-method' === target ) {
shippingZoneView.block();
// Add method to zone via ajax call
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_add_method', {
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
method_id : posted_data.add_method_id,
zone_id : posted_data.zone_id
}, function( response, textStatus ) {
if ( 'success' === textStatus && response.success ) {
// Method was added. Render methods.
shippingZoneView.renderShippingMethods( posted_data.zone_id, response.data.methods );
}
shippingZoneView.unblock();
}, 'json' );
}
},
onChangeShippingMethodSelector: function() {
var description = $( this ).find( 'option:selected' ).data( 'description' );
$( this ).parent().find( '.wc-shipping-zone-method-description' ).remove();
$( this ).after( '<p class="wc-shipping-zone-method-description">' + description + '</p>' );
$( this ).closest( 'article' ).height( $( this ).parent().height() );
}
} ),
shippingZone = new ShippingZone({
@ -431,55 +263,5 @@
handle: 'td.wc-shipping-zone-sort',
scrollSensitivity: 40
});
function getEnhancedSelectFormatString() {
var formatString = {
formatMatches: function( matches ) {
if ( 1 === matches ) {
return wc_enhanced_select_params.i18n_matches_1;
}
return wc_enhanced_select_params.i18n_matches_n.replace( '%qty%', matches );
},
formatNoMatches: function() {
return wc_enhanced_select_params.i18n_no_matches;
},
formatAjaxError: function() {
return wc_enhanced_select_params.i18n_ajax_error;
},
formatInputTooShort: function( input, min ) {
var number = min - input.length;
if ( 1 === number ) {
return wc_enhanced_select_params.i18n_input_too_short_1;
}
return wc_enhanced_select_params.i18n_input_too_short_n.replace( '%qty%', number );
},
formatInputTooLong: function( input, max ) {
var number = input.length - max;
if ( 1 === number ) {
return wc_enhanced_select_params.i18n_input_too_long_1;
}
return wc_enhanced_select_params.i18n_input_too_long_n.replace( '%qty%', number );
},
formatSelectionTooBig: function( limit ) {
if ( 1 === limit ) {
return wc_enhanced_select_params.i18n_selection_too_long_1;
}
return wc_enhanced_select_params.i18n_selection_too_long_n.replace( '%qty%', limit );
},
formatLoadMore: function() {
return wc_enhanced_select_params.i18n_load_more;
},
formatSearching: function() {
return wc_enhanced_select_params.i18n_searching;
}
};
return formatString;
}
});
})( jQuery, shippingZonesLocalizeScript, wp, ajaxurl );

File diff suppressed because one or more lines are too long

View File

@ -332,18 +332,20 @@
// Loop through selects and disable/enable options based on selections
$form.find( '.variations select' ).each( function( index, el ) {
var current_attr_name, current_attr_select = $( el );
var current_attr_name, current_attr_select = $( el ),
show_option_none = $( el ).data( 'show_option_none' ),
option_gt_filter = 'no' === show_option_none ? '' : ':gt(0)';
// Reset options
if ( ! current_attr_select.data( 'attribute_options' ) ) {
current_attr_select.data( 'attribute_options', current_attr_select.find( 'option:gt(0)' ).get() );
current_attr_select.data( 'attribute_options', current_attr_select.find( 'option' + option_gt_filter ).get() );
}
current_attr_select.find( 'option:gt(0)' ).remove();
current_attr_select.find( 'option' + option_gt_filter ).remove();
current_attr_select.append( current_attr_select.data( 'attribute_options' ) );
current_attr_select.find( 'option:gt(0)' ).removeClass( 'attached' );
current_attr_select.find( 'option:gt(0)' ).removeClass( 'enabled' );
current_attr_select.find( 'option:gt(0)' ).removeAttr( 'disabled' );
current_attr_select.find( 'option' + option_gt_filter ).removeClass( 'attached' );
current_attr_select.find( 'option' + option_gt_filter ).removeClass( 'enabled' );
current_attr_select.find( 'option' + option_gt_filter ).removeAttr( 'disabled' );
// Get name from data-attribute_name, or from input name if it doesn't exist
if ( typeof( current_attr_select.data( 'attribute_name' ) ) !== 'undefined' ) {
@ -385,7 +387,7 @@
} else {
current_attr_select.find( 'option:gt(0)' ).addClass( 'attached ' + variation_active );
current_attr_select.find( 'option' + option_gt_filter ).addClass( 'attached ' + variation_active );
}
}
@ -395,10 +397,10 @@
}
// Detach unattached
current_attr_select.find( 'option:gt(0):not(.attached)' ).remove();
current_attr_select.find( 'option' + option_gt_filter + ':not(.attached)' ).remove();
// Grey out disabled
current_attr_select.find( 'option:gt(0):not(.enabled)' ).attr( 'disabled', 'disabled' );
current_attr_select.find( 'option' + option_gt_filter + ':not(.enabled)' ).attr( 'disabled', 'disabled' );
});

File diff suppressed because one or more lines are too long

View File

@ -112,6 +112,10 @@ class WC_Admin_Post_Types {
// Show blank state
add_action( 'manage_posts_extra_tablenav', array( $this, 'maybe_render_blank_state' ) );
// Hide template for CPT archive.
add_filter( 'theme_page_templates', array( $this, 'hide_cpt_archive_templates' ), 10, 3 );
add_action( 'edit_form_top', array( $this, 'show_cpt_archive_notice' ) );
}
/**
@ -2249,6 +2253,9 @@ class WC_Admin_Post_Types {
return $post_types;
}
/**
* Show blank slate.
*/
public function maybe_render_blank_state( $which ) {
global $post_type;
@ -2287,6 +2294,35 @@ class WC_Admin_Post_Types {
echo '<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .wrap .subsubsub { display: none; } </style></div>';
}
}
/**
* When editing the shop page, we should hide templates.
* @return array
*/
public function hide_cpt_archive_templates( $page_templates, $class, $post ) {
$shop_page_id = wc_get_page_id( 'shop' );
if ( $post && absint( $shop_page_id ) === absint( $post->ID ) ) {
$page_templates = array();
}
return $page_templates;
}
/**
* Show a notice above the CPT archive.
*/
public function show_cpt_archive_notice( $post ) {
$shop_page_id = wc_get_page_id( 'shop' );
if ( $post && absint( $shop_page_id ) === absint( $post->ID ) ) {
?>
<div class="notice notice-info">
<p><?php printf( __( 'This is the WooCommerce shop page. The shop page is a special archive that lists your products. %sYou can read more about this here%s.', 'woocommerce' ), '<a href="https://docs.woocommerce.com/document/woocommerce-pages/#section-4">', '</a>' ); ?></p>
</div>
<?php
}
}
}
endif;

View File

@ -261,12 +261,13 @@ class WC_Settings_Products extends WC_Settings_Page {
'id' => 'woocommerce_hold_stock_minutes',
'type' => 'number',
'custom_attributes' => array(
'min' => 0,
'step' => 1,
'min' => 0,
'step' => 1,
),
'css' => 'width: 80px;',
'default' => '60',
'autoload' => false,
'class' => 'manage_stock_field',
),
array(
@ -277,6 +278,7 @@ class WC_Settings_Products extends WC_Settings_Page {
'type' => 'checkbox',
'checkboxgroup' => 'start',
'autoload' => false,
'class' => 'manage_stock_field',
),
array(
@ -286,6 +288,7 @@ class WC_Settings_Products extends WC_Settings_Page {
'type' => 'checkbox',
'checkboxgroup' => 'end',
'autoload' => false,
'class' => 'manage_stock_field',
),
array(
@ -297,6 +300,7 @@ class WC_Settings_Products extends WC_Settings_Page {
'css' => 'width: 250px;',
'autoload' => false,
'desc_tip' => true,
'class' => 'manage_stock_field',
),
array(
@ -306,12 +310,13 @@ class WC_Settings_Products extends WC_Settings_Page {
'css' => 'width:50px;',
'type' => 'number',
'custom_attributes' => array(
'min' => 0,
'step' => 1,
'min' => 0,
'step' => 1,
),
'default' => '2',
'autoload' => false,
'desc_tip' => true,
'class' => 'manage_stock_field',
),
array(
@ -321,11 +326,12 @@ class WC_Settings_Products extends WC_Settings_Page {
'css' => 'width:50px;',
'type' => 'number',
'custom_attributes' => array(
'min' => 0,
'step' => 1,
'min' => 0,
'step' => 1,
),
'default' => '0',
'desc_tip' => true,
'class' => 'manage_stock_field',
),
array(

View File

@ -190,7 +190,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
if ( isset( $_REQUEST['zone_id'] ) ) {
$hide_save_button = true;
$this->zone_methods_screen( absint( $_REQUEST['zone_id'] ) );
$this->zone_methods_screen( wc_clean( $_REQUEST['zone_id'] ) );
} elseif ( isset( $_REQUEST['instance_id'] ) ) {
$this->instance_settings_screen( absint( $_REQUEST['instance_id'] ) );
} else {
@ -204,16 +204,37 @@ class WC_Settings_Shipping extends WC_Settings_Page {
* @param int $zone_id
*/
protected function zone_methods_screen( $zone_id ) {
$wc_shipping = WC_Shipping ::instance();
$zone = WC_Shipping_Zones::get_zone( $zone_id );
$shipping_methods = $wc_shipping->get_shipping_methods();
if ( 'new' === $zone_id ) {
$zone = new WC_Shipping_Zone();
$zone->set_zone_name( __( 'New Zone', 'woocommerce' ) );
} else {
$zone = WC_Shipping_Zones::get_zone( absint( $zone_id ) );
}
if ( ! $zone ) {
wp_die( __( 'Zone does not exist!', 'woocommerce' ) );
}
$allowed_countries = WC()->countries->get_allowed_countries();
$wc_shipping = WC_Shipping ::instance();
$shipping_methods = $wc_shipping->get_shipping_methods();
$continents = WC()->countries->get_continents();
// Prepare locations
$locations = array();
$postcodes = array();
foreach ( $zone->get_zone_locations() as $location ) {
if ( 'postcode' === $location->type ) {
$postcodes[] = $location->code;
} else {
$locations[] = $location->type . ':' . $location->code;
}
}
wp_localize_script( 'wc-shipping-zone-methods', 'shippingZoneMethodsLocalizeScript', array(
'methods' => $zone->get_shipping_methods(),
'zone_name' => $zone->get_zone_name(),
'zone_id' => $zone->get_zone_id(),
'wc_shipping_zones_nonce' => wp_create_nonce( 'wc_shipping_zones_nonce' ),
'strings' => array(
@ -250,6 +271,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
'wc_shipping_zones_nonce' => wp_create_nonce( 'wc_shipping_zones_nonce' ),
'strings' => array(
'unload_confirmation_msg' => __( 'Your changed data will be lost if you leave this page without saving.', 'woocommerce' ),
'delete_confirmation_msg' => __( 'Are you sure you want to delete this zone? This action cannot be undone.', 'woocommerce' ),
'save_failed' => __( 'Your changes were not saved. Please retry.', 'woocommerce' ),
'no_shipping_methods_offered' => __( 'No shipping methods offered to this zone.', 'woocommerce' ),
),

View File

@ -6,32 +6,90 @@ if ( ! defined( 'ABSPATH' ) ) {
<h2>
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=shipping' ); ?>"><?php _e( 'Shipping Zones', 'woocommerce' ); ?></a> &gt;
<?php echo esc_html( $zone->get_zone_name() ); ?>
<?php echo wc_help_tip( __( 'The following shipping methods apply to customers with shipping addresses within this zone.', 'woocommerce' ) ); ?>
<span class="wc-shipping-zone-name"><?php echo esc_html( $zone->get_zone_name() ); ?></span>
</h2>
<?php do_action( 'woocommerce_shipping_zone_before_methods_table' ); ?>
<table class="wc-shipping-zone-methods widefat">
<thead>
<tr>
<th class="wc-shipping-zone-method-sort"><?php echo wc_help_tip( __( 'Drag and drop to re-order your shipping methods. This is the order in which they will display during checkout.', 'woocommerce' ) ); ?></th>
<th class="wc-shipping-zone-method-title"><?php esc_html_e( 'Title', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-type"><?php esc_html_e( 'Type', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-description"><?php esc_html_e( 'Description', 'woocommerce' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<input type="submit" name="save" class="button button-primary wc-shipping-zone-method-save" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled />
<input type="submit" class="button button-secondary wc-shipping-zone-add-method" value="<?php esc_attr_e( 'Add shipping method', 'woocommerce' ); ?>" />
<table class="form-table wc-shipping-zone-settings">
<tbody>
<?php if ( 0 !== $zone->get_zone_id() ) : ?>
<tr valign="top" class="">
<th scope="row" class="titledesc">
<label for="zone_name"><?php esc_html_e( 'Zone Name', 'woocommerce' ); ?></label>
<?php echo wc_help_tip( __( 'This is the name of the zone for your reference.', 'woocommerce' ) ); ?>
</th>
<td class="forminp">
<input type="text" data-attribute="zone_name" name="zone_name" id="zone_name" value="<?php echo esc_attr( $zone->get_zone_name() ); ?>" placeholder="<?php _e( 'Zone Name', 'woocommerce' ); ?>">
</td>
</tr>
<tr valign="top" class="">
<th scope="row" class="titledesc">
<label for="zone_locations"><?php esc_html_e( 'Zone Region(s)', 'woocommerce' ); ?></label>
<?php echo wc_help_tip( __( 'These are regions inside this zone. Customers will be matched against these regions.', 'woocommerce' ) ); ?>
</th>
<td class="forminp">
<select multiple="multiple" data-attribute="zone_locations" id="zone_locations" name="zone_locations" data-placeholder="<?php _e( 'Select regions within this zone', 'woocommerce' ); ?>" class="wc-shipping-zone-region-select chosen_select">
<?php
foreach ( $continents as $continent_code => $continent ) {
echo '<option value="continent:' . esc_attr( $continent_code ) . '" ' . selected( in_array( "continent:$continent_code", $locations ), true, false ) . ' alt="">' . esc_html( $continent['name'] ) . '</option>';
$countries = array_intersect( array_keys( $allowed_countries ), $continent['countries'] );
foreach ( $countries as $country_code ) {
echo '<option value="country:' . esc_attr( $country_code ) . '" ' . selected( in_array( "country:$country_code", $locations ), true, false ) . ' alt="' . esc_attr( $continent['name'] ) . '">' . esc_html( '&nbsp;&nbsp; ' . $allowed_countries[ $country_code ] ) . '</option>';
if ( $states = WC()->countries->get_states( $country_code ) ) {
foreach ( $states as $state_code => $state_name ) {
echo '<option value="state:' . esc_attr( $country_code . ':' . $state_code ) . '" ' . selected( in_array( "state:$country_code:$state_code", $locations ), true, false ) . ' alt="' . esc_attr( $continent['name'] . ' ' . $allowed_countries[ $country_code ] ) . '">' . esc_html( '&nbsp;&nbsp;&nbsp;&nbsp; ' . $state_name ) . '</option>';
}
}
}
}
?>
</select>
<?php if ( empty( $postcodes ) ) : ?>
<a class="wc-shipping-zone-postcodes-toggle" href="#"><?php _e( 'Limit to specific ZIP/postcodes', 'woocommerce' ); ?></a>
<?php endif; ?>
<div class="wc-shipping-zone-postcodes">
<textarea name="zone_postcodes" data-attribute="zone_postcodes" id="zone_postcodes" placeholder="<?php esc_attr_e( 'List 1 postcode per line', 'woocommerce' ); ?>" class="input-text large-text" cols="25" rows="5"><?php echo esc_textarea( implode( "\n", $postcodes ) ); ?></textarea>
<span class="description"><?php _e( 'Postcodes containing wildcards (e.g. CB23*) and fully numeric ranges (e.g. <code>90210...99000</code>) are also supported.', 'woocommerce' ) ?></span>
</div>
</td>
</tr>
<?php endif; ?>
<tr valign="top" class="">
<th scope="row" class="titledesc">
<label><?php esc_html_e( 'Shipping Method(s)', 'woocommerce' ); ?></label>
<?php echo wc_help_tip( __( 'The following shipping methods apply to customers with shipping addresses within this zone.', 'woocommerce' ) ); ?>
</th>
<td class="">
<table class="wc-shipping-zone-methods widefat">
<thead>
<tr>
<th class="wc-shipping-zone-method-sort"><?php echo wc_help_tip( __( 'Drag and drop to re-order your shipping methods. This is the order in which they will display during checkout.', 'woocommerce' ) ); ?></th>
<th class="wc-shipping-zone-method-title"><?php esc_html_e( 'Title', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-type"><?php esc_html_e( 'Type', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-description"><?php esc_html_e( 'Description', 'woocommerce' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<input type="submit" class="button wc-shipping-zone-add-method" value="<?php esc_attr_e( 'Add shipping method', 'woocommerce' ); ?>" />
</td>
</tr>
</tfoot>
<tbody class="wc-shipping-zone-method-rows"></tbody>
</table>
</td>
</tr>
</tfoot>
<tbody class="wc-shipping-zone-method-rows"></tbody>
</tbody>
</table>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button button-primary button-hero wc-shipping-zone-method-save" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled />
</p>
<script type="text/html" id="tmpl-wc-shipping-zone-method-row-blank">
<tr>
@ -49,11 +107,11 @@ if ( ! defined( 'ABSPATH' ) ) {
<td class="wc-shipping-zone-method-title">
<a class="wc-shipping-zone-method-settings" href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}">{{ data.title }}</a>
<div class="row-actions">
<a class="wc-shipping-zone-method-settings" href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}"><?php _e( 'Settings', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-method-delete"><?php _e( 'Remove', 'woocommerce' ); ?></a>
<a class="wc-shipping-zone-method-settings" href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}"><?php _e( 'Edit', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-method-delete"><?php _e( 'Delete', 'woocommerce' ); ?></a>
</div>
</td>
<td width="1%" class="wc-shipping-zone-method-enabled"><a href="#">{{{ data.enabled_icon }}}</a></td>
<td class="wc-shipping-zone-method-type">{{ data.method_title }}</td>
<td width="1%" class="wc-shipping-zone-method-enabled"><a href="#">{{{ data.enabled_icon }}}</a></td>
<td class="wc-shipping-zone-method-description">{{ data.method_description }}</td>
</tr>
</script>

View File

@ -6,9 +6,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<h2>
<?php _e( 'Shipping Zones', 'woocommerce' ); ?>
<?php echo wc_help_tip( __( 'A shipping zone is a geographic region where a certain set of shipping methods and rates apply.', 'woocommerce' ) . ' ' . __( 'WooCommerce will automatically choose the correct shipping zone based on your customer&lsquo;s shipping address and present the shipping methods within that zone to them.', 'woocommerce' ) ); ?>
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=new' ); ?>" class="page-title-action"><?php esc_html_e( 'Add shipping zone', 'woocommerce' ); ?></a>
</h2>
<p><?php echo __( 'A shipping zone is a geographic region where a certain set of shipping methods are offered.', 'woocommerce' ) . ' ' . __( 'WooCommerce will match a customer to a single zone using their shipping address and present the shipping methods within that zone to them.', 'woocommerce' ); ?></p>
<table class="wc-shipping-zones widefat">
<thead>
<tr>
@ -18,14 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) {
<th class="wc-shipping-zone-methods"><?php esc_html_e( 'Shipping Method(s)', 'woocommerce' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<input type="submit" name="save" class="button button-primary wc-shipping-zone-save" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled />
<a class="button button-secondary wc-shipping-zone-add" href="#"><?php esc_html_e( 'Add shipping zone', 'woocommerce' ); ?></a>
</td>
</tr>
</tfoot>
<tbody class="wc-shipping-zone-rows"></tbody>
<tbody>
<tr data-id="0">
@ -33,13 +25,12 @@ if ( ! defined( 'ABSPATH' ) ) {
<td class="wc-shipping-zone-name">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=0' ) ); ?>"><?php esc_html_e( 'Rest of the World', 'woocommerce' ); ?></a>
<div class="row-actions">
<a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}"><?php _e( 'View', 'woocommerce' ); ?></a>
<a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}"><?php _e( 'Edit', 'woocommerce' ); ?></a>
</div>
</td>
<td class="wc-shipping-zone-region"><?php esc_html_e( 'This zone is used for shipping addresses that aren&lsquo;t included in any other shipping zone. Adding shipping methods to this zone is optional.', 'woocommerce' ); ?></td>
<td class="wc-shipping-zone-region"><?php _e( 'This zone is <b>optionally</b> used for regions that are not included in any other shipping zone.', 'woocommerce' ); ?></td>
<td class="wc-shipping-zone-methods">
<ul>
<li class="wc-shipping-zone-methods-add-row"><a href="#" class="add_shipping_method tips" data-tip="<?php esc_attr_e( 'Add shipping method', 'woocommerce' ); ?>" data-disabled-tip="<?php esc_attr_e( 'Save changes to continue adding shipping methods to this zone', 'woocommerce' ); ?>"><?php _e( 'Add shipping method', 'woocommerce' ); ?></a></li>
<?php
$worldwide = new WC_Shipping_Zone( 0 );
$methods = $worldwide->get_shipping_methods();
@ -48,7 +39,7 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! empty( $methods ) ) {
foreach ( $methods as $method ) {
$class_name = 'yes' === $method->enabled ? 'method_enabled' : 'method_disabled';
echo '<li class="wc-shipping-zone-method"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' . absint( $method->instance_id ) . '" class="' . esc_attr( $class_name ) . '">' . esc_html( $method->get_title() ) . '</a></li>';
echo '<li class="wc-shipping-zone-method ' . esc_attr( $class_name ) . '">' . esc_html( $method->get_title() ) . '</li>';
}
} else {
echo '<li class="wc-shipping-zone-method">' . __( 'No shipping methods offered to this zone.', 'woocommerce' ) . '</li>';
@ -82,54 +73,16 @@ if ( ! defined( 'ABSPATH' ) ) {
<tr data-id="{{ data.zone_id }}">
<td width="1%" class="wc-shipping-zone-sort"></td>
<td class="wc-shipping-zone-name">
<div class="view">
<a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}">{{ data.zone_name }}</a>
<div class="row-actions">
<a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}"><?php _e( 'View', 'woocommerce' ); ?></a> | <a class="wc-shipping-zone-edit" href="#"><?php _e( 'Edit', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-delete"><?php _e( 'Remove', 'woocommerce' ); ?></a>
</div>
</div>
<div class="edit">
<input type="text" name="zone_name[{{ data.zone_id }}]" data-attribute="zone_name" value="{{ data.zone_name }}" placeholder="<?php esc_attr_e( 'Zone Name', 'woocommerce' ); ?>" />
<div class="row-actions">
<a class="wc-shipping-zone-cancel-edit" href="#"><?php _e( 'Cancel changes', 'woocommerce' ); ?></a>
</div>
<a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}">{{ data.zone_name }}</a>
<div class="row-actions">
<a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}"><?php _e( 'Edit', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-delete"><?php _e( 'Delete', 'woocommerce' ); ?></a>
</div>
</td>
<td class="wc-shipping-zone-region">
<div class="view">{{ data.formatted_zone_location }}</div>
<div class="edit">
<select multiple="multiple" name="zone_locations[{{ data.zone_id }}]" data-attribute="zone_locations" data-placeholder="<?php _e( 'Select regions within this zone', 'woocommerce' ); ?>" class="wc-shipping-zone-region-select">
<?php
foreach ( $continents as $continent_code => $continent ) {
echo '<option value="continent:' . esc_attr( $continent_code ) . '" alt="">' . esc_html( $continent['name'] ) . '</option>';
$countries = array_intersect( array_keys( $allowed_countries ), $continent['countries'] );
foreach ( $countries as $country_code ) {
echo '<option value="country:' . esc_attr( $country_code ) . '" alt="' . esc_attr( $continent['name'] ) . '">' . esc_html( '&nbsp;&nbsp; ' . $allowed_countries[ $country_code ] ) . '</option>';
if ( $states = WC()->countries->get_states( $country_code ) ) {
foreach ( $states as $state_code => $state_name ) {
echo '<option value="state:' . esc_attr( $country_code . ':' . $state_code ) . '" alt="' . esc_attr( $continent['name'] . ' ' . $allowed_countries[ $country_code ] ) . '">' . esc_html( '&nbsp;&nbsp;&nbsp;&nbsp; ' . $state_name ) . '</option>';
}
}
}
}
?>
</select>
<a class="wc-shipping-zone-postcodes-toggle" href="#"><?php _e( 'Limit to specific ZIP/postcodes', 'woocommerce' ); ?></a>
<div class="wc-shipping-zone-postcodes">
<textarea name="zone_postcodes[{{ data.zone_id }}]" data-attribute="zone_postcodes" placeholder="<?php esc_attr_e( 'List 1 postcode per line', 'woocommerce' ); ?>" class="input-text large-text" cols="25" rows="5"></textarea>
<span class="description"><?php _e( 'Postcodes containing wildcards (e.g. CB23*) and fully numeric ranges (e.g. <code>90210...99000</code>) are also supported.', 'woocommerce' ) ?></span>
</div>
</div>
{{ data.formatted_zone_location }}
</td>
<td class="wc-shipping-zone-methods">
<div>
<ul>
<li class="wc-shipping-zone-methods-add-row"><a href="#" class="add_shipping_method tips" data-tip="<?php esc_attr_e( 'Add shipping method', 'woocommerce' ); ?>" data-disabled-tip="<?php esc_attr_e( 'Save changes to continue adding shipping methods to this zone', 'woocommerce' ); ?>"><?php _e( 'Add shipping method', 'woocommerce' ); ?></a></li>
</ul>
</div>
<div><ul></ul></div>
</td>
</tr>
</script>

View File

@ -350,17 +350,19 @@ class WC_REST_Product_Attributes_Controller extends WC_REST_Controller {
}
}
$update = $wpdb->update(
$wpdb->prefix . 'woocommerce_attribute_taxonomies',
$args,
array( 'attribute_id' => $id ),
$format,
array( '%d' )
);
if ( $args ) {
$update = $wpdb->update(
$wpdb->prefix . 'woocommerce_attribute_taxonomies',
$args,
array( 'attribute_id' => $id ),
$format,
array( '%d' )
);
// Checks for errors.
if ( false === $update ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Could not edit the attribute.', 'woocommerce' ), array( 'status' => 400 ) );
// Checks for errors.
if ( false === $update ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Could not edit the attribute.', 'woocommerce' ), array( 'status' => 400 ) );
}
}
$attribute = $this->get_attribute( $id );

View File

@ -2875,51 +2875,16 @@ class WC_AJAX {
$zone_data = array_intersect_key( $data, array(
'zone_id' => 1,
'zone_name' => 1,
'zone_order' => 1,
'zone_locations' => 1,
'zone_postcodes' => 1,
) );
if ( isset( $zone_data['zone_id'] ) ) {
$zone = new WC_Shipping_Zone( $zone_data['zone_id'] );
if ( isset( $zone_data['zone_name'] ) ) {
$zone->set_zone_name( $zone_data['zone_name'] );
}
if ( isset( $zone_data['zone_order'] ) ) {
$zone->set_zone_order( $zone_data['zone_order'] );
}
if ( isset( $zone_data['zone_locations'] ) ) {
$zone->clear_locations( array( 'state', 'country', 'continent' ) );
$locations = array_filter( array_map( 'wc_clean', (array) $zone_data['zone_locations'] ) );
foreach ( $locations as $location ) {
// Each posted location will be in the format type:code
$location_parts = explode( ':', $location );
switch ( $location_parts[0] ) {
case 'state' :
$zone->add_location( $location_parts[1] . ':' . $location_parts[2], 'state' );
break;
case 'country' :
$zone->add_location( $location_parts[1], 'country' );
break;
case 'continent' :
$zone->add_location( $location_parts[1], 'continent' );
break;
}
}
}
if ( isset( $zone_data['zone_postcodes'] ) ) {
$zone->clear_locations( 'postcode' );
$postcodes = array_filter( array_map( 'strtoupper', array_map( 'wc_clean', explode( "\n", $zone_data['zone_postcodes'] ) ) ) );
foreach ( $postcodes as $postcode ) {
$zone->add_location( $postcode, 'postcode' );
}
}
$zone->save();
}
}
@ -2949,13 +2914,14 @@ class WC_AJAX {
exit;
}
$zone_id = absint( $_POST['zone_id'] );
$zone = WC_Shipping_Zones::get_zone( $zone_id );
$zone_id = wc_clean( $_POST['zone_id'] );
$zone = new WC_Shipping_Zone( $zone_id );
$instance_id = $zone->add_shipping_method( wc_clean( $_POST['method_id'] ) );
wp_send_json_success( array(
'instance_id' => $instance_id,
'zone_id' => $zone_id,
'zone_id' => $zone->get_zone_id(),
'zone_name' => $zone->get_zone_name(),
'methods' => $zone->get_shipping_methods(),
) );
}
@ -2981,42 +2947,80 @@ class WC_AJAX {
global $wpdb;
$zone_id = absint( $_POST['zone_id'] );
$zone_id = wc_clean( $_POST['zone_id'] );
$zone = new WC_Shipping_Zone( $zone_id );
$changes = $_POST['changes'];
foreach ( $changes as $instance_id => $data ) {
$method_id = $wpdb->get_var( $wpdb->prepare( "SELECT method_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE instance_id = %d", $instance_id ) );
if ( isset( $changes['zone_name'] ) ) {
$zone->set_zone_name( wc_clean( $changes['zone_name'] ) );
}
if ( isset( $data['deleted'] ) ) {
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
$option_key = $shipping_method->get_instance_option_key();
if ( $wpdb->delete( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'instance_id' => $instance_id ) ) ) {
delete_option( $option_key );
do_action( 'woocommerce_shipping_zone_method_deleted', $instance_id, $method_id, $zone_id );
}
continue;
}
$method_data = array_intersect_key( $data, array(
'method_order' => 1,
'enabled' => 1,
) );
if ( isset( $method_data['method_order'] ) ) {
$wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'method_order' => absint( $method_data['method_order'] ) ), array( 'instance_id' => absint( $instance_id ) ) );
}
if ( isset( $method_data['enabled'] ) ) {
$is_enabled = absint( 'yes' === $method_data['enabled'] );
if ( $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'is_enabled' => $is_enabled ), array( 'instance_id' => absint( $instance_id ) ) ) ) {
do_action( 'woocommerce_shipping_zone_method_status_toggled', $instance_id, $method_id, $zone_id, $is_enabled );
if ( isset( $changes['zone_locations'] ) ) {
$zone->clear_locations( array( 'state', 'country', 'continent' ) );
$locations = array_filter( array_map( 'wc_clean', (array) $changes['zone_locations'] ) );
foreach ( $locations as $location ) {
// Each posted location will be in the format type:code
$location_parts = explode( ':', $location );
switch ( $location_parts[0] ) {
case 'state' :
$zone->add_location( $location_parts[1] . ':' . $location_parts[2], 'state' );
break;
case 'country' :
$zone->add_location( $location_parts[1], 'country' );
break;
case 'continent' :
$zone->add_location( $location_parts[1], 'continent' );
break;
}
}
}
if ( isset( $changes['zone_postcodes'] ) ) {
$zone->clear_locations( 'postcode' );
$postcodes = array_filter( array_map( 'strtoupper', array_map( 'wc_clean', explode( "\n", $changes['zone_postcodes'] ) ) ) );
foreach ( $postcodes as $postcode ) {
$zone->add_location( $postcode, 'postcode' );
}
}
if ( isset( $changes['methods'] ) ) {
foreach ( $changes['methods'] as $instance_id => $data ) {
$method_id = $wpdb->get_var( $wpdb->prepare( "SELECT method_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE instance_id = %d", $instance_id ) );
if ( isset( $data['deleted'] ) ) {
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
$option_key = $shipping_method->get_instance_option_key();
if ( $wpdb->delete( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'instance_id' => $instance_id ) ) ) {
delete_option( $option_key );
do_action( 'woocommerce_shipping_zone_method_deleted', $instance_id, $method_id, $zone_id );
}
continue;
}
$method_data = array_intersect_key( $data, array(
'method_order' => 1,
'enabled' => 1,
) );
if ( isset( $method_data['method_order'] ) ) {
$wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'method_order' => absint( $method_data['method_order'] ) ), array( 'instance_id' => absint( $instance_id ) ) );
}
if ( isset( $method_data['enabled'] ) ) {
$is_enabled = absint( 'yes' === $method_data['enabled'] );
if ( $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'is_enabled' => $is_enabled ), array( 'instance_id' => absint( $instance_id ) ) ) ) {
do_action( 'woocommerce_shipping_zone_method_status_toggled', $instance_id, $method_id, $zone_id, $is_enabled );
}
}
}
}
$zone->save();
wp_send_json_success( array(
'methods' => $zone->get_shipping_methods(),
'zone_id' => $zone->get_zone_id(),
'zone_name' => $zone->get_zone_name(),
'methods' => $zone->get_shipping_methods(),
) );
}
@ -3046,8 +3050,10 @@ class WC_AJAX {
$shipping_method->process_admin_options();
wp_send_json_success( array(
'methods' => $zone->get_shipping_methods(),
'errors' => $shipping_method->get_errors(),
'zone_id' => $zone->get_zone_id(),
'zone_name' => $zone->get_zone_name(),
'methods' => $zone->get_shipping_methods(),
'errors' => $shipping_method->get_errors(),
) );
}

View File

@ -548,6 +548,7 @@ class WC_Countries {
'required' => true,
'class' => array( 'form-row-first' ),
'autocomplete' => 'given-name',
'autofocus' => true,
),
'last_name' => array(
'label' => __( 'Last Name', 'woocommerce' ),

View File

@ -45,7 +45,7 @@ class WC_Shipping_Zone extends WC_Data {
$this->set_zone_name( $zone->zone_name );
$this->set_zone_order( $zone->zone_order );
$this->read_zone_locations( $zone->zone_id );
} elseif ( 0 === $zone ) {
} elseif ( 0 === $zone || "0" === $zone ) {
$this->set_id( 0 );
$this->set_zone_name( __( 'Rest of the World', 'woocommerce' ) );
$this->read_zone_locations( 0 );
@ -455,7 +455,7 @@ class WC_Shipping_Zone extends WC_Data {
global $wpdb;
if ( null === $this->get_id() ) {
return 0;
$this->save();
}
$instance_id = 0;

View File

@ -161,9 +161,9 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
$total = WC()->cart->get_displayed_subtotal();
if ( 'incl' === WC()->cart->tax_display_cart ) {
$total = $total - ( WC()->cart->get_cart_discount_total() + WC()->cart->get_cart_discount_tax_total() );
$total = round( $total - ( WC()->cart->get_cart_discount_total() + WC()->cart->get_cart_discount_tax_total() ), wc_get_price_decimals() );
} else {
$total = $total - WC()->cart->get_cart_discount_total();
$total = round( $total - WC()->cart->get_cart_discount_total(), wc_get_price_decimals() );
}
if ( $total >= $this->min_amount ) {

View File

@ -736,3 +736,18 @@ function wc_get_product_attachment_props( $attachment_id, $product = false ) {
}
return $props;
}
/**
* Get product visibility options.
*
* @since 2.7.0
* @return array
*/
function wc_get_product_visibility_options() {
return apply_filters( 'woocommerce_product_visibility_options', array(
'visible' => __( 'Catalog/search', 'woocommerce' ),
'catalog' => __( 'Catalog', 'woocommerce' ),
'search' => __( 'Search', 'woocommerce' ),
'hidden' => __( 'Hidden', 'woocommerce' ),
) );
}

View File

@ -1862,6 +1862,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
'custom_attributes' => array(),
'validate' => array(),
'default' => '',
'autofocus' => '',
);
$args = wp_parse_args( $args, $defaults );
@ -1874,10 +1875,6 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$required = '';
}
$args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
$args['autocomplete'] = ( $args['autocomplete'] ) ? 'autocomplete="' . esc_attr( $args['autocomplete'] ) . '"' : '';
if ( is_string( $args['label_class'] ) ) {
$args['label_class'] = array( $args['label_class'] );
}
@ -1887,7 +1884,20 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
}
// Custom attribute handling
$custom_attributes = array();
$custom_attributes = array();
$args['custom_attributes'] = array_filter( (array) $args['custom_attributes'] );
if ( $args['maxlength'] ) {
$args['custom_attributes']['maxlength'] = absint( $args['maxlength'] );
}
if ( true === $args['autocomplete'] ) {
$args['custom_attributes']['autocomplete'] = 'true';
}
if ( true === $args['autofocus'] ) {
$args['custom_attributes']['autofocus'] = 'autofocus';
}
if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
@ -1918,7 +1928,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
} else {
$field = '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . $args['autocomplete'] . ' class="country_to_state country_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . '>' . '<option value="">' . __( 'Select a country&hellip;', 'woocommerce' ) . '</option>';
$field = '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="country_to_state country_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . '>' . '<option value="">' . __( 'Select a country&hellip;', 'woocommerce' ) . '</option>';
foreach ( $countries as $ckey => $cvalue ) {
$field .= '<option value="' . esc_attr( $ckey ) . '" ' . selected( $value, $ckey, false ) . '>' . $cvalue . '</option>';
@ -1946,7 +1956,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
} elseif ( is_array( $states ) ) {
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="state_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . ' data-placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['autocomplete'] . '>
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="state_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . ' data-placeholder="' . esc_attr( $args['placeholder'] ) . '">
<option value="">' . __( 'Select a state&hellip;', 'woocommerce' ) . '</option>';
foreach ( $states as $ckey => $cvalue ) {
@ -1957,14 +1967,14 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
} else {
$field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['autocomplete'] . ' name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
$field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
}
break;
case 'textarea' :
$field .= '<textarea name="' . esc_attr( $key ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['maxlength'] . ' ' . $args['autocomplete'] . ' ' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="2"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="5"' : '' ) . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $value ) . '</textarea>';
$field .= '<textarea name="' . esc_attr( $key ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="2"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="5"' : '' ) . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $value ) . '</textarea>';
break;
case 'checkbox' :
@ -1980,7 +1990,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
case 'tel' :
case 'number' :
$field .= '<input type="' . esc_attr( $args['type'] ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['maxlength'] . ' ' . $args['autocomplete'] . ' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
$field .= '<input type="' . esc_attr( $args['type'] ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
break;
case 'select' :
@ -1999,7 +2009,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$options .= '<option value="' . esc_attr( $option_key ) . '" ' . selected( $value, $option_key, false ) . '>' . esc_attr( $option_text ) . '</option>';
}
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . ' data-placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['autocomplete'] . '>
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . ' data-placeholder="' . esc_attr( $args['placeholder'] ) . '">
' . $options . '
</select>';
}
@ -2150,21 +2160,22 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
'show_option_none' => __( 'Choose an option', 'woocommerce' ),
) );
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class'];
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class'];
$show_option_none = $args['show_option_none'] ? true : false;
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
$attributes = $product->get_variation_attributes();
$options = $attributes[ $attribute ];
}
$html = '<select id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '" name="' . esc_attr( $name ) . '" data-attribute_name="attribute_' . esc_attr( sanitize_title( $attribute ) ) . '">';
$html = '<select id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '" name="' . esc_attr( $name ) . '" data-attribute_name="attribute_' . esc_attr( sanitize_title( $attribute ) ) . '"' . '" data-show_option_none="' . ( $show_option_none ? 'yes' : 'no' ) . '">';
if ( $args['show_option_none'] ) {
if ( $show_option_none ) {
$html .= '<option value="">' . esc_html( $args['show_option_none'] ) . '</option>';
}

View File

@ -468,7 +468,7 @@ function wc_get_customer_available_downloads( $customer_id ) {
}
}
return $downloads;
return apply_filters( 'woocommerce_customer_available_downloads', $downloads, $customer_id );
}
/**

View File

@ -448,16 +448,18 @@ class WC_Widget_Layered_Nav extends WC_Widget {
}
}
if ( $count > 0 || $option_is_set ) {
$link = esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) );
$term_html = '<a href="' . $link . '">' . esc_html( $term->name ) . '</a>';
} else {
$link = false;
$term_html = '<span>' . esc_html( $term->name ) . '</span>';
}
$term_html .= ' ' . apply_filters( 'woocommerce_layered_nav_count', '<span class="count">(' . absint( $count ) . ')</span>', $count, $term );
echo '<li class="wc-layered-nav-term ' . ( $option_is_set ? 'chosen' : '' ) . '">';
echo ( $count > 0 || $option_is_set ) ? '<a href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span>';
echo esc_html( $term->name );
echo ( $count > 0 || $option_is_set ) ? '</a> ' : '</span> ';
echo apply_filters( 'woocommerce_layered_nav_count', '<span class="count">(' . absint( $count ) . ')</span>', $count, $term );
echo wp_kses_post( apply_filters( 'woocommerce_layered_nav_term_html', $term_html, $term, $link, $count ) );
echo '</li>';
}

View File

@ -180,6 +180,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woocommerce/wo
* Add reply-to to admin emails.
* When deleting a tax rate class, remove it's tax rates.
* Made the store notice dismissible.
* Improved the zone setup flow.
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt).