Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Justin Silver 2016-03-15 13:51:49 -07:00
commit ef3a5b97ef
54 changed files with 690 additions and 336 deletions

View File

@ -1,3 +1,19 @@
<!--
PLEASE NOTE:
- These comments won't show up when you submit the issue.
- Try to add as much detail as possible. Be specific!
- GitHub issues ARE NOT FOR SUPPORT! If you have questions, use the either:
- https://wordpress.org/support/plugin/woocommerce for general support
- https://support.woothemes.com for premium plugin support
- If you're requesting a new feature, explain why you'd like it to be added.
- Search this repository (top of the page) for the issue and it has not been fixed or reported already.
And before logging BUGS, ensure you:
- Use the latest stable release of WooCommerce.
- Disabled all plugins to ensure it's a core bug and not a plugin issue.
- Switched to Twenty Twelve theme to ensure it's a core bug and not a theme issue.
-->
## EXPLANATION OF THE ISSUE
What happens, under which versions, under what conditions, when, and what were you expecting instead.
@ -11,19 +27,3 @@ What happens, under which versions, under what conditions, when, and what were y
```
Grab the system status report from WooCommerce > System Status and paste it here.
```
<!--
PLEASE NOTE:
- These comments won't show up when you submit the issue.
- Try to add as much detail as possible. Be specific!
- GitHub issues aren't for support! If you have questions, use the either:
- https://wordpress.org/support/plugin/woocommerce for general support
- https://support.woothemes.com for premium plugin support
- If you're requesting a new feature, explain why you'd like it to be added.
- Search this repository (top of the page) for the issue and it has not been fixed or reported already.
And before logging BUGS, ensure you:
- Use the latest stable release of WooCommerce.
- Disabled all plugins to ensure it's a core bug and not a plugin issue.
- Switched to Twenty Twelve theme to ensure it's a core bug and not a theme issue.
-->

View File

@ -1 +1 @@
.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#cc99c2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);border-color:#b366a4;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);color:#fff;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:hover{background:#bb77ae;border-color:#aa559a;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15)}.woocommerce-message a.button-primary:active,p.woocommerce-actions a.button-primary:active{background:#aa559a;border-color:#aa559a}.woocommerce-message a.docs,.woocommerce-message a.skip,p.woocommerce-actions a.docs,p.woocommerce-actions a.skip{opacity:.5}.woocommerce-message a.docs:focus,.woocommerce-message a.docs:hover,.woocommerce-message a.skip:focus,.woocommerce-message a.skip:hover,p.woocommerce-actions a.docs:focus,p.woocommerce-actions a.docs:hover,p.woocommerce-actions a.skip:focus,p.woocommerce-actions a.skip:hover{opacity:1}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}
.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#cc99c2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);border-color:#b366a4;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);color:#fff;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:hover{background:#bb77ae;border-color:#aa559a;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15)}.woocommerce-message a.button-primary:active,p.woocommerce-actions a.button-primary:active{background:#aa559a;border-color:#aa559a}.woocommerce-message a.docs,.woocommerce-message a.skip,p.woocommerce-actions a.docs,p.woocommerce-actions a.skip{opacity:.5}.woocommerce-message a.docs:focus,.woocommerce-message a.docs:hover,.woocommerce-message a.skip:focus,.woocommerce-message a.skip:hover,p.woocommerce-actions a.docs:focus,p.woocommerce-actions a.docs:hover,p.woocommerce-actions a.skip:focus,p.woocommerce-actions a.skip:hover{opacity:1}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:10px;right:10px;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close:before,p.woocommerce-actions a.woocommerce-message-close:before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice:before{content:"\f319";font-family:dashicons;text-align:center;line-height:1;color:#F7F1F6;display:block;width:1em;font-size:20em;top:0;right:0;position:absolute}

View File

@ -49,6 +49,23 @@ p.woocommerce-actions,
}
}
a.woocommerce-message-close {
position: absolute;
top: 10px;
right: 10px;
padding: 10px 15px 10px 21px;
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
&:before {
position: absolute;
top: 8px;
left: 0;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
}
a.button-primary,
a.button-secondary {
text-decoration: none !important;
@ -65,3 +82,32 @@ p.woocommerce-actions,
.woocommerce-about-text {
margin-bottom: 1em !important;
}
div.woocommerce-legacy-shipping-notice {
overflow: hidden;
padding: 1px 12px;
p {
position: relative;
z-index: 1;
max-width: 700px;
line-height: 1.5em;
margin: 12px 0;
&.main {
font-size: 1.1em;
}
}
&:before {
content: "\f319";
font-family: 'dashicons';
text-align: center;
line-height: 1;
color: #F7F1F6;
display: block;
width: 1em;
font-size: 20em;
top: 0;
right: 0;
position: absolute;
}
}

File diff suppressed because one or more lines are too long

View File

@ -149,6 +149,23 @@
text-decoration: none !important;
}
a.woocommerce-message-close {
position: absolute;
top: 10px;
right: 10px;
padding: 10px 15px 10px 21px;
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
&:before {
position: absolute;
top: 8px;
left: 0;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
}
.twitter-share-button {
margin-top: -3px;
margin-left: 3px;
@ -156,6 +173,36 @@
}
}
div.woocommerce-legacy-shipping-notice {
overflow: hidden;
padding: 1px 12px;
p {
position: relative;
z-index: 1;
max-width: 700px;
line-height: 1.5em;
margin: 12px 0;
&.main {
font-size: 1.1em;
}
}
&:before {
content: "\f319";
font-family: 'dashicons';
text-align: center;
line-height: 1;
color: #F7F1F6;
display: block;
width: 1em;
font-size: 20em;
top: 0;
right: 0;
position: absolute;
}
}
#variable_product_options #message, #variable_product_options .notice {
margin: 10px;
}
@ -2134,7 +2181,6 @@ table.wc_shipping {
}
}
}
table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-classes {
td, th {
vertical-align: top;
@ -2259,6 +2305,12 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
line-height: inherit;
}
}
.status-disabled {
display: inline-block;
&:before {
line-height: inherit;
}
}
}
.wc-shipping-zone-name,
.wc-shipping-zone-methods {
@ -2403,7 +2455,8 @@ img.help_tip {
}
.status-enabled,
.status-manual {
.status-manual,
.status-disabled {
font-size: 1.4em;
@include ir();
}
@ -2422,6 +2475,13 @@ img.help_tip {
}
}
.status-disabled {
&:before {
@include icon( "\e013" );
color: #ccc;
}
}
.woocommerce {
.woo-nav-tab-wrapper {
margin: 1.5em 0 1em !important;

View File

@ -175,7 +175,7 @@ jQuery(function( $ ) {
var the_series = window.main_chart.getData();
var series = [];
csv_data += xaxes_label + ',';
csv_data += '"' + xaxes_label + '",';
$.each( the_series, function( index, value ) {
if ( ! exclude_series || $.inArray( index.toString(), exclude_series ) === -1 ) {
@ -185,7 +185,7 @@ jQuery(function( $ ) {
// CSV Headers
for ( s = 0; s < series.length; ++s ) {
csv_data += series[s].label + ',';
csv_data += '"' + series[s].label + '",';
}
csv_data = csv_data.substring( 0, csv_data.length - 1 );
@ -218,9 +218,9 @@ jQuery(function( $ ) {
var date = new Date( parseInt( index, 10 ) );
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 {
csv_data += date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + ',';
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
}
for ( var d = 0; d < value.length; ++d ) {
@ -231,7 +231,7 @@ jQuery(function( $ ) {
val = val.toFixed( 2 );
}
csv_data += val + ',';
csv_data += '"' + val + '",';
}
csv_data = csv_data.substring( 0, csv_data.length - 1 );
csv_data += '\n';

View File

@ -1 +1 @@
jQuery(function(a){function b(b,c,d){a('<div class="chart-tooltip">'+d+"</div>").css({top:c-16,left:b+20}).appendTo("body").fadeIn(200)}var c=null,d=null;a(".chart-placeholder").bind("plothover",function(e,f,g){if(g){if((c!==g.dataIndex||d!==g.seriesIndex)&&(c=g.dataIndex,d=g.seriesIndex,a(".chart-tooltip").remove(),g.series.points.show||g.series.enable_tooltip)){var h=g.series.data[g.dataIndex][1],i="";g.series.prepend_label&&(i=i+g.series.label+": "),g.series.prepend_tooltip&&(i+=g.series.prepend_tooltip),i+=h,g.series.append_tooltip&&(i+=g.series.append_tooltip),g.series.pie.show?b(f.pageX,f.pageY,i):b(g.pageX,g.pageY,i)}}else a(".chart-tooltip").remove(),c=null}),a(".wc_sparkline.bars").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),bars:{fillColor:a(this).data("color"),fill:!0,show:!0,lineWidth:1,barWidth:a(this).data("barwidth"),align:"center"},shadowSize:0}];a.plot(a(this),d,c)}),a(".wc_sparkline.lines").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),lines:{fill:!1,show:!0,lineWidth:1,align:"center"},shadowSize:0}];a.plot(a(this),d,c)});var e=a(".range_datepicker").datepicker({changeMonth:!0,changeYear:!0,defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,maxDate:"+0D",showButtonPanel:!0,showOn:"focus",buttonImageOnly:!0,onSelect:function(b){var c=a(this).is(".from")?"minDate":"maxDate",d=a(this).data("datepicker"),f=a.datepicker.parseDate(d.settings.dateFormat||a.datepicker._defaults.dateFormat,b,d.settings);e.not(this).datepicker("option",c,f)}}),f=document.createElement("a");"undefined"==typeof f.download&&a(".export_csv").hide(),a(".export_csv").click(function(){var b=a(this).data("exclude_series")||"";b=b.toString(),b=b.split(",");var c,d,e,f=a(this).data("xaxes"),g=a(this).data("groupby"),h=a(this).data("export"),i="data:application/csv;charset=utf-8,";if("table"===h)a(this).closest("div").find("thead tr,tbody tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();b=b.replace("[?]",""),i+='"'+b+'",'}),i=i.substring(0,i.length-1),i+="\n"}),a(this).closest("div").find("tfoot tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();if(b=b.replace("[?]",""),i+='"'+b+'",',a(this).attr("colspan")>0)for(m=1;m<a(this).attr("colspan");m++)i+='"",'}),i=i.substring(0,i.length-1),i+="\n"});else{if(!window.main_chart)return!1;var j=window.main_chart.getData(),k=[];for(i+=f+",",a.each(j,function(c,d){b&&-1!==a.inArray(c.toString(),b)||k.push(d)}),c=0;c<k.length;++c)i+=k[c].label+",";i=i.substring(0,i.length-1),i+="\n";var l={};for(c=0;c<k.length;++c)for(d=k[c].data,e=0;e<d.length;++e){l[d[e][0]]=[];for(var m=0;m<k.length;++m)l[d[e][0]].push(0)}for(c=0;c<k.length;++c)for(d=k[c].data,e=0;e<d.length;++e)l[d[e][0]][c]=d[e][1];a.each(l,function(a,b){var c=new Date(parseInt(a,10));i+="day"===g?c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+"-"+c.getUTCDate()+",":c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+",";for(var d=0;d<b.length;++d){var e=b[d];Math.round(e)!==e&&(e=parseFloat(e),e=e.toFixed(2)),i+=e+","}i=i.substring(0,i.length-1),i+="\n"})}return a(this).attr("href",encodeURI(i)),!0})});
jQuery(function(a){function b(b,c,d){a('<div class="chart-tooltip">'+d+"</div>").css({top:c-16,left:b+20}).appendTo("body").fadeIn(200)}var c=null,d=null;a(".chart-placeholder").bind("plothover",function(e,f,g){if(g){if((c!==g.dataIndex||d!==g.seriesIndex)&&(c=g.dataIndex,d=g.seriesIndex,a(".chart-tooltip").remove(),g.series.points.show||g.series.enable_tooltip)){var h=g.series.data[g.dataIndex][1],i="";g.series.prepend_label&&(i=i+g.series.label+": "),g.series.prepend_tooltip&&(i+=g.series.prepend_tooltip),i+=h,g.series.append_tooltip&&(i+=g.series.append_tooltip),g.series.pie.show?b(f.pageX,f.pageY,i):b(g.pageX,g.pageY,i)}}else a(".chart-tooltip").remove(),c=null}),a(".wc_sparkline.bars").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),bars:{fillColor:a(this).data("color"),fill:!0,show:!0,lineWidth:1,barWidth:a(this).data("barwidth"),align:"center"},shadowSize:0}];a.plot(a(this),d,c)}),a(".wc_sparkline.lines").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),lines:{fill:!1,show:!0,lineWidth:1,align:"center"},shadowSize:0}];a.plot(a(this),d,c)});var e=a(".range_datepicker").datepicker({changeMonth:!0,changeYear:!0,defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,maxDate:"+0D",showButtonPanel:!0,showOn:"focus",buttonImageOnly:!0,onSelect:function(b){var c=a(this).is(".from")?"minDate":"maxDate",d=a(this).data("datepicker"),f=a.datepicker.parseDate(d.settings.dateFormat||a.datepicker._defaults.dateFormat,b,d.settings);e.not(this).datepicker("option",c,f)}}),f=document.createElement("a");"undefined"==typeof f.download&&a(".export_csv").hide(),a(".export_csv").click(function(){var b=a(this).data("exclude_series")||"";b=b.toString(),b=b.split(",");var c,d,e,f=a(this).data("xaxes"),g=a(this).data("groupby"),h=a(this).data("export"),i="data:application/csv;charset=utf-8,";if("table"===h)a(this).closest("div").find("thead tr,tbody tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();b=b.replace("[?]",""),i+='"'+b+'",'}),i=i.substring(0,i.length-1),i+="\n"}),a(this).closest("div").find("tfoot tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();if(b=b.replace("[?]",""),i+='"'+b+'",',a(this).attr("colspan")>0)for(m=1;m<a(this).attr("colspan");m++)i+='"",'}),i=i.substring(0,i.length-1),i+="\n"});else{if(!window.main_chart)return!1;var j=window.main_chart.getData(),k=[];for(i+='"'+f+'",',a.each(j,function(c,d){b&&-1!==a.inArray(c.toString(),b)||k.push(d)}),c=0;c<k.length;++c)i+='"'+k[c].label+'",';i=i.substring(0,i.length-1),i+="\n";var l={};for(c=0;c<k.length;++c)for(d=k[c].data,e=0;e<d.length;++e){l[d[e][0]]=[];for(var m=0;m<k.length;++m)l[d[e][0]].push(0)}for(c=0;c<k.length;++c)for(d=k[c].data,e=0;e<d.length;++e)l[d[e][0]][c]=d[e][1];a.each(l,function(a,b){var c=new Date(parseInt(a,10));i+="day"===g?'"'+c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+"-"+c.getUTCDate()+'",':'"'+c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+'",';for(var d=0;d<b.length;++d){var e=b[d];Math.round(e)!==e&&(e=parseFloat(e),e=e.toFixed(2)),i+='"'+e+'",'}i=i.substring(0,i.length-1),i+="\n"})}return a(this).attr("href",encodeURI(i)),!0})});

View File

@ -109,9 +109,9 @@
// Populate $tbody with the current methods
$.each( methods, function( id, rowData ) {
if ( 'yes' === rowData.enabled ) {
rowData.enabled_icon = '<span class="status-enabled tips" data-tip="' + data.strings.yes + '">' + data.strings.yes + '</span>';
rowData.enabled_icon = '<span class="status-enabled">' + data.strings.yes + '</span>';
} else {
rowData.enabled_icon = '&ndash;';
rowData.enabled_icon = '<span class="status-disabled">' + data.strings.no + '</span>';
}
view.$el.append( view.rowTemplate( rowData ) );
@ -126,6 +126,7 @@
// Make the rows function
this.$el.find( '.wc-shipping-zone-method-delete' ).on( 'click', { view: this }, this.onDeleteRow );
this.$el.find( '.wc-shipping-zone-method-enabled a').on( 'click', { view: this }, this.onToggleEnabled );
} else {
view.$el.append( $blank_template );
}
@ -162,6 +163,23 @@
model.logChanges( changes );
view.render();
},
onToggleEnabled: function( event ) {
var view = event.data.view,
$target = $( event.target ),
model = view.model,
methods = _.indexBy( model.get( 'methods' ), 'instance_id' ),
instance_id = $target.closest( 'tr' ).data( 'id' ),
enabled = $target.closest( 'tr' ).data( 'enabled' ) === 'yes' ? 'no' : 'yes',
changes = {},
new_enabled = 'yes';
event.preventDefault();
methods[ instance_id ].enabled = enabled;
changes[ instance_id ] = _.extend( changes[ instance_id ] || {}, { enabled : enabled } );
model.set( 'methods', methods );
model.logChanges( changes );
view.render();
},
setUnloadConfirmation: function() {
this.needsUnloadConfirm = true;
$save_button.removeAttr( 'disabled' );

File diff suppressed because one or more lines are too long

View File

@ -8,10 +8,13 @@ jQuery( function( $ ) {
/* Storage Handling */
var $supports_html5_storage;
try {
$supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null );
window.sessionStorage.setItem( 'wc', 'test' );
window.sessionStorage.removeItem( 'wc' );
window.localStorage.setItem( 'wc', 'test' );
window.localStorage.removeItem( 'wc' );
} catch( err ) {
$supports_html5_storage = false;
}

View File

@ -1 +1 @@
jQuery(function(a){function b(){e&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(a){e&&(localStorage.setItem("wc_cart_hash",a),sessionStorage.setItem("wc_cart_hash",a))}function d(){a.ajax(g)}if("undefined"==typeof wc_cart_fragments_params)return!1;var e;try{e="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc")}catch(f){e=!1}var g={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(d){d&&d.fragments&&(a.each(d.fragments,function(b,c){a(b).replaceWith(c)}),e&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d.fragments)),c(d.cart_hash),d.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(e){var h=null,i=864e5;a(document.body).bind("added_to_cart",function(a,d,e){var f=sessionStorage.getItem("wc_cart_hash");null!==f&&void 0!==f&&""!==f||b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d)),c(e)}),a(document.body).bind("wc_fragments_refreshed",function(){clearTimeout(h),h=setTimeout(d,i)}),a(window).on("storage onstorage",function(b){"wc_cart_hash"===b.originalEvent.key&&localStorage.getItem("wc_cart_hash")!==sessionStorage.getItem("wc_cart_hash")&&a.ajax(g)});try{var j=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),k=sessionStorage.getItem("wc_cart_hash"),l=a.cookie("woocommerce_cart_hash"),m=sessionStorage.getItem("wc_cart_created");if(null!==k&&void 0!==k&&""!==k||(k=""),null!==l&&void 0!==l&&""!==l||(l=""),k&&(null===m||void 0===m||""===m))throw"No cart_created";if(m){var n=1*m+i,o=(new Date).getTime();if(o>n)throw"Fragment expired";h=setTimeout(d,n-o)}if(!j||!j["div.widget_shopping_cart_content"]||k!==l)throw"No fragment";a.each(j,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(f){d()}}else d();a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});
jQuery(function(a){function b(){e&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(a){e&&(localStorage.setItem("wc_cart_hash",a),sessionStorage.setItem("wc_cart_hash",a))}function d(){a.ajax(g)}if("undefined"==typeof wc_cart_fragments_params)return!1;var e;try{e="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(f){e=!1}var g={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(d){d&&d.fragments&&(a.each(d.fragments,function(b,c){a(b).replaceWith(c)}),e&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d.fragments)),c(d.cart_hash),d.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(e){var h=null,i=864e5;a(document.body).bind("added_to_cart",function(a,d,e){var f=sessionStorage.getItem("wc_cart_hash");null!==f&&void 0!==f&&""!==f||b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d)),c(e)}),a(document.body).bind("wc_fragments_refreshed",function(){clearTimeout(h),h=setTimeout(d,i)}),a(window).on("storage onstorage",function(b){"wc_cart_hash"===b.originalEvent.key&&localStorage.getItem("wc_cart_hash")!==sessionStorage.getItem("wc_cart_hash")&&a.ajax(g)});try{var j=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),k=sessionStorage.getItem("wc_cart_hash"),l=a.cookie("woocommerce_cart_hash"),m=sessionStorage.getItem("wc_cart_created");if(null!==k&&void 0!==k&&""!==k||(k=""),null!==l&&void 0!==l&&""!==l||(l=""),k&&(null===m||void 0===m||""===m))throw"No cart_created";if(m){var n=1*m+i,o=(new Date).getTime();if(o>n)throw"Fragment expired";h=setTimeout(d,n-o)}if(!j||!j["div.widget_shopping_cart_content"]||k!==l)throw"No fragment";a.each(j,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(f){d()}}else d();a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});

View File

@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WooCommerce 2.6.0-dev\n"
"Report-Msgid-Bugs-To: https://github.com/woothemes/woocommerce/issues\n"
"POT-Creation-Date: 2016-03-11 17:39:25+00:00\n"
"POT-Creation-Date: 2016-03-14 12:26:03+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -5949,7 +5949,7 @@ msgstr ""
#: includes/admin/settings/class-wc-settings-api.php:45
#: includes/admin/settings/views/html-admin-page-shipping-zone-methods.php:61
#: includes/admin/views/html-admin-page-status-report.php:429
#: includes/class-wc-install.php:799
#: includes/class-wc-install.php:775
msgid "Settings"
msgstr ""
@ -9397,7 +9397,7 @@ msgstr ""
#: includes/admin/reports/class-wc-report-customer-list.php:27
#: includes/admin/settings/class-wc-settings-emails.php:260
#: includes/class-wc-install.php:570
#: includes/class-wc-install.php:546
msgid "Customer"
msgstr ""
@ -13590,43 +13590,38 @@ msgid ""
"class=\"wc-backward\">Return to homepage</a>"
msgstr ""
#: includes/class-wc-checkout.php:449 includes/class-wc-form-handler.php:85
#: includes/class-wc-form-handler.php:185
msgid "is a required field."
msgstr ""
#: includes/class-wc-checkout.php:462 includes/class-wc-form-handler.php:98
#: includes/class-wc-checkout.php:473 includes/class-wc-form-handler.php:98
#: includes/shortcodes/class-wc-shortcode-cart.php:27
msgid "Please enter a valid postcode/ZIP."
msgstr ""
#: includes/class-wc-checkout.php:471 includes/class-wc-form-handler.php:107
#: includes/class-wc-checkout.php:482 includes/class-wc-form-handler.php:107
msgid "is not a valid phone number."
msgstr ""
#: includes/class-wc-checkout.php:477 includes/class-wc-form-handler.php:114
#: includes/class-wc-checkout.php:488 includes/class-wc-form-handler.php:114
msgid "is not a valid email address."
msgstr ""
#: includes/class-wc-checkout.php:495
#: includes/class-wc-checkout.php:506
msgid "is not valid. Please enter one of the following:"
msgstr ""
#: includes/class-wc-checkout.php:551 includes/class-wc-form-handler.php:297
#: includes/class-wc-checkout.php:562 includes/class-wc-form-handler.php:297
msgid "You must accept our Terms &amp; Conditions."
msgstr ""
#: includes/class-wc-checkout.php:557
#: includes/class-wc-checkout.php:568
msgid ""
"Unfortunately <strong>we do not ship %s</strong>. Please enter an "
"alternative shipping address."
msgstr ""
#: includes/class-wc-checkout.php:566
#: includes/class-wc-checkout.php:577
msgid "Invalid shipping method."
msgstr ""
#: includes/class-wc-checkout.php:578 includes/class-wc-form-handler.php:307
#: includes/class-wc-checkout.php:589 includes/class-wc-form-handler.php:307
msgid "Invalid payment method."
msgstr ""
@ -13908,6 +13903,10 @@ msgstr ""
msgid "Read More"
msgstr ""
#: includes/class-wc-form-handler.php:85 includes/class-wc-form-handler.php:185
msgid "is a required field."
msgstr ""
#: includes/class-wc-form-handler.php:129
msgid "Address changed successfully."
msgstr ""
@ -14091,40 +14090,40 @@ msgstr ""
msgid "Monthly"
msgstr ""
#: includes/class-wc-install.php:575
#: includes/class-wc-install.php:551
msgid "Shop Manager"
msgstr ""
#: includes/class-wc-install.php:799
#: includes/class-wc-install.php:775
msgid "View WooCommerce Settings"
msgstr ""
#: includes/class-wc-install.php:815
#: includes/class-wc-install.php:791
msgid "View WooCommerce Documentation"
msgstr ""
#: includes/class-wc-install.php:815
#: includes/class-wc-install.php:791
msgid "Docs"
msgstr ""
#: includes/class-wc-install.php:816
#: includes/class-wc-install.php:792
msgid "View WooCommerce API Docs"
msgstr ""
#: includes/class-wc-install.php:816
#: includes/class-wc-install.php:792
msgid "API Docs"
msgstr ""
#: includes/class-wc-install.php:817
#: includes/class-wc-install.php:793
msgid "Visit Premium Customer Support Forum"
msgstr ""
#: includes/class-wc-install.php:817
#: includes/class-wc-install.php:793
msgid "Premium Support"
msgstr ""
#: includes/class-wc-order.php:46
msgid "(Includes %s)"
#: includes/class-wc-order.php:46 includes/wc-cart-functions.php:281
msgid "(includes %s)"
msgstr ""
#: includes/class-wc-post-types.php:66
@ -16306,10 +16305,6 @@ msgstr ""
msgid "estimated for %s"
msgstr ""
#: includes/wc-cart-functions.php:281
msgid "(includes %s)"
msgstr ""
#: includes/wc-core-functions.php:83
msgid "Order &ndash; %s"
msgstr ""
@ -18134,6 +18129,21 @@ msgctxt "WC Pages links in the System Status"
msgid "Edit %s page"
msgstr ""
#: includes/class-wc-checkout.php:451
msgctxt "Shipping FIELDNAME"
msgid "Shipping %s"
msgstr ""
#: includes/class-wc-checkout.php:454
msgctxt "Billing FIELDNAME"
msgid "Billing %s"
msgstr ""
#: includes/class-wc-checkout.php:460
msgctxt "FIELDNAME is a required field."
msgid "%s is a required field."
msgstr ""
#: includes/class-wc-install.php:242
msgctxt "Page slug"
msgid "shop"

View File

@ -252,13 +252,15 @@ abstract class WC_Abstract_Order {
* @return int|bool Item ID or false.
*/
public function add_product( $product, $qty = 1, $args = array() ) {
$default_args = array(
$args = wp_parse_args( $args, array(
'variation' => array(),
'totals' => array()
);
) );
if ( ! $product ) {
return false;
}
$args = wp_parse_args( $args, $default_args );
$item_id = wc_add_order_item( $this->id, array(
'order_item_name' => $product->get_title(),
'order_item_type' => 'line_item'

View File

@ -202,6 +202,11 @@ if ( ! defined( 'ABSPATH' ) ) {
update_metadata( 'payment_token', $this->get_id(), $meta_key, $meta_value );
}
// Make sure all other tokens are not set to default
if ( $this->is_default() && $this->get_user_id() > 0 ) {
WC_Payment_Tokens::set_users_default( $this->get_user_id(), $this->get_id() );
}
do_action( 'woocommerce_payment_token_updated', $this->get_id() );
return true;
}
@ -217,10 +222,9 @@ if ( ! defined( 'ABSPATH' ) ) {
}
global $wpdb;
// Are there any other tokens? If not, set this token as default
if ( ! $this->is_default() && is_user_logged_in() ) {
$default_token = WC_Payment_Tokens::get_customer_default_token( get_current_user_id() );
if ( ! $this->is_default() && $this->get_user_id() > 0 ) {
$default_token = WC_Payment_Tokens::get_customer_default_token( $this->get_user_id() );
if ( is_null( $default_token ) ) {
$this->set_default( true );
}
@ -232,6 +236,11 @@ if ( ! defined( 'ABSPATH' ) ) {
add_metadata( 'payment_token', $token_id, $meta_key, $meta_value, true );
}
// Make sure all other tokens are not set to default
if ( $this->is_default() && $this->get_user_id() > 0 ) {
WC_Payment_Tokens::set_users_default( $this->get_user_id(), $token_id );
}
do_action( 'woocommerce_payment_token_created', $token_id );
return true;
}

View File

@ -25,7 +25,8 @@ class WC_Admin_Notices {
'install' => 'install_notice',
'update' => 'update_notice',
'template_files' => 'template_file_check_notice',
'theme_support' => 'theme_check_notice'
'theme_support' => 'theme_check_notice',
'legacy_shipping' => 'legacy_shipping_notice',
);
/**
@ -182,6 +183,27 @@ class WC_Admin_Notices {
self::remove_notice( 'template_files' );
}
}
/**
* Show a notice asking users to convert to shipping zones.
*/
public function legacy_shipping_notice() {
$maybe_load_legacy_methods = array( 'flat_rate', 'free_shipping', 'international_delivery', 'local_delivery', 'local_pickup' );
$enabled = false;
foreach ( $maybe_load_legacy_methods as $method ) {
$options = get_option( 'woocommerce_' . $method . '_settings' );
if ( $options && isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
$enabled = true;
}
}
if ( $enabled ) {
include( 'views/html-notice-legacy-shipping.php' );
} else {
self::remove_notice( 'template_files' );
}
}
}
new WC_Admin_Notices();

View File

@ -416,18 +416,24 @@ class WC_Meta_Box_Order_Data {
WC()->payment_gateways();
WC()->shipping();
$customer_changed = false;
// Add key
add_post_meta( $post_id, '_order_key', uniqid( 'order_' ), true );
// Update meta
update_post_meta( $post_id, '_customer_user', absint( $_POST['customer_user'] ) );
if ( update_post_meta( $post_id, '_customer_user', absint( $_POST['customer_user'] ) ) ) {
$customer_changed = true;
}
if ( ! empty( self::$billing_fields ) ) {
foreach ( self::$billing_fields as $key => $field ) {
if ( ! isset( $field['id'] ) ){
$field['id'] = '_billing_' . $key;
}
update_post_meta( $post_id, $field['id'], wc_clean( $_POST[ $field['id'] ] ) );
if ( update_post_meta( $post_id, $field['id'], wc_clean( $_POST[ $field['id'] ] ) ) ) {
$customer_changed = true;
}
}
}
@ -436,7 +442,9 @@ class WC_Meta_Box_Order_Data {
if ( ! isset( $field['id'] ) ){
$field['id'] = '_shipping_' . $key;
}
update_post_meta( $post_id, $field['id'], wc_clean( $_POST[ $field['id'] ] ) );
if ( update_post_meta( $post_id, $field['id'], wc_clean( $_POST[ $field['id'] ] ) ) ) {
$customer_changed = true;
}
}
}
@ -470,6 +478,26 @@ class WC_Meta_Box_Order_Data {
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date( $date ), $post_id ) );
// If customer changed, update any downloadable permissions
if ( $customer_changed ) {
$wpdb->update( $wpdb->prefix . "woocommerce_downloadable_product_permissions",
array(
'user_id' => absint( get_post_meta( $post->ID, '_customer_user', true ) ),
'user_email' => wc_clean( get_post_meta( $post->ID, '_billing_email', true ) ),
),
array(
'order_id' => $post_id,
),
array(
'%d',
'%s',
),
array(
'%d',
)
);
}
// Order data saved, now get it so we can manipulate status
$order = wc_get_order( $post_id );

View File

@ -95,8 +95,6 @@ class WC_Meta_Box_Order_Downloads {
$access_expires = $_POST['access_expires'];
// Order data
$customer_email = get_post_meta( $post->ID, '_billing_email', true );
$customer_user = get_post_meta( $post->ID, '_customer_user', true );
$product_ids_max = max( array_keys( $product_ids ) );
for ( $i = 0; $i <= $product_ids_max; $i ++ ) {
@ -106,12 +104,12 @@ class WC_Meta_Box_Order_Downloads {
}
$data = array(
'user_id' => absint( $customer_user ),
'user_email' => wc_clean( $customer_email ),
'downloads_remaining' => wc_clean( $downloads_remaining[ $i ] )
'downloads_remaining' => wc_clean( $downloads_remaining[ $i ] ),
);
$format = array( '%d', '%s', '%s' );
$format = array(
'%s',
);
$expiry = ( array_key_exists( $i, $access_expires ) && '' != $access_expires[ $i ] ) ? date_i18n( 'Y-m-d', strtotime( $access_expires[ $i ] ) ) : null;

View File

@ -125,24 +125,14 @@ class WC_Report_Customer_List extends WP_List_Table {
case 'last_order' :
$order_ids = get_posts( array(
'posts_per_page' => 1,
'post_type' => 'shop_order',
'orderby' => 'date',
'order' => 'desc',
'post_status' => array( 'wc-completed', 'wc-processing' ),
'meta_query' => array(
array(
'key' => '_customer_user',
'value' => $user->ID
)
),
'fields' => 'ids'
$orders = wc_get_orders( array(
'limit' => 1,
'status' => array( 'wc-completed', 'wc-processing' ),
'customer' => $user->ID
) );
if ( $order_ids ) {
$order = wc_get_order( $order_ids[0] );
if ( ! empty( $orders ) ) {
$order = $orders[0];
return '<a href="' . admin_url( 'post.php?post=' . $order->id . '&action=edit' ) . '">' . _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number() . '</a> &ndash; ' . date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) );
} else {
return '-';
@ -176,25 +166,13 @@ class WC_Report_Customer_List extends WP_List_Table {
'action' => "view"
);
$order_ids = get_posts( array(
'posts_per_page' => 1,
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ),
'meta_query' => array(
array(
'key' => '_customer_user',
'value' => array( 0, '' ),
'compare' => 'IN'
),
array(
'key' => '_billing_email',
'value' => $user->user_email
)
),
'fields' => 'ids'
$orders = wc_get_orders( array(
'limit' => 1,
'status' => array( 'wc-completed', 'wc-processing' ),
'customer' => array( array( 0, $user->user_email ) ),
) );
if ( $order_ids ) {
if ( $orders ) {
$actions['link'] = array(
'url' => wp_nonce_url( add_query_arg( 'link_orders', $user->ID ), 'link_orders' ),
'name' => __( 'Link previous orders', 'woocommerce' ),

View File

@ -145,7 +145,6 @@ class WC_Settings_Shipping extends WC_Settings_Page {
}
// Default to zones screen
$hide_save_button = true;
$this->output_zones_screen();
}
@ -181,11 +180,15 @@ class WC_Settings_Shipping extends WC_Settings_Page {
* Handles output of the shipping zones page in admin.
*/
protected function output_zones_screen() {
global $hide_save_button;
if ( isset( $_REQUEST['zone_id'] ) ) {
$hide_save_button = true;
$this->zone_methods_screen( absint( $_REQUEST['zone_id'] ) );
} elseif ( isset( $_REQUEST['instance_id'] ) ) {
$this->instance_settings_screen( absint( $_REQUEST['instance_id'] ) );
} else {
$hide_save_button = true;
$this->zones_screen();
}
}
@ -212,6 +215,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
'save_failed' => __( 'Your changes were not saved. Please retry.', 'woocommerce' ),
'add_method_failed' => __( 'Shipping method could not be added. Please retry.', 'woocommerce' ),
'yes' => __( 'Yes', 'woocommerce' ),
'no' => __( 'No', 'woocommerce' ),
),
) );
wp_enqueue_script( 'wc-shipping-zone-methods' );
@ -264,9 +268,9 @@ class WC_Settings_Shipping extends WC_Settings_Page {
wp_die( __( 'This shipping method does not have any settings to configure.', 'woocommerce' ) );
}
if ( ! empty( $_POST['save_method'] ) ) {
if ( ! empty( $_POST['save'] ) ) {
if ( empty( $_POST['woocommerce_save_method_nonce'] ) || ! wp_verify_nonce( $_POST['woocommerce_save_method_nonce'], 'woocommerce_save_method' )) {
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-settings' ) ) {
echo '<div class="updated error"><p>' . __( 'Edit failed. Please try again.', 'woocommerce' ) . '</p></div>';
}

View File

@ -51,11 +51,11 @@ if ( ! defined( 'ABSPATH' ) ) {
</script>
<script type="text/html" id="tmpl-wc-shipping-zone-method-row">
<tr data-id="{{ data.instance_id }}">
<tr data-id="{{ data.instance_id }}" data-enabled="{{ data.enabled }}">
<td width="1%" class="wc-shipping-zone-method-sort"></td>
<td class="wc-shipping-zone-method-title"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}">{{ data.title }}</a></td>
<td class="wc-shipping-zone-method-type">{{ data.method_title }}</td>
<td class="wc-shipping-zone-method-enabled">{{{ data.enabled_icon }}}</td>
<td class="wc-shipping-zone-method-enabled"><a href="#">{{{ data.enabled_icon }}}</a></td>
<td class="wc-shipping-zone-method-description">{{ data.method_description }}</td>
<td class="wc-shipping-zone-method-actions">
<a class="wc-shipping-zone-method-delete tips" data-tip="<?php esc_attr_e( 'Delete', 'woocommerce' ); ?>" href="#"><?php _e( 'Delete', 'woocommerce' ); ?></a><a class="wc-shipping-zone-method-settings tips" data-tip="<?php esc_attr_e( 'Settings', 'woocommerce' ); ?>" href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}"><?php _e( 'Settings', 'woocommerce' ); ?></a>

View File

@ -3,10 +3,5 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h2><?php echo esc_html( $shipping_method->get_method_title() ); ?> <?php wc_back_link( __( 'Return to Shipping Methods', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=' . absint( $zone->get_zone_id() ) ) ); ?></h2>
<?php $shipping_method->admin_options(); ?>
<?php if ( ! isset( $GLOBALS['hide_save_button'] ) ) : ?>
<p class="submit"><input type="submit" class="button button-primary" name="save_method" value="<?php _e( 'Save changes', 'woocommerce' ); ?>" /></p>
<?php endif; ?>
<?php wp_nonce_field( 'woocommerce_save_method', 'woocommerce_save_method_nonce' ); ?>

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
<h2><?php _e( 'Shipping Zones', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'Shipping Zones let you group regions with similar Shipping Methods and rates. 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' ) ); ?></h2>
<h2><?php _e( 'Shipping Zones', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'Shipping Zones let you group regions with similar Shipping Methods and rates.', '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' ) ); ?></h2>
<table class="wc-shipping-zones widefat">
<thead>

View File

@ -14,7 +14,6 @@ if ( ! defined( 'ABSPATH' ) ) {
foreach ( $tabs as $name => $label ) {
echo '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
}
do_action( 'woocommerce_settings_tabs' );
?>
</nav>
@ -28,10 +27,9 @@ if ( ! defined( 'ABSPATH' ) ) {
do_action( 'woocommerce_settings_tabs_' . $current_tab ); // @deprecated hook
?>
<p class="submit">
<?php if ( ! isset( $GLOBALS['hide_save_button'] ) ) : ?>
<input name="save" class="button-primary" type="submit" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" />
<?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?>
<input name="save" class="button-primary woocommerce-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" />
<?php endif; ?>
<input type="hidden" name="subtab" id="last_tab" />
<?php wp_nonce_field( 'woocommerce-settings' ); ?>
</p>
</form>

View File

@ -0,0 +1,23 @@
<?php
/**
* Admin View: Notice - Legacy Shipping.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div id="message" class="updated woocommerce-message woocommerce-legacy-shipping-notice">
<a class="woocommerce-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'legacy_shipping' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'woocommerce' ); ?></a>
<p class="main"><strong><?php _e( 'New Feature: Shipping Zones!', 'woocommerce' ); ?></strong></p>
<p><?php _e( 'Shipping Zones let you group regions with similar Shipping Methods and rates.', 'woocommerce' ); ?></p>
<p><?php _e( 'Legacy shipping methods (Flat Rate, International, Local Pickup and Delivery and Free Shipping) are deprecated and <em>will be removed in future versions of WooCommerce</em>, but will continue to function as normal for now. We recommend disabling these shipping methods and instead setting up new rates within Shipping Zones as soon as possible.', 'woocommerce' ); ?></p>
<p class="submit">
<?php if ( empty( $_GET['page'] ) || empty( $_GET['tab'] ) || 'wc-settings' !== $_GET['page'] || 'shipping' !== $_GET['tab'] ) : ?>
<a class="button-primary" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping' ) ); ?>"><?php _e( 'Setup Shipping Zones', 'woocommerce' ); ?></a>
<?php endif; ?>
<a class="button-secondary" href="<?php echo esc_url( 'https://docs.woothemes.com/document/setting-up-shipping-zones/' ); ?>"><?php _e( 'Lean more about Shipping Zones', 'woocommerce' ); ?></a>
</p>
</div>

View File

@ -1510,15 +1510,12 @@ class WC_API_Orders extends WC_API_Resource {
return $order_id;
}
$refund_items = get_posts(
array(
'post_type' => 'shop_order_refund',
'post_parent' => $order_id,
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids'
)
);
$refund_items = wc_get_orders( array(
'type' => 'shop_order_refund',
'parent' => $order_id,
'limit' => -1,
'return' => 'ids',
) );
$order_refunds = array();
foreach ( $refund_items as $refund_id ) {
@ -1551,7 +1548,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID', 'woocommerce' ), 400 );
}
$order = wc_get_order( $id );
$order = wc_get_order( $order_id );
$refund = wc_get_order( $id );
if ( ! $refund ) {

View File

@ -1466,15 +1466,12 @@ class WC_API_Orders extends WC_API_Resource {
return $order_id;
}
$refund_items = get_posts(
array(
'post_type' => 'shop_order_refund',
'post_parent' => $order_id,
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids'
)
);
$refund_items = wc_get_orders( array(
'type' => 'shop_order_refund',
'parent' => $order_id,
'limit' => -1,
'return' => 'ids',
) );
$order_refunds = array();
foreach ( $refund_items as $refund_id ) {
@ -1507,7 +1504,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID', 'woocommerce' ), 400 );
}
$order = wc_get_order( $id );
$order = wc_get_order( $order_id );
$refund = wc_get_order( $id );
if ( ! $refund ) {

View File

@ -3218,12 +3218,17 @@ class WC_AJAX {
}
$method_data = array_intersect_key( $data, array(
'method_order' => 1
'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'] ) ) {
$wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'is_enabled' => absint( 'yes' === $method_data['enabled'] ) ), array( 'instance_id' => absint( $instance_id ) ) );
}
}
wp_send_json_success( array(

View File

@ -446,7 +446,18 @@ class WC_Checkout {
// Validation: Required fields
if ( isset( $field['required'] ) && $field['required'] && empty( $this->posted[ $key ] ) ) {
wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is a required field.', 'woocommerce' ), 'error' );
switch ( $fieldset_key ) {
case 'shipping' :
$field_label = sprintf( _x( 'Shipping %s', 'Shipping FIELDNAME', 'woocommerce' ), $field['label'] );
break;
case 'billing' :
$field_label = sprintf( _x( 'Billing %s', 'Billing FIELDNAME', 'woocommerce' ), $field['label'] );
break;
default :
$field_label = $field['label'];
break;
}
wc_add_notice( sprintf( _x( '%s is a required field.', 'FIELDNAME is a required field.', 'woocommerce' ), '<strong>' . $field_label . '</strong>' ), 'error' );
}
if ( ! empty( $this->posted[ $key ] ) ) {

View File

@ -979,7 +979,7 @@ class WC_Countries {
$address_fields[ $type . $key ] = $value;
// Add email and phone after company or last
if ( $type == 'billing_' && ( 'company' === $key || ( ! array_key_exists( 'company', $fields ) && $key === end( $keys ) ) ) ) {
if ( 'billing_' === $type && ( 'company' === $key || ( ! array_key_exists( 'company', $fields ) && $key === end( $keys ) ) ) ) {
$address_fields['billing_email'] = array(
'label' => __( 'Email Address', 'woocommerce' ),
'required' => true,

View File

@ -487,6 +487,7 @@ CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_methods (
instance_id bigint(20) NOT NULL auto_increment,
method_id varchar(255) NOT NULL,
method_order bigint(20) NOT NULL,
is_enabled tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (instance_id)
) $collate;
CREATE TABLE {$wpdb->prefix}woocommerce_payment_tokens (

View File

@ -43,7 +43,7 @@ class WC_Order extends WC_Abstract_Order {
$tax_string_array[] = sprintf( '%s %s', wc_price( $tax_amount, array( 'currency' => $this->get_order_currency() ) ), WC()->countries->tax_or_vat() );
}
if ( ! empty( $tax_string_array ) ) {
$tax_string = ' ' . sprintf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) );
$tax_string = ' ' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) );
}
}
@ -63,22 +63,11 @@ class WC_Order extends WC_Abstract_Order {
*/
public function get_refunds() {
if ( empty( $this->refunds ) && ! is_array( $this->refunds ) ) {
$refunds = array();
$refund_items = get_posts(
array(
'post_type' => 'shop_order_refund',
'post_parent' => $this->id,
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids'
)
);
foreach ( $refund_items as $refund_id ) {
$refunds[] = new WC_Order_Refund( $refund_id );
}
$this->refunds = $refunds;
$this->refunds = wc_get_orders( array(
'type' => 'shop_order_refund',
'parent' => $this->id,
'limit' => -1,
) );
}
return $this->refunds;
}

View File

@ -169,14 +169,24 @@ class WC_Payment_Tokens {
* @param int $token_id The ID of the token that should be default
*/
public static function set_users_default( $user_id, $token_id ) {
global $wpdb; // DB queries so we avoid an infinite loop (update & create use this function)
$users_tokens = self::get_customer_tokens( $user_id );
foreach ( $users_tokens as $token ) {
if ( $token_id === $token->get_id() ) {
$token->set_default( true );
$wpdb->update(
$wpdb->prefix . 'woocommerce_payment_tokens',
array( 'is_default' => 1 ),
array( 'token_id' => $token->get_id(),
) );
} else {
$token->set_default( false );
$wpdb->update(
$wpdb->prefix . 'woocommerce_payment_tokens',
array( 'is_default' => 0 ),
array( 'token_id' => $token->get_id(),
) );
}
$token->update();
}
}

View File

@ -213,12 +213,14 @@ class WC_Shipping_Zone implements WC_Data {
/**
* Get shipping methods linked to this zone
* @param bool Only return enabled methods.
* @return array of objects
*/
public function get_shipping_methods() {
public function get_shipping_methods( $enabled_only = false ) {
global $wpdb;
$raw_methods = $wpdb->get_results( $wpdb->prepare( "SELECT method_id, method_order, instance_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d order by method_order ASC;", $this->get_zone_id() ) );
$raw_methods_sql = $enabled_only ? "SELECT method_id, method_order, instance_id, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d AND is_enabled = 1 order by method_order ASC;" : "SELECT method_id, method_order, instance_id, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d order by method_order ASC;";
$raw_methods = $wpdb->get_results( $wpdb->prepare( $raw_methods_sql, $this->get_zone_id() ) );
$wc_shipping = WC_Shipping::instance();
$allowed_classes = $wc_shipping->get_shipping_method_class_names();
$methods = array();
@ -245,6 +247,7 @@ class WC_Shipping_Zone implements WC_Data {
// Let's make sure that we have an instance before setting its attributes
if ( is_object( $methods[ $raw_method->instance_id ] ) ) {
$methods[ $raw_method->instance_id ]->method_order = absint( $raw_method->method_order );
$methods[ $raw_method->instance_id ]->enabled = $raw_method->is_enabled ? 'yes' : 'no';
$methods[ $raw_method->instance_id ]->has_settings = $methods[ $raw_method->instance_id ]->has_settings();
}
}

View File

@ -133,7 +133,7 @@ class WC_Shipping {
public function load_shipping_methods( $package = array() ) {
if ( $package ) {
$shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package );
$this->shipping_methods = $shipping_zone->get_shipping_methods();
$this->shipping_methods = $shipping_zone->get_shipping_methods( true );
} else {
$this->shipping_methods = array();
}

View File

@ -91,7 +91,8 @@ class WC_Shortcodes {
ob_start();
if ( $products->have_posts() ) : ?>
if ( $products->have_posts() ) {
?>
<?php do_action( "woocommerce_shortcode_before_{$loop_name}_loop" ); ?>
@ -107,7 +108,10 @@ class WC_Shortcodes {
<?php do_action( "woocommerce_shortcode_after_{$loop_name}_loop" ); ?>
<?php endif;
<?php
} else {
do_action( "woocommerce_shortcode_{$loop_name}_loop_no_results" );
}
woocommerce_reset_loop();
wp_reset_postdata();
@ -345,10 +349,16 @@ class WC_Shortcodes {
'value' => array_map( 'trim', explode( ',', $atts['skus'] ) ),
'compare' => 'IN'
);
// Ignore catalog visibility
$query_args['meta_query'] = WC()->query->stock_status_meta_query();
}
if ( ! empty( $atts['ids'] ) ) {
$query_args['post__in'] = array_map( 'trim', explode( ',', $atts['ids'] ) );
// Ignore catalog visibility
$query_args['meta_query'] = WC()->query->stock_status_meta_query();
}
return self::product_loop( $query_args, $atts, 'products' );

View File

@ -30,14 +30,14 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
/**
* Validate a PDT transaction to ensure its authentic.
* @param string $transaction
* @return bool
* @return bool|array False or result array
*/
protected function validate_transaction( $transaction ) {
$pdt = array(
'body' => array(
'cmd' => '_notify-synch',
'tx' => $transaction,
'at' => $this->identity_token
'at' => $this->identity_token,
),
'timeout' => 60,
'httpversion' => '1.1',
@ -51,7 +51,24 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
return false;
}
return true;
// Parse transaction result data
$transaction_result = explode( "\n", $response['body'] );
$transaction_results = array();
foreach ( $transaction_result as $line ) {
$line = explode( "=", $line );
$key = wc_clean( urldecode( $line[0] ) );
if ( function_exists( 'iconv' ) ) {
$value = wc_clean( iconv( 'windows-1252', 'utf-8', urldecode( isset( $line[1] ) ? $line[1] : '' ) ) );
} else {
$value = wc_clean( urldecode( isset( $line[1] ) ? $line[1] : '' ) );
}
$transaction_results[ $key ] = $value;
}
return $transaction_results;
}
/**
@ -71,16 +88,30 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
return false;
}
if ( $this->validate_transaction( $transaction ) && 'completed' === $status ) {
$transaction_result = $this->validate_transaction( $transaction );
if ( $transaction_result && 'completed' === $status ) {
if ( $order->get_total() != $amount ) {
WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (amt ' . $amount . ')' );
$this->payment_on_hold( $order, sprintf( __( 'Validation error: PayPal amounts do not match (amt %s).', 'woocommerce' ), $amount ) );
} else {
$this->payment_complete( $order, $transaction, __( 'PDT payment completed', 'woocommerce' ) );
if ( ! empty( $_REQUEST['mc_fee'] ) ) {
// Log paypal transaction fee.
update_post_meta( $order->id, 'PayPal Transaction Fee', wc_clean( $_REQUEST['mc_fee'] ) );
// Log paypal transaction fee and other meta data.
if ( ! empty( $transaction_result['mc_fee'] ) ) {
update_post_meta( $order->id, 'PayPal Transaction Fee', $transaction_result['mc_fee'] );
}
if ( ! empty( $transaction_result['payer_email'] ) ) {
update_post_meta( $order->id, 'Payer PayPal address', $transaction_result['payer_email'] );
}
if ( ! empty( $transaction_result['first_name'] ) ) {
update_post_meta( $order->id, 'Payer first name', $transaction_result['first_name'] );
}
if ( ! empty( $transaction_result['last_name'] ) ) {
update_post_meta( $order->id, 'Payer last name', $transaction_result['last_name'] );
}
if ( ! empty( $transaction_result['payment_type'] ) ) {
update_post_meta( $order->id, 'Payment type', $transaction_result['payment_type'] );
}
}
}

View File

@ -38,7 +38,6 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
*/
public function init() {
$this->instance_form_fields = include( 'includes/settings-flat-rate.php' );
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->availability = $this->get_option( 'availability' );
$this->countries = $this->get_option( 'countries' );

View File

@ -10,12 +10,6 @@ $cost_desc = __( 'Enter a cost (excl. tax) or sum, e.g. <code>10.00 * [qty]</cod
* Settings for flat rate shipping.
*/
$settings = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable this shipping method', 'woocommerce' ),
'default' => 'yes',
),
'title' => array(
'title' => __( 'Method Title', 'woocommerce' ),
'type' => 'text',

View File

@ -33,7 +33,6 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'shipping-zones',
'instance-settings'
);
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->min_amount = $this->get_option( 'min_amount', 0 );
$this->requires = $this->get_option( 'requires' );
@ -47,12 +46,6 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
*/
public function get_instance_form_fields() {
return array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable Free Shipping', 'woocommerce' ),
'default' => 'yes'
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',

View File

@ -40,7 +40,6 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
$this->init_settings();
// Define user set variables
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->codes = $this->get_option( 'codes' );
$this->availability = $this->get_option( 'availability' );
@ -66,12 +65,6 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
*/
public function init_form_fields() {
$this->instance_form_fields = array(
'enabled' => array(
'title' => __( 'Enable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable local pickup', 'woocommerce' ),
'default' => 'yes'
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
@ -142,7 +135,7 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
* @return bool
*/
public function is_available( $package ) {
$is_available = "yes" === $this->enabled;
$is_available = true;
if ( $is_available && $this->get_valid_postcodes() ) {
$is_available = $this->is_valid_postcode( $package['destination']['postcode'], $package['destination']['country'] );

View File

@ -14,6 +14,8 @@ if ( ! defined( 'ABSPATH' ) ) {
global $wpdb;
WC_Admin_Notices::add_notice( 'legacy_shipping' );
/**
* Migrate term meta to WordPress tables
*/

View File

@ -150,36 +150,6 @@ function wc_get_account_orders_columns() {
return apply_filters( 'woocommerce_my_account_my_orders_columns', $columns );
}
/**
* Get My Account > Orders query args.
*
* @since 2.6.0
* @param int $current_page
* @return array
*/
function wc_get_account_orders_query_args( $current_page = 1 ) {
$args = array(
'numberposts' => 15,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ),
);
// @deprecated 2.6.0.
$args = apply_filters( 'woocommerce_my_account_my_orders_query', $args );
// Remove deprecated option.
$args['posts_per_page'] = $args['numberposts'];
unset( $args['numberposts'] );
if ( 1 < $current_page ) {
$args['paged'] = absint( $current_page );
}
return apply_filters( 'woocommerce_account_orders_query', $args );
}
/**
* Get My Account > Downloads columns.
*

View File

@ -475,15 +475,20 @@ function wc_print_js() {
global $wc_queued_js;
if ( ! empty( $wc_queued_js ) ) {
echo "<!-- WooCommerce JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) {";
// Sanitize
// Sanitize.
$wc_queued_js = wp_check_invalid_utf8( $wc_queued_js );
$wc_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wc_queued_js );
$wc_queued_js = str_replace( "\r", '', $wc_queued_js );
echo $wc_queued_js . "});\n</script>\n";
$js = "<!-- WooCommerce JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) { $wc_queued_js });\n</script>\n";
/**
* woocommerce_queued_js filter.
*
* @since 2.6.0
* @param string $js JavaScript code.
*/
echo apply_filters( 'woocommerce_queued_js', $js );
unset( $wc_queued_js );
}

View File

@ -14,6 +14,173 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Wrapper for get_posts specific to orders.
*
* This function should be used for order retrieval so that when we move to
* custom tables, functions still work.
*
* Args:
* status array|string List of order statuses to find
* type array|string Order type, e.g. shop_order or shop_order_refund
* parent int post/order parent
* customer int|string|array User ID or billing email to limit orders to a
* particular user. Accepts array of values. Array of values is OR'ed. If array of array is passed, each array will be AND'ed.
* e.g. test@test.com, 1, array( 1, 2, 3 ), array( array( 1, 'test@test.com' ), 2, 3 )
* limit int Maximum of orders to retrieve.
* offset int Offset of orders to retrieve.
* page int Page of orders to retrieve. Ignored when using the 'offset' arg.
* exclude array Order IDs to exclude from the query.
* orderby string Order by date, title, id, modified, rand etc
* order string ASC or DESC
* return string Type of data to return. Allowed values:
* ids array of order ids
* objects array of order objects (default)
* paginate bool If true, the return value will be an array with values:
* 'orders' => array of data (return value above),
* 'total' => total number of orders matching the query
* 'max_num_pages' => max number of pages found
*
* @since 2.6.0
* @param array $args Array of args (above)
* @return array|stdClass Number of pages and an array of order objects if
* paginate is true, or just an array of values.
*/
function wc_get_orders( $args ) {
$args = wp_parse_args( $args, array(
'status' => array_keys( wc_get_order_statuses() ),
'type' => wc_get_order_types( 'view-orders' ),
'parent' => null,
'customer' => null,
'email' => '',
'limit' => get_option( 'posts_per_page' ),
'offset' => null,
'page' => 1,
'exclude' => array(),
'orderby' => 'date',
'order' => 'DESC',
'return' => 'objects',
'paginate' => false,
) );
// Handle some BW compatibility arg names where wp_query args differ in naming.
$map_legacy = array(
'numberposts' => 'limit',
'post_type' => 'type',
'post_status' => 'status',
'post_parent' => 'parent',
'author' => 'customer',
'posts_per_page' => 'limit',
'paged' => 'page',
);
foreach ( $map_legacy as $from => $to ) {
if ( isset( $args[ $from ] ) ) {
$args[ $to ] = $args[ $from ];
}
}
/**
* Generate WP_Query args. This logic will change if orders are moved to
* custom tables in the future.
*/
$wp_query_args = array(
'post_type' => $args['type'] ? $args['type'] : 'shop_order',
'post_status' => $args['status'],
'posts_per_page' => $args['limit'],
'meta_query' => array(),
'fields' => 'ids',
'orderby' => $args['orderby'],
'order' => $args['order'],
);
if ( ! is_null( $args['parent'] ) ) {
$wp_query_args['post_parent'] = absint( $args['parent'] );
}
if ( ! is_null( $args['offset'] ) ) {
$wp_query_args['offset'] = absint( $args['offset'] );
} else {
$wp_query_args['paged'] = absint( $args['page'] );
}
if ( ! empty( $args['customer'] ) ) {
$values = is_array( $args['customer'] ) ? $args['customer'] : array( $args['customer'] );
$wp_query_args['meta_query'][] = _wc_get_orders_generate_customer_meta_query( $values );
}
if ( ! empty( $args['exclude'] ) ) {
$wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
}
if ( ! $args['paginate' ] ) {
$wp_query_args['no_found_rows'] = true;
}
// Get results.
$orders = new WP_Query( $wp_query_args );
if ( 'objects' === $args['return'] ) {
$return = array_map( 'wc_get_order', $orders->posts );
} else {
$return = $orders->posts;
}
if ( $args['paginate' ] ) {
return (object) array(
'orders' => $return,
'total' => $orders->found_posts,
'max_num_pages' => $orders->max_num_pages,
);
} else {
return $return;
}
}
/**
* Generate meta query for wc_get_orders. Used internally only.
* @since 2.6.0
* @param array $values
* @param string $relation
* @return array
*/
function _wc_get_orders_generate_customer_meta_query( $values, $relation = 'or' ) {
$meta_query = array(
'relation' => strtoupper( $relation ),
'customer_emails' => array(
'key' => '_billing_email',
'value' => array(),
'compare' => 'IN',
),
'customer_ids' => array(
'key' => '_customer_user',
'value' => array(),
'compare' => 'IN',
)
);
foreach ( $values as $value ) {
if ( is_array( $value ) ) {
$meta_query[] = _wc_get_orders_generate_customer_meta_query( $value, 'and' );
} elseif ( is_email( $value ) ) {
$meta_query['customer_emails']['value'][] = sanitize_email( $value );
} else {
$meta_query['customer_ids']['value'][] = strval( absint( $value ) );
}
}
if ( empty( $meta_query['customer_emails']['value'] ) ) {
unset( $meta_query['customer_emails'] );
unset( $meta_query['relation'] );
}
if ( empty( $meta_query['customer_ids']['value'] ) ) {
unset( $meta_query['customer_ids'] );
unset( $meta_query['relation'] );
}
return $meta_query;
}
/**
* Get all order statuses.
*

View File

@ -557,7 +557,7 @@ if ( ! function_exists( 'woocommerce_template_loop_category_title' ) ) {
* Insert the opening anchor tag for products in the loop.
*/
function woocommerce_template_loop_product_link_open() {
echo '<a href="' . get_the_permalink() . '">';
echo '<a href="' . get_the_permalink() . '" class="woocommerce-LoopProduct-link">';
}
/**
* Insert the opening anchor tag for products in the loop.
@ -2094,9 +2094,10 @@ if ( ! function_exists( 'woocommerce_account_orders' ) ) {
* @param int $current_page Current page number.
*/
function woocommerce_account_orders( $current_page ) {
$current_page = empty( $current_page ) ? 1 : $current_page;
$current_page = empty( $current_page ) ? 1 : absint( $current_page );
$customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', array( 'customer' => get_current_user_id(), 'page' => $current_page, 'paginate' => true ) ) );
wc_get_template( 'myaccount/orders.php', array( 'current_page' => absint( $current_page ) ) );
wc_get_template( 'myaccount/orders.php', array( 'current_page' => absint( $current_page ), 'customer_orders' => $customer_orders ) );
}
}

View File

@ -137,31 +137,16 @@ function wc_set_customer_auth_cookie( $customer_id ) {
* @return int
*/
function wc_update_new_customer_past_orders( $customer_id ) {
$customer = get_user_by( 'id', absint( $customer_id ) );
$customer_orders = get_posts( array(
'numberposts' => -1,
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ),
'fields' => 'ids',
'meta_query' => array(
array(
'key' => '_customer_user',
'value' => array( 0, '' ),
'compare' => 'IN'
),
array(
'key' => '_billing_email',
'value' => $customer->user_email,
)
),
) );
$linked = 0;
$complete = 0;
$customer = get_user_by( 'id', absint( $customer_id ) );
$customer_orders = wc_get_orders( array(
'limit' => -1,
'customer' => array( array( 0, $customer->user_email ) ),
'return' => 'ids',
) );
if ( $customer_orders ) {
if ( ! empty( $customer_orders ) ) {
foreach ( $customer_orders as $order_id ) {
update_post_meta( $order_id, '_customer_user', $customer->ID );

View File

@ -121,7 +121,7 @@ class WC_Widget_Product_Categories extends WC_Widget {
} elseif ( is_singular( 'product' ) ) {
$product_category = wc_get_product_terms( $post->ID, 'product_cat', array( 'orderby' => 'parent' ) );
$product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent' ) ) );
if ( $product_category ) {
$this->current_cat = end( $product_category );

View File

@ -159,10 +159,32 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 2.6.0 - TBD =
* Feature - Introduced Shipping Zone functionality, and re-usable instance based shipping methods.
* Feature - Tabbed "My Account" area.
* Feature - Cart operations now use ajax (item quantities/remove, coupon apply/remove, shipping options).
* Feature - Layered nav; filter by rating.
* Feature - On-hold order emails.
* Dev - Added ability for shipping methods to store meta data to the order.
* Dev - Added Payment Gateway Tokenization API for storing and retrieving tokens in a standardized manner.
* Dev - Migrated custom term meta implementation to WP Term Meta.
* Dev - Added new wc_get_orders() function to get order objects and ids instead of direct get_posts() calls.
* Dev - Made coupon optional in cart has_discount() method.
* Dev - Made the review template more editable.
* Fix - Update download permission user and email when changed.
* Tweak - Ignore catalog visibility on products shortcode when specifying IDs or SKUs.
* Tweak - Added context to checkout error messages.
* Tweak - Added SKU field to grouped products.
* Tweak - Support qty display in cart messages.
* Tweak - Hide min order amount field when not needed in shipping settings.
* Tweak - If shipping < 999.99, use 'shipping' arg when passing values to PayPal.
* Tweak - Show net sales on dashboard.
* Tweak - Replaced credit card icons with SVG.
* Tweak - Enqueue scripts on pages with checkout shortcodes.
* Tweak - Color code manual, system and customer notes.
* Tweak - Layered Nav Refactoring to improve performance.
* Tweak - Removed tag/cat classes from loops since WP does the same.
* Tweak - Added hash check for orders so that if the cart changes before payment, a new order is made.
* Feature - Cart operations now use ajax (item quantities/remove, coupon apply/remove, shipping options)
* Tweak - Removed unused 'view mode' under screen options.
[See changelog for all versions](https://raw.githubusercontent.com/woothemes/woocommerce/master/CHANGELOG.txt).

View File

@ -2,21 +2,7 @@
/**
* My Orders
*
* Shows recent orders on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/my-orders.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
* @depreacated 2.6.0
* @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
*/
if ( ! defined( 'ABSPATH' ) ) {

View File

@ -22,18 +22,14 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$customer_orders = new WP_Query( wc_get_account_orders_query_args( $current_page ) );
$has_orders = $customer_orders->have_posts();
wc_print_notices();
wc_get_template( 'myaccount/navigation.php' ); ?>
<div class="my-account-content">
<?php do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<?php if ( $has_orders ) : ?>
<?php if ( 0 < $customer_orders->total ) : ?>
<table class="shop_table shop_table_responsive my_account_orders account-orders-table">
<thead>
@ -45,7 +41,7 @@ wc_get_template( 'myaccount/navigation.php' ); ?>
</thead>
<tbody>
<?php foreach ( $customer_orders->posts as $customer_order ) :
<?php foreach ( $customer_orders->orders as $customer_order ) :
$order = wc_get_order( $customer_order );
$item_count = $order->get_item_count();
?>

View File

@ -12,13 +12,16 @@ class WC_Helper_Payment_Token {
* @since 2.6
* @return WC_Payment_Token_CC object
*/
public static function create_cc_token() {
public static function create_cc_token( $user_id = '' ) {
$token = new WC_Payment_Token_CC();
$token->set_last4( 1234 );
$token->set_expiry_month( '08' );
$token->set_expiry_year( '2016' );
$token->set_card_type( 'visa' );
$token->set_token( time() );
if ( ! empty( $user_id ) ) {
$token->set_user_id( $user_id );
}
$token->save();
return $token;
}
@ -53,4 +56,3 @@ class WC_Helper_Payment_Token {
}
}

View File

@ -40,21 +40,6 @@ class Functions extends \WC_Unit_Test_Case {
), wc_get_account_orders_columns() );
}
/**
* Test wc_get_account_orders_query_args().
*
* @since 2.6.0
*/
public function test_wc_get_account_orders_query_args() {
$this->assertEquals( array(
'posts_per_page' => 15,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ),
), wc_get_account_orders_query_args() );
}
/**
* Test wc_get_account_downloads_columns().
*

View File

@ -7,6 +7,12 @@ namespace WooCommerce\Tests\Payment_Tokens;
*/
class Payment_Tokens extends \WC_Unit_Test_Case {
public function setUp() {
parent::setUp();
$this->user_id = $this->factory->user->create( array( 'role' => 'shop_manager' ) );
wp_set_current_user( $this->user_id );
}
/**
* Test getting tokens associated with an order.
* @since 2.6.0
@ -27,17 +33,17 @@ class Payment_Tokens extends \WC_Unit_Test_Case {
* @since 2.6.0
*/
function test_wc_payment_tokens_get_customer_tokens_no_gateway() {
$this->assertEmpty( \WC_Payment_Tokens::get_customer_tokens( 1 ) );
$this->assertEmpty( \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) );
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token->set_user_id( $this->user_id );
$token->save();
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token->set_user_id( $this->user_id );
$token->save();
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( 1 ) );
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) );
}
/**
@ -45,22 +51,22 @@ class Payment_Tokens extends \WC_Unit_Test_Case {
* @since 2.6.0
*/
function test_wc_payment_tokens_get_customer_tokens_with_gateway() {
$this->assertEmpty( \WC_Payment_Tokens::get_customer_tokens( 1 ) );
$this->assertEmpty( \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) );
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token->set_user_id( $this->user_id );
$token->set_gateway_id( 'simplify_commerce' );
$token->save();
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token->set_user_id( $this->user_id );
$token->set_gateway_id( 'paypal' );
$token->save();
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( 1 ) );
$this->assertCount( 1, \WC_Payment_Tokens::get_customer_tokens( 1, 'simplify_commerce' ) );
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) );
$this->assertCount( 1, \WC_Payment_Tokens::get_customer_tokens( $this->user_id, 'simplify_commerce' ) );
foreach ( \WC_Payment_Tokens::get_customer_tokens( 1, 'simplify_commerce' ) as $simplify_token ) {
foreach ( \WC_Payment_Tokens::get_customer_tokens( $this->user_id, 'simplify_commerce' ) as $simplify_token ) {
$this->assertEquals( 'simplify_commerce', $simplify_token->get_gateway_id() );
}
}
@ -71,41 +77,42 @@ class Payment_Tokens extends \WC_Unit_Test_Case {
*/
function test_wc_get_customer_default_token() {
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token->set_user_id( $this->user_id );
$token->set_gateway_id( 'simplify_commerce' );
$token->save();
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token->set_user_id( $this->user_id );
$token->set_default( true );
$token->set_gateway_id( 'paypal' );
$token->save();
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( 1 ) );
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) );
$default_token = \WC_Payment_Tokens::get_customer_default_token( 1 );
$default_token = \WC_Payment_Tokens::get_customer_default_token( $this->user_id );
$this->assertEquals( 'paypal', $default_token->get_gateway_id() );
}
/**
* Test getting a customers default token, when there is no default token.
* Test getting a customers default token, when there no token is expictly set.
* This should be the "first created".
* @see WC_Payment_Token::create()
* @group failing
* @since 2.6.0
*/
function test_wc_get_customer_default_token_returns_null_when_no_default_token() {
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
function test_wc_get_customer_default_token_returns_first_created_when_no_default_token_set() {
$token = \WC_Helper_Payment_Token::create_cc_token( $this->user_id );
$token->set_gateway_id( 'simplify_commerce' );
$token->save();
$token = \WC_Helper_Payment_Token::create_cc_token();
$token->set_user_id( 1 );
$token = \WC_Helper_Payment_Token::create_cc_token( $this->user_id );
$token->set_gateway_id( 'paypal' );
$token->save();
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( 1 ) );
$this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) );
$default_token = \WC_Payment_Tokens::get_customer_default_token( 1 );
$this->assertNull( $default_token );
$default_token = \WC_Payment_Tokens::get_customer_default_token( $this->user_id );
$this->assertEquals( 'simplify_commerce', $default_token->get_gateway_id() );
}
/**
@ -148,26 +155,24 @@ class Payment_Tokens extends \WC_Unit_Test_Case {
* @since 2.6.0
*/
function test_wc_payment_tokens_set_users_default() {
$token = \WC_Helper_Payment_Token::create_cc_token();
$token = \WC_Helper_Payment_Token::create_cc_token( $this->user_id );
$token_id = $token->get_id();
$token->set_user_id( 1 );
$token->save();
$token2 = \WC_Helper_Payment_Token::create_cc_token();
$token2 = \WC_Helper_Payment_Token::create_cc_token( $this->user_id );
$token_id_2 = $token2->get_id();
$token2->set_user_id( 1 );
$token2->save();
$this->assertFalse( $token->is_default() );
$this->assertTrue( $token->is_default() ); // first created is default
$this->assertFalse( $token2->is_default() );
\WC_Payment_Tokens::set_users_default( 1, $token_id_2 );
\WC_Payment_Tokens::set_users_default( $this->user_id, $token_id_2 );
$token->read( $token_id );
$token2->read( $token_id_2 );
$this->assertFalse( $token->is_default() );
$this->assertTrue( $token2->is_default() );
\WC_Payment_Tokens::set_users_default( 1, $token_id );
\WC_Payment_Tokens::set_users_default( $this->user_id, $token_id );
$token->read( $token_id );
$token2->read( $token_id_2 );
$this->assertTrue( $token->is_default() );

View File

@ -59,6 +59,7 @@ if ( ! empty( $status_options['uninstall_data'] ) ) {
// Delete posts + data.
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" );
$wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
$wpdb->query( "DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_items" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_itemmeta" );
}