Merge branch 'master' into update/erasure-requests

This commit is contained in:
Mike Jolley 2018-05-01 13:46:53 +01:00
commit f59acf1350
70 changed files with 625 additions and 455 deletions

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,-1px 0 1px #a36597,0 1px 1px #a36597,1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;left:0;padding:10px 21px 10px 15px;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;right:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;left:12px;position:absolute}
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,-1px 0 1px #a36597,0 1px 1px #a36597,1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:static;float:left;top:0;left:0;padding:0 28px 10px 15px;margin-top:-10px;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:relative;top:18px;right:-20px;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;left:12px;position:absolute}

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,1px 0 1px #a36597,0 1px 1px #a36597,-1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;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 .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .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,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute}
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,1px 0 1px #a36597,0 1px 1px #a36597,-1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:static;float:right;top:0;right:0;padding:0 15px 10px 28px;margin-top:-10px;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:relative;top:18px;left:-20px;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .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,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute}

View File

@ -35,17 +35,19 @@ p.woocommerce-actions,
}
a.woocommerce-message-close {
position: absolute;
position: static;
float: right;
top: 0;
right: 0;
padding: 10px 15px 10px 21px;
padding: 0px 15px 10px 28px;
margin-top: -10px;
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
&::before {
position: absolute;
top: 8px;
left: 0;
position: relative;
top: 18px;
left: -20px;
transition: all 0.1s ease-in-out;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -543,17 +543,17 @@
}
a.woocommerce-message-close {
position: absolute;
top: 10px;
right: 10px;
padding: 10px 15px 10px 21px;
position: static;
float: right;
padding: 0px 15px 10px 28px;
margin-top: -10px;
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
&::before {
position: absolute;
top: 8px;
left: 0;
position: relative;
top: 18px;
left: -20px;
transition: all 0.1s ease-in-out;
}
}
@ -3596,18 +3596,12 @@ img.help_tip {
}
.colorpickpreview {
padding: 6px;
padding-left: 20px;
padding: 7px 0;
line-height: 1em;
display: inline-block;
width: 26px;
border: 1px solid #ddd;
/* rtl:ignore */
border-right: 0;
/* rtl:ignore */
margin-left: -3px;
}
.colorpick {
/* rtl:ignore */
border-left: 0;
font-size: 14px;
}
.image_width_settings {

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -5,19 +5,33 @@ jQuery( function( $ ) {
var table_selector = 'table.wp-list-table',
item_selector = 'tbody tr:not(.inline-edit-row)',
term_id_selector = '.column-handle input[name="term_id"]';
term_id_selector = '.column-handle input[name="term_id"]',
column_handle = '<td class="column-handle"></td>';
if ( 0 === $( table_selector ).find( '.column-handle' ).length ) {
$( table_selector ).find( 'tr:not(.inline-edit-row)' ).append( '<td class="column-handle"></td>' );
$( table_selector ).find( 'tr:not(.inline-edit-row)' ).append( column_handle );
term_id_selector = '.check-column input';
}
$( table_selector ).find( '.column-handle' ).show();
$.wc_add_missing_sort_handles = function() {
var all_table_rows = $( table_selector ).find('tbody > tr');
var rows_with_handle = $( table_selector ).find('tbody > tr > td.column-handle').parent();
if ( all_table_rows.length !== rows_with_handle.length ) {
all_table_rows.each(function(index, elem){
if ( ! rows_with_handle.is( elem ) ) {
$( elem ).append( column_handle );
}
});
}
$( table_selector ).find( '.column-handle' ).show();
};
$( document ).ajaxComplete( function( event, request, options ) {
if ( request && 4 === request.readyState && 200 === request.status && options.data && 0 <= options.data.indexOf( '_inline_edit' ) ) {
$( table_selector ).find( '.column-handle' ).show();
if ( request && 4 === request.readyState && 200 === request.status && options.data && ( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) ) ) {
$.wc_add_missing_sort_handles();
$( document.body ).trigger( 'init_tooltips' );
}
} );

View File

@ -1 +1 @@
jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append('<td class="column-handle"></td>'),n=".check-column input"),e(t).find(".column-handle").show(),e(document).ajaxComplete(function(n,i,d){i&&4===i.readyState&&200===i.status&&d.data&&0<=d.data.indexOf("_inline_edit")&&(e(t).find(".column-handle").show(),e(document.body).trigger("init_tooltips"))}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var o,a,l=d.item.find(n).val(),r=d.item.find(".parent").html(),c=d.item.prev().find(n).val(),m=d.item.next().find(n).val();c!==undefined&&(o=d.item.prev().find(".parent").html())!==r&&(c=undefined),m!==undefined&&(a=d.item.next().find(".parent").html())!==r&&(m=undefined),c===undefined&&m===undefined||m===undefined&&a===c||m!==undefined&&o===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})});
jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append('<td class="column-handle"></td>'),n=".check-column input"),e(t).find(".column-handle").show(),e.wc_add_missing_sort_handles=function(){var n=e(t).find("tbody > tr"),i=e(t).find("tbody > tr > td.column-handle").parent();n.length!==i.length&&n.each(function(t,n){i.is(n)||e(n).append('<td class="column-handle"></td>')}),e(t).find(".column-handle").show()},e(document).ajaxComplete(function(t,n,i){n&&4===n.readyState&&200===n.status&&i.data&&(0<=i.data.indexOf("_inline_edit")||0<=i.data.indexOf("add-tag"))&&(e.wc_add_missing_sort_handles(),e(document.body).trigger("init_tooltips"))}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var a,o,l=d.item.find(n).val(),c=d.item.find(".parent").html(),r=d.item.prev().find(n).val(),m=d.item.next().find(n).val();r!==undefined&&(a=d.item.prev().find(".parent").html())!==c&&(r=undefined),m!==undefined&&(o=d.item.next().find(".parent").html())!==c&&(m=undefined),r===undefined&&m===undefined||m===undefined&&o===r||m!==undefined&&a===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})});

View File

@ -565,8 +565,9 @@
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
$form.wc_variations_image_reset();
if ( $gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).length > 0 ) {
$form.wc_variations_image_reset();
$gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).trigger( 'click' );
$form.attr( 'current-image', variation.image_id );
return;

View File

@ -333,7 +333,7 @@ jQuery( function( $ ) {
// Save payment details to a temporary object
var paymentDetails = {};
$( '.payment_box input' ).each( function() {
$( '.payment_box :input' ).each( function() {
var ID = $( this ).attr( 'id' );
if ( ID ) {
@ -360,7 +360,7 @@ jQuery( function( $ ) {
// Fill in the payment details if possible without overwriting data if set.
if ( ! $.isEmptyObject( paymentDetails ) ) {
$( '.payment_box input' ).each( function() {
$( '.payment_box :input' ).each( function() {
var ID = $( this ).attr( 'id' );
if ( ID ) {

View File

@ -89,7 +89,7 @@ jQuery( function( $ ) {
var country = $( this ).val(),
$statebox = $wrapper.find( '#billing_state, #shipping_state, #calc_shipping_state' ),
$parent = $statebox.parent(),
$parent = $statebox.closest( 'p.form-row' ),
input_name = $statebox.attr( 'name' ),
input_id = $statebox.attr( 'id' ),
value = $statebox.val(),
@ -98,7 +98,7 @@ jQuery( function( $ ) {
if ( states[ country ] ) {
if ( $.isEmptyObject( states[ country ] ) ) {
$statebox.parent().hide().find( '.select2-container' ).remove();
$statebox.closest( 'p.form-row' ).hide().find( '.select2-container' ).remove();
$statebox.replaceWith( '<input type="hidden" class="hidden" name="' + input_name + '" id="' + input_id + '" value="" placeholder="' + placeholder + '" />' );
$( document.body ).trigger( 'country_to_state_changed', [ country, $wrapper ] );
@ -114,7 +114,7 @@ jQuery( function( $ ) {
}
}
$statebox.parent().show();
$statebox.closest( 'p.form-row' ).show();
if ( $statebox.is( 'input' ) ) {
// Change for select

View File

@ -1 +1 @@
jQuery(function(t){function e(){return{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}}}if("undefined"==typeof wc_country_select_params)return!1;if(t().selectWoo){var n=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var n=t.extend({placeholderOption:"first",width:"100%"},e());t(this).selectWoo(n),t(this).on("select2:select",function(){t(this).focus()})})};n(),t(document.body).bind("country_to_state_changed",function(){n()})}var o=wc_country_select_params.countries.replace(/&quot;/g,'"'),c=t.parseJSON(o);t(document.body).on("change","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");e.length||(e=t(this).closest(".form-row").parent());var n=t(this).val(),o=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=o.parent(),a=o.attr("name"),r=o.attr("id"),s=o.val(),_=o.attr("placeholder")||o.attr("data-placeholder")||"";if(c[n])if(t.isEmptyObject(c[n]))o.parent().hide().find(".select2-container").remove(),o.replaceWith('<input type="hidden" class="hidden" name="'+a+'" id="'+r+'" value="" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]);else{var l="",u=c[n];for(var p in u)u.hasOwnProperty(p)&&(l=l+'<option value="'+p+'">'+u[p]+"</option>");o.parent().show(),o.is("input")&&(o.replaceWith('<select name="'+a+'" id="'+r+'" class="state_select" data-placeholder="'+_+'"></select>'),o=e.find("#billing_state, #shipping_state, #calc_shipping_state")),o.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+l),o.val(s).change(),t(document.body).trigger("country_to_state_changed",[n,e])}else o.is("select")?(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+a+'" id="'+r+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e])):o.is('input[type="hidden"]')&&(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+a+'" id="'+r+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]));t(document.body).trigger("country_to_state_changing",[n,e])}),t(function(){t(":input.country_to_state").change()})});
jQuery(function(t){function e(){return{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}}}if("undefined"==typeof wc_country_select_params)return!1;if(t().selectWoo){var n=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var n=t.extend({placeholderOption:"first",width:"100%"},e());t(this).selectWoo(n),t(this).on("select2:select",function(){t(this).focus()})})};n(),t(document.body).bind("country_to_state_changed",function(){n()})}var o=wc_country_select_params.countries.replace(/&quot;/g,'"'),c=t.parseJSON(o);t(document.body).on("change","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");e.length||(e=t(this).closest(".form-row").parent());var n=t(this).val(),o=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=o.closest("p.form-row"),r=o.attr("name"),a=o.attr("id"),s=o.val(),_=o.attr("placeholder")||o.attr("data-placeholder")||"";if(c[n])if(t.isEmptyObject(c[n]))o.closest("p.form-row").hide().find(".select2-container").remove(),o.replaceWith('<input type="hidden" class="hidden" name="'+r+'" id="'+a+'" value="" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]);else{var l="",u=c[n];for(var p in u)u.hasOwnProperty(p)&&(l=l+'<option value="'+p+'">'+u[p]+"</option>");o.closest("p.form-row").show(),o.is("input")&&(o.replaceWith('<select name="'+r+'" id="'+a+'" class="state_select" data-placeholder="'+_+'"></select>'),o=e.find("#billing_state, #shipping_state, #calc_shipping_state")),o.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+l),o.val(s).change(),t(document.body).trigger("country_to_state_changed",[n,e])}else o.is("select")?(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+r+'" id="'+a+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e])):o.is('input[type="hidden"]')&&(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+r+'" id="'+a+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]));t(document.body).trigger("country_to_state_changing",[n,e])}),t(function(){t(":input.country_to_state").change()})});

View File

@ -999,7 +999,7 @@ return array(
array(
'country' => 'ZA',
'state' => '',
'rate' => '14.0000',
'rate' => '15.0000',
'name' => 'VAT',
'shipping' => true,
),

View File

@ -54,7 +54,8 @@ abstract class WC_Abstract_Privacy {
*/
protected function init() {
add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ) );
// We set priority to 5 to help WooCommerce's findings appear before those from extensions in exported items.
add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 5 );
add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
}

View File

@ -569,7 +569,7 @@ abstract class WC_Settings_API {
<td class="forminp">
<fieldset>
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
<span class="colorpickpreview" style="background:<?php echo esc_attr( $this->get_option( $key ) ); ?>;"></span>
<span class="colorpickpreview" style="background:<?php echo esc_attr( $this->get_option( $key ) ); ?>;">&nbsp;</span>
<input class="colorpick <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
<div id="colorPickerDiv_<?php echo esc_attr( $field_key ); ?>" class="colorpickdiv" style="z-index: 100; background: #eee; border: 1px solid #ccc; position: absolute; display: none;"></div>
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>

View File

@ -77,8 +77,8 @@ class WC_Admin_Help {
'title' => __( 'Education', 'woocommerce' ),
'content' =>
'<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' .
'<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course offered by one of our educational partners.', 'woocommerce' ) . '</p>' .
'<p><a href="https://woocommerce.com/educational-partners/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'View education partners', 'woocommerce' ) . '</a></p>',
'<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider a WooCommerce course to further your education.', 'woocommerce' ) . '</p>' .
'<p><a href="https://docs.woocommerce.com/document/further-education/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'Further education', 'woocommerce' ) . '</a></p>',
)
);
@ -98,7 +98,7 @@ class WC_Admin_Help {
'<p><strong>' . __( 'For more information:', 'woocommerce' ) . '</strong></p>' .
'<p><a href="https://woocommerce.com/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=woocommerceplugin" target="_blank">' . __( 'About WooCommerce', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://wordpress.org/plugins/woocommerce/" target="_blank">' . __( 'WordPress.org project', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://github.com/woocommerce/woocommerce" target="_blank">' . __( 'Github project', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/" target="_blank">' . __( 'Github project', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://woocommerce.com/storefront/?utm_source=helptab&utm_medium=product&utm_content=wcthemes&utm_campaign=woocommerceplugin" target="_blank">' . __( 'Official theme', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://woocommerce.com/product-category/woocommerce-extensions/?utm_source=helptab&utm_medium=product&utm_content=wcextensions&utm_campaign=woocommerceplugin" target="_blank">' . __( 'Official extensions', 'woocommerce' ) . '</a></p>'
);

View File

@ -235,26 +235,34 @@ class WC_Admin_Importers {
update_user_option( get_current_user_id(), 'product_import_error_log', $error_log );
if ( 100 === $percent_complete ) {
// Clear temp meta.
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) ); // @codingStandardsIgnoreLine.
$wpdb->query(
"DELETE {$wpdb->posts}, {$wpdb->postmeta}, {$wpdb->term_relationships}
FROM {$wpdb->posts}
LEFT JOIN {$wpdb->term_relationships} ON ( {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id )
LEFT JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )
LEFT JOIN {$wpdb->term_taxonomy} ON ( {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id )
LEFT JOIN {$wpdb->terms} ON ( {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id )
WHERE {$wpdb->posts}.post_type IN ( 'product', 'product_variation' )
AND {$wpdb->posts}.post_status = 'importing'"
);
// @codingStandardsIgnoreStart.
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) );
$wpdb->delete( $wpdb->posts, array(
'post_type' => 'product',
'post_status' => 'importing',
) );
$wpdb->delete( $wpdb->posts, array(
'post_type' => 'product_variation',
'post_status' => 'importing',
) );
// @codingStandardsIgnoreEnd.
// Clear orphan variations.
$wpdb->query(
"DELETE products
FROM {$wpdb->posts} products
LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent
WHERE wp.ID IS NULL AND products.post_type = 'product_variation';"
);
// Clean up orphaned data.
$wpdb->query( "
DELETE {$wpdb->posts}.* FROM {$wpdb->posts}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->posts}.post_parent
WHERE wp.ID IS NULL AND {$wpdb->posts}.post_type = 'product_variation'
" );
$wpdb->query( "
DELETE {$wpdb->postmeta}.* FROM {$wpdb->postmeta}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->postmeta}.post_id
WHERE wp.ID IS NULL
" );
$wpdb->query( "
DELETE {$wpdb->term_relationships}.* FROM {$wpdb->term_relationships}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->term_relationships}.object_id
WHERE wp.ID IS NULL
" );
// Send success.
wp_send_json_success(

View File

@ -151,13 +151,13 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
'debug' => __( 'Debug', 'woocommerce' ),
);
if ( isset( $levels[ $level_key ] ) ) {
$level = $levels[ $level_key ];
$level_class = sanitize_html_class( 'log-level--' . $level_key );
return '<span class="log-level ' . $level_class . '">' . esc_html( $level ) . '</span>';
} else {
if ( ! isset( $levels[ $level_key ] ) ) {
return '';
}
$level = $levels[ $level_key ];
$level_class = sanitize_html_class( 'log-level--' . $level_key );
return '<span class="log-level ' . $level_class . '">' . esc_html( $level ) . '</span>';
}
/**

View File

@ -313,7 +313,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
</th>
<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">&lrm;
<span class="colorpickpreview" style="background: <?php echo esc_attr( $option_value ); ?>"></span>
<span class="colorpickpreview" style="background: <?php echo esc_attr( $option_value ); ?>">&nbsp;</span>
<input
name="<?php echo esc_attr( $value['id'] ); ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"

View File

@ -552,7 +552,7 @@ class WC_Admin_Setup_Wizard {
if ( $tracking ) {
update_option( 'woocommerce_allow_tracking', 'yes' );
WC_Tracker::send_tracking_data( true );
wp_schedule_single_event( time() + 10, 'woocommerce_tracker_send_event', array( true ) );
} else {
update_option( 'woocommerce_allow_tracking', 'no' );
}

View File

@ -307,17 +307,8 @@ class WC_Helper_Updater {
public static function flush_updates_cache() {
delete_transient( '_woocommerce_helper_updates' );
delete_transient( '_woocommerce_helper_updates_count' );
// Refresh update transients
$update_plugins = get_site_transient( 'update_plugins' );
if ( ! empty( $update_plugins ) ) {
set_site_transient( 'update_plugins', $update_plugins );
}
$update_themes = get_site_transient( 'update_themes' );
if ( ! empty( $update_themes ) ) {
set_site_transient( 'update_themes', $update_themes );
}
delete_site_transient( 'update_plugins' );
delete_site_transient( 'update_themes' );
}
/**

View File

@ -741,6 +741,7 @@ class WC_Helper {
}
self::_flush_subscriptions_cache();
self::_flush_updates_cache();
// Enable tracking when connected.
if ( class_exists( 'WC_Tracker' ) ) {
@ -858,6 +859,8 @@ class WC_Helper {
}
self::_flush_subscriptions_cache();
self::_flush_updates_cache();
$redirect_uri = add_query_arg(
array(
'page' => 'wc-addons',
@ -1220,6 +1223,7 @@ class WC_Helper {
self::log( 'Auto-activated a subscription for ' . $filename );
self::_flush_subscriptions_cache();
self::_flush_updates_cache();
}
/**
@ -1280,6 +1284,7 @@ class WC_Helper {
if ( $deactivated ) {
self::log( sprintf( 'Auto-deactivated %d subscription(s) for %s', $deactivated, $filename ) );
self::_flush_subscriptions_cache();
self::_flush_updates_cache();
}
}

View File

@ -340,17 +340,11 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
if ( 'simple' === $term->name ) {
$output .= '<option value="downloadable" ';
if ( isset( $wp_query->query['product_type'] ) ) {
$output .= selected( 'downloadable', $current_product_type, false );
}
$output .= selected( 'downloadable', $current_product_type, false );
$output .= '> ' . ( is_rtl() ? '&larr;' : '&rarr;' ) . ' ' . __( 'Downloadable', 'woocommerce' ) . '</option>';
$output .= '<option value="virtual" ';
$output .= selected( 'virtual', $current_product_type, false );
$output .= '> ' . ( is_rtl() ? '&larr;' : '&rarr;' ) . ' ' . __( 'Virtual', 'woocommerce' ) . '</option>';
}
}

View File

@ -263,9 +263,9 @@ class WC_Meta_Box_Coupon_Data {
woocommerce_wp_text_input(
array(
'id' => 'customer_email',
'label' => __( 'Email restrictions', 'woocommerce' ),
'label' => __( 'Allowed emails', 'woocommerce' ),
'placeholder' => __( 'No restrictions', 'woocommerce' ),
'description' => __( 'List of allowed emails to check against the customer billing email when an order is placed. Separate email addresses with commas. You can also use an asterisk (*) to match parts of an email. For example "*@gmail.com" would match all gmail addresses.', 'woocommerce' ),
'description' => __( 'Whitelist of billing emails to check against when an order is placed. Separate email addresses with commas. You can also use an asterisk (*) to match parts of an email. For example "*@gmail.com" would match all gmail addresses.', 'woocommerce' ),
'value' => implode( ', ', (array) $coupon->get_email_restrictions( 'edit' ) ),
'desc_tip' => true,
'type' => 'email',

View File

@ -4,13 +4,10 @@
*
* Functions for displaying product reviews data meta box.
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Meta Boxes
* @package WooCommerce/Admin/Meta Boxes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WC_Meta_Box_Product_Reviews
@ -18,9 +15,9 @@ if ( ! defined( 'ABSPATH' ) ) {
class WC_Meta_Box_Product_Reviews {
/**
* Output the metabox
* Output the metabox.
*
* @param object $comment
* @param object $comment Comment being shown.
*/
public static function output( $comment ) {
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
@ -30,7 +27,7 @@ class WC_Meta_Box_Product_Reviews {
<select name="rating" id="rating">
<?php
for ( $rating = 1; $rating <= 5; $rating ++ ) {
printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) );
printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) ); // WPCS: XSS ok.
}
?>
</select>
@ -40,30 +37,24 @@ class WC_Meta_Box_Product_Reviews {
/**
* Save meta box data
*
* @param mixed $data
*
* @param mixed $data Data to save.
* @return mixed
*/
public static function save( $data ) {
// Not allowed, return regular value without updating meta
if ( ! wp_verify_nonce( $_POST['woocommerce_meta_nonce'], 'woocommerce_save_data' ) && ! isset( $_POST['rating'] ) ) {
// Not allowed, return regular value without updating meta.
if ( ! isset( $_POST['woocommerce_meta_nonce'], $_POST['rating'] ) || ! wp_verify_nonce( wp_unslash( $_POST['woocommerce_meta_nonce'] ), 'woocommerce_save_data' ) ) { // WPCS: input var ok, sanitization ok.
return $data;
}
if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) {
if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok.
return $data;
}
$comment_id = $data['comment_ID'];
// Update meta
update_comment_meta(
$comment_id,
'rating',
intval( $_POST['rating'] )
);
update_comment_meta( $comment_id, 'rating', intval( wp_unslash( $_POST['rating'] ) ) ); // WPCS: input var ok.
// Return regular value after updating
// Return regular value after updating.
return $data;
}
}

View File

@ -51,7 +51,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'title' => __( 'Login', 'woocommerce' ),
'desc' => __( 'Allow customers to log into an existing account during checkout', 'woocommerce' ),
'id' => 'woocommerce_enable_checkout_login_reminder',
'default' => 'yes',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'autoload' => false,
@ -60,7 +60,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'title' => __( 'Account creation', 'woocommerce' ),
'desc' => __( 'Allow customers to create an account during checkout.', 'woocommerce' ),
'id' => 'woocommerce_enable_signup_and_login_from_checkout',
'default' => 'yes',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'autoload' => false,
@ -84,7 +84,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
array(
'desc' => __( 'When creating an account, automatically generate an account password.', 'woocommerce' ),
'id' => 'woocommerce_registration_generate_password',
'default' => 'no',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'autoload' => false,

View File

@ -2093,7 +2093,7 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
'validate_callback' => 'rest_validate_request_arg',
);
$params['attribute'] = array(
'description' => __( 'Limit result set to products with a specific attribute.', 'woocommerce' ),
'description' => __( 'Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.', 'woocommerce' ),
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',

View File

@ -157,7 +157,12 @@ class WC_Cache_Helper {
if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) {
global $wpdb;
$limit = apply_filters( 'woocommerce_delete_version_transients_limit', 1000 );
$limit = apply_filters( 'woocommerce_delete_version_transients_limit', 1000 );
if ( ! $limit ) {
return;
}
$affected = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s ORDER BY option_id LIMIT %d;", '\_transient\_%' . $version, $limit ) ); // WPCS: cache ok, db call ok.
// If affected rows is equal to limit, there are more rows to delete. Delete in 10 secs.

View File

@ -129,6 +129,7 @@ class WC_Checkout {
if ( in_array( $key, array( 'posted', 'shipping_method', 'payment_method' ), true ) && empty( $this->legacy_posted_data ) ) {
$this->legacy_posted_data = $this->get_posted_data();
}
switch ( $key ) {
case 'enable_signup':
return $this->is_registration_enabled();
@ -193,45 +194,54 @@ class WC_Checkout {
* @return array
*/
public function get_checkout_fields( $fieldset = '' ) {
if ( is_null( $this->fields ) ) {
$this->fields = array(
'billing' => WC()->countries->get_address_fields( $this->get_value( 'billing_country' ), 'billing_' ),
'shipping' => WC()->countries->get_address_fields( $this->get_value( 'shipping_country' ), 'shipping_' ),
'account' => array(),
'order' => array(
'order_comments' => array(
'type' => 'textarea',
'class' => array( 'notes' ),
'label' => __( 'Order notes', 'woocommerce' ),
'placeholder' => esc_attr__( 'Notes about your order, e.g. special notes for delivery.', 'woocommerce' ),
if ( ! is_null( $this->fields ) ) {
return $fieldset ? $this->fields[ $fieldset ] : $this->fields;
}
$this->fields = array(
'billing' => WC()->countries->get_address_fields(
$this->get_value( 'billing_country' ),
'billing_'
),
'shipping' => WC()->countries->get_address_fields(
$this->get_value( 'shipping_country' ),
'shipping_'
),
'account' => array(),
'order' => array(
'order_comments' => array(
'type' => 'textarea',
'class' => array( 'notes' ),
'label' => __( 'Order notes', 'woocommerce' ),
'placeholder' => esc_attr__(
'Notes about your order, e.g. special notes for delivery.',
'woocommerce'
),
),
),
);
if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) {
$this->fields['account']['account_username'] = array(
'type' => 'text',
'label' => __( 'Account username', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Username', 'woocommerce' ),
);
if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) {
$this->fields['account']['account_username'] = array(
'type' => 'text',
'label' => __( 'Account username', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Username', 'woocommerce' ),
);
}
if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) {
$this->fields['account']['account_password'] = array(
'type' => 'password',
'label' => __( 'Create account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
);
}
$this->fields = apply_filters( 'woocommerce_checkout_fields', $this->fields );
}
if ( $fieldset ) {
return $this->fields[ $fieldset ];
} else {
return $this->fields;
if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) {
$this->fields['account']['account_password'] = array(
'type' => 'password',
'label' => __( 'Create account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
);
}
$this->fields = apply_filters( 'woocommerce_checkout_fields', $this->fields );
return $fieldset ? $this->fields[ $fieldset ] : $this->fields;
}
/**
@ -378,6 +388,7 @@ class WC_Checkout {
'taxes' => $values['line_tax_data'],
)
);
if ( $product ) {
$item->set_props(
array(
@ -388,6 +399,7 @@ class WC_Checkout {
)
);
}
$item->set_backorder_meta();
/**
@ -560,9 +572,11 @@ class WC_Checkout {
if ( 'shipping' === $fieldset_key && ( ! $data['ship_to_different_address'] || ! WC()->cart->needs_shipping_address() ) ) {
return true;
}
if ( 'account' === $fieldset_key && ( is_user_logged_in() || ( ! $this->is_registration_required() && empty( $data['createaccount'] ) ) ) ) {
return true;
}
return false;
}
@ -587,6 +601,7 @@ class WC_Checkout {
$skipped[] = $fieldset_key;
continue;
}
foreach ( $fieldset as $key => $field ) {
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );
@ -633,6 +648,7 @@ class WC_Checkout {
if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) {
continue;
}
foreach ( $fieldset as $key => $field ) {
if ( ! isset( $data[ $key ] ) ) {
continue;
@ -769,6 +785,7 @@ class WC_Checkout {
WC()->customer->{"set_billing_{$field}"}( $data[ "billing_{$field}" ] );
WC()->customer->{"set_shipping_{$field}"}( $data[ "billing_{$field}" ] );
}
if ( isset( $data[ "shipping_{$field}" ] ) ) {
WC()->customer->{"set_shipping_{$field}"}( $data[ "shipping_{$field}" ] );
}
@ -835,12 +852,12 @@ class WC_Checkout {
if ( isset( $result['result'] ) && 'success' === $result['result'] ) {
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );
if ( is_ajax() ) {
wp_send_json( $result );
} else {
if ( ! is_ajax() ) {
wp_redirect( $result['redirect'] );
exit;
}
wp_send_json( $result );
}
}
@ -855,19 +872,19 @@ class WC_Checkout {
$order->payment_complete();
wc_empty_cart();
if ( is_ajax() ) {
wp_send_json(
array(
'result' => 'success',
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ),
)
);
} else {
if ( ! is_ajax() ) {
wp_safe_redirect(
apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order )
);
exit;
}
wp_send_json(
array(
'result' => 'success',
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ),
)
);
}
/**
@ -1060,22 +1077,20 @@ class WC_Checkout {
public function get_value( $input ) {
if ( ! empty( $_POST[ $input ] ) ) { // WPCS: input var ok, CSRF OK.
return wc_clean( wp_unslash( $_POST[ $input ] ) ); // WPCS: input var ok, CSRF OK.
} else {
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
if ( null !== $value ) {
return $value;
}
if ( is_callable( array( WC()->customer, "get_$input" ) ) ) {
$value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null;
} elseif ( WC()->customer->meta_exists( $input ) ) {
$value = WC()->customer->get_meta( $input, true );
}
return apply_filters( 'default_checkout_' . $input, $value, $input );
}
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
if ( null !== $value ) {
return $value;
}
if ( is_callable( array( WC()->customer, "get_$input" ) ) ) {
$value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null;
} elseif ( WC()->customer->meta_exists( $input ) ) {
$value = WC()->customer->get_meta( $input, true );
}
return apply_filters( 'default_checkout_' . $input, $value, $input );
}
}

View File

@ -1216,10 +1216,10 @@ class WC_Countries {
// Add email and phone fields.
if ( 'billing_' === $type ) {
if ( 'hidden' !== get_option( 'woocommerce_checkout_phone_field', 'optional' ) ) {
if ( 'hidden' !== get_option( 'woocommerce_checkout_phone_field', 'required' ) ) {
$address_fields['billing_phone'] = array(
'label' => __( 'Phone', 'woocommerce' ),
'required' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'optional' ),
'required' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ),
'type' => 'tel',
'class' => array( 'form-row-wide' ),
'validate' => array( 'phone' ),

View File

@ -183,7 +183,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
* @return float
*/
public function get_amount( $context = 'view' ) {
return $this->get_prop( 'amount', $context );
return (float) $this->get_prop( 'amount', $context );
}
/**

View File

@ -535,8 +535,8 @@ class WC_Frontend_Scripts {
$params = array(
'ajax_url' => WC()->ajax_url(),
'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
'cart_hash_key' => apply_filters( 'woocommerce_cart_hash_key', 'wc_cart_hash_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) ) ),
'fragment_name' => apply_filters( 'woocommerce_cart_fragment_name', 'wc_fragments_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) ) ),
'cart_hash_key' => apply_filters( 'woocommerce_cart_hash_key', 'wc_cart_hash_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ) ),
'fragment_name' => apply_filters( 'woocommerce_cart_fragment_name', 'wc_fragments_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ) ),
);
break;
case 'wc-add-to-cart':

View File

@ -57,7 +57,6 @@ class WC_Geolocation {
* @var array
*/
private static $geoip_apis = array(
'freegeoip' => 'https://freegeoip.net/json/%s',
'ipinfo.io' => 'https://ipinfo.io/%s/json',
'ip-api.com' => 'http://ip-api.com/json/%s',
);
@ -65,22 +64,36 @@ class WC_Geolocation {
/**
* Check if server supports MaxMind GeoLite2 Reader.
*
* @since 3.4.0
* @return bool
*/
private static function supports_geolite2() {
return version_compare( PHP_VERSION, '5.4.0', '>=' );
}
/**
* Check if geolocation is enabled.
*
* @since 3.4.0
* @param string $current_settings Current geolocation settings.
* @return bool
*/
private static function is_geolocation_enabled( $current_settings ) {
return in_array( $current_settings, array( 'geolocation', 'geolocation_ajax' ), true );
}
/**
* Prevent geolocation via MaxMind when using legacy versions of php.
*
* @since 3.4.0
* @param string $default_customer_address current value.
* @return string
*/
public static function disable_geolocation_on_legacy_php( $default_customer_address ) {
if ( in_array( $default_customer_address, array( 'geolocation', 'geolocation_ajax' ), true ) ) {
if ( self::is_geolocation_enabled( $default_customer_address ) ) {
$default_customer_address = 'base';
}
return $default_customer_address;
}
@ -90,9 +103,11 @@ class WC_Geolocation {
public static function init() {
if ( self::supports_geolite2() ) {
// Only download the database from MaxMind if the geolocation function is enabled, or a plugin specifically requests it.
if ( in_array( get_option( 'woocommerce_default_customer_address' ), array( 'geolocation', 'geolocation_ajax' ), true ) || apply_filters( 'woocommerce_geolocation_update_database_periodically', false ) ) {
if ( self::is_geolocation_enabled( get_option( 'woocommerce_default_customer_address' ) ) || apply_filters( 'woocommerce_geolocation_update_database_periodically', false ) ) {
add_action( 'woocommerce_geoip_updater', array( __CLASS__, 'update_database' ) );
}
// Trigger database update when settings are changed to enable geolocation.
add_filter( 'pre_update_option_woocommerce_default_customer_address', array( __CLASS__, 'maybe_update_database' ), 10, 2 );
} else {
add_filter( 'pre_option_woocommerce_default_customer_address', array( __CLASS__, 'disable_geolocation_on_legacy_php' ) );
@ -107,9 +122,10 @@ class WC_Geolocation {
* @return string
*/
public static function maybe_update_database( $new_value, $old_value ) {
if ( $new_value !== $old_value && in_array( $new_value, array( 'geolocation', 'geolocation_ajax' ), true ) ) {
if ( $new_value !== $old_value && self::is_geolocation_enabled( $new_value ) ) {
self::update_database();
}
return $new_value;
}
@ -228,7 +244,7 @@ class WC_Geolocation {
}
/**
* Update geoip database. Adapted from https://wordpress.org/plugins/geoip-detect/.
* Update geoip database.
*/
public static function update_database() {
$logger = wc_get_logger();
@ -247,11 +263,11 @@ class WC_Geolocation {
try {
// GeoLite2 database name.
$database = 'GeoLite2-Country.mmdb';
$dest_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $database;
$dest_path = trailingslashit( $upload_dir['basedir'] ) . $database;
// Extract files with PharData. Tool built into PHP since 5.3.
$file = new PharData( $tmp_database_path ); // phpcs:ignore PHPCompatibility.PHP.NewClasses.phardataFound
$file_path = $file->current()->getFileName() . DIRECTORY_SEPARATOR . $database;
$file_path = trailingslashit( $file->current()->getFileName() ) . $database;
// Extract under uploads directory.
$file->extractTo( $upload_dir['basedir'], $file_path, true );
@ -260,8 +276,8 @@ class WC_Geolocation {
@unlink( $dest_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink
// Copy database and delete tmp directories.
@rename( $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $file_path, $dest_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
@rmdir( $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $file->current()->getFileName() ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.directory_rmdir
@rename( trailingslashit( $upload_dir['basedir'] ) . $file_path, $dest_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
@rmdir( trailingslashit( $upload_dir['basedir'] ) . $file->current()->getFileName() ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.directory_rmdir
// Set correct file permission.
@chmod( $dest_path, 0644 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.chmod_chmod
@ -302,15 +318,27 @@ class WC_Geolocation {
/**
* Use APIs to Geolocate the user.
*
* Geolocation APIs can be added through the use of the woocommerce_geolocation_geoip_apis filter.
* Provide a name=>value pair for service-slug=>endpoint.
*
* If APIs are defined, one will be chosen at random to fulfil the request. After completing, the result
* will be cached in a transient.
*
* @param string $ip_address IP address.
* @return string|bool
* @return string
*/
private static function geolocate_via_api( $ip_address ) {
$country_code = get_transient( 'geoip_' . $ip_address );
if ( false === $country_code ) {
$geoip_services = apply_filters( 'woocommerce_geolocation_geoip_apis', self::$geoip_apis );
$geoip_services = apply_filters( 'woocommerce_geolocation_geoip_apis', self::$geoip_apis );
if ( empty( $geoip_services ) ) {
return '';
}
$geoip_services_keys = array_keys( $geoip_services );
shuffle( $geoip_services_keys );
foreach ( $geoip_services_keys as $service_name ) {
@ -327,10 +355,6 @@ class WC_Geolocation {
$data = json_decode( $response['body'] );
$country_code = isset( $data->countryCode ) ? $data->countryCode : ''; // @codingStandardsIgnoreLine
break;
case 'freegeoip':
$data = json_decode( $response['body'] );
$country_code = isset( $data->country_code ) ? $data->country_code : '';
break;
default:
$country_code = apply_filters( 'woocommerce_geolocation_geoip_response_' . $service_name, '', $response['body'] );
break;

View File

@ -368,7 +368,10 @@ class WC_Install {
wp_schedule_event( time(), 'daily', 'woocommerce_cleanup_personal_data' );
wp_schedule_event( time(), 'twicedaily', 'woocommerce_cleanup_sessions' );
wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'woocommerce_geoip_updater' );
wp_schedule_event( time(), apply_filters( 'woocommerce_tracker_event_recurrence', 'daily' ), 'woocommerce_tracker_send_event' );
wp_schedule_event( time() + 10, apply_filters( 'woocommerce_tracker_event_recurrence', 'daily' ), 'woocommerce_tracker_send_event' );
// Trigger GeoLite2 database download after 5 minutes.
wp_schedule_single_event( time() + ( MINUTE_IN_SECONDS * 5 ), 'woocommerce_geoip_updater' );
}
/**

View File

@ -100,7 +100,7 @@ class WC_Order_Item_Meta {
}
}
$output = apply_filters( 'woocommerce_order_items_meta_display', $output, $this );
$output = apply_filters( 'woocommerce_order_items_meta_display', $output, $this, $flat );
if ( $return ) {
return $output;

View File

@ -73,10 +73,10 @@ Handling this data also allows us to:
Additionally we may also collect the following information:
- Location and traffic data (including IP address and browser type) if you place an order, or if we need to estimate taxes and shipping costs based on your location.
- Product pages visited and content viewed whist your session is active.
- Product pages visited and content viewed whilst your session is active.
- Your comments and product reviews if you choose to leave them on our website.
- Shipping address if you request shipping rates from us before checkout whist your session is active.
- Cookies which are essential to keep track of the contents of your cart whist your session is active.
- Shipping address if you request shipping rates from us before checkout whilst your session is active.
- Cookies which are essential to keep track of the contents of your cart whilst your session is active.
- Account email/password to allow you to access your account, if you have one.
- If you choose to create an account with us, your name, address, email and phone number, which will be used to populate the checkout for future orders.
', 'woocommerce' ) ) ) );

View File

@ -135,16 +135,17 @@ class WC_Product_Variation extends WC_Product_Simple {
if ( isset( $attributes[ $attribute ] ) ) {
$value = $attributes[ $attribute ];
$term = taxonomy_exists( $attribute ) ? get_term_by( 'slug', $value, $attribute ) : false;
$value = ! is_wp_error( $term ) && $term ? $term->name : $value;
} elseif ( isset( $attributes[ 'pa_' . $attribute ] ) ) {
$value = $attributes[ 'pa_' . $attribute ];
$term = taxonomy_exists( 'pa_' . $attribute ) ? get_term_by( 'slug', $value, 'pa_' . $attribute ) : false;
$value = ! is_wp_error( $term ) && $term ? $term->name : $value;
} else {
return '';
return ! is_wp_error( $term ) && $term ? $term->name : $value;
}
return $value;
$att_str = 'pa_' . $attribute;
if ( isset( $attributes[ $att_str ] ) ) {
$value = $attributes[ $att_str ];
$term = taxonomy_exists( $att_str ) ? get_term_by( 'slug', $value, $att_str ) : false;
return ! is_wp_error( $term ) && $term ? $term->name : $value;
}
return '';
}
/**

View File

@ -193,7 +193,7 @@ class WC_Template_Loader {
* @since 3.3.0
*/
public static function unsupported_theme_init() {
if ( self::$shop_page_id ) {
if ( 0 < self::$shop_page_id ) {
if ( is_product_taxonomy() ) {
self::unsupported_theme_tax_archive_init();
} elseif ( is_product() ) {

View File

@ -5,21 +5,21 @@
* The WooCommerce tracker class adds functionality to track WooCommerce usage based on if the customer opted in.
* No personal information is tracked, only general WooCommerce settings, general product, order and user counts and admin email for discount code.
*
* @class WC_Tracker
* @version 2.3.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @class WC_Tracker
* @since 2.3.0
* @package WooCommerce/Classes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WooCommerce Tracker Class
*/
class WC_Tracker {
/**
* URL to the WooThemes Tracker API endpoint.
*
* @var string
*/
private static $api_url = 'https://tracking.woocommerce.com/v1/';
@ -34,10 +34,10 @@ class WC_Tracker {
/**
* Decide whether to send tracking data or not.
*
* @param boolean $override
* @param boolean $override Should override?.
*/
public static function send_tracking_data( $override = false ) {
// Don't trigger this on AJAX Requests
// Don't trigger this on AJAX Requests.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
@ -56,25 +56,25 @@ class WC_Tracker {
}
}
// Update time first before sending to ensure it is set
// Update time first before sending to ensure it is set.
update_option( 'woocommerce_tracker_last_send', time() );
$params = self::get_tracking_data();
$params = self::get_tracking_data();
wp_safe_remote_post( self::$api_url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => false,
'headers' => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
'body' => json_encode( $params ),
'cookies' => array(),
)
);
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => false,
'headers' => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url_raw( home_url( '/' ) ) ) . ';' ),
'body' => wp_json_encode( $params ),
'cookies' => array(),
) );
}
/**
* Get the last time tracking data was sent.
*
* @return int|bool
*/
private static function get_last_send_time() {
@ -83,52 +83,53 @@ class WC_Tracker {
/**
* Get all the tracking data.
*
* @return array
*/
private static function get_tracking_data() {
$data = array();
// General site info
// General site info.
$data['url'] = home_url();
$data['email'] = apply_filters( 'woocommerce_tracker_admin_email', get_option( 'admin_email' ) );
$data['theme'] = self::get_theme_info();
// WordPress Info
// WordPress Info.
$data['wp'] = self::get_wordpress_info();
// Server Info
// Server Info.
$data['server'] = self::get_server_info();
// Plugin info
// Plugin info.
$all_plugins = self::get_all_plugins();
$data['active_plugins'] = $all_plugins['active_plugins'];
$data['inactive_plugins'] = $all_plugins['inactive_plugins'];
// Jetpack & WooCommerce Connect
// Jetpack & WooCommerce Connect.
$data['jetpack_version'] = defined( 'JETPACK__VERSION' ) ? JETPACK__VERSION : 'none';
$data['jetpack_connected'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_active' ) && Jetpack::is_active() ) ? 'yes' : 'no';
$data['jetpack_is_staging'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() ) ? 'yes' : 'no';
$data['connect_installed'] = class_exists( 'WC_Connect_Loader' ) ? 'yes' : 'no';
$data['connect_active'] = ( class_exists( 'WC_Connect_Loader' ) && wp_next_scheduled( 'wc_connect_fetch_service_schemas' ) ) ? 'yes' : 'no';
// Store count info
// Store count info.
$data['users'] = self::get_user_counts();
$data['products'] = self::get_product_counts();
$data['orders'] = self::get_order_counts();
$data['orders'] = self::get_orders();
// Payment gateway info
// Payment gateway info.
$data['gateways'] = self::get_active_payment_gateways();
// Shipping method info
// Shipping method info.
$data['shipping_methods'] = self::get_active_shipping_methods();
// Get all WooCommerce options info
// Get all WooCommerce options info.
$data['settings'] = self::get_all_woocommerce_options_values();
// Template overrides
// Template overrides.
$data['template_overrides'] = self::get_all_template_overrides();
// Template overrides
// Template overrides.
$data['admin_user_agents'] = self::get_admin_user_agents();
return apply_filters( 'woocommerce_tracker_data', $data );
@ -136,18 +137,25 @@ class WC_Tracker {
/**
* Get the current theme info, theme name and version.
*
* @return array
*/
public static function get_theme_info() {
$theme_data = wp_get_theme();
$theme_child_theme = is_child_theme() ? 'Yes' : 'No';
$theme_wc_support = ! current_theme_supports( 'woocommerce' ) ? 'No' : 'Yes';
$theme_child_theme = wc_bool_to_string( is_child_theme() );
$theme_wc_support = wc_bool_to_string( current_theme_supports( 'woocommerce' ) );
return array( 'name' => $theme_data->Name, 'version' => $theme_data->Version, 'child_theme' => $theme_child_theme, 'wc_support' => $theme_wc_support );
return array(
'name' => $theme_data->Name, // @phpcs:ignore
'version' => $theme_data->Version, // @phpcs:ignore
'child_theme' => $theme_child_theme,
'wc_support' => $theme_wc_support,
);
}
/**
* Get WordPress related data.
*
* @return array
*/
private static function get_wordpress_info() {
@ -171,13 +179,14 @@ class WC_Tracker {
/**
* Get server related info.
*
* @return array
*/
private static function get_server_info() {
$server_data = array();
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
$server_data['software'] = $_SERVER['SERVER_SOFTWARE'];
if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
$server_data['software'] = $_SERVER['SERVER_SOFTWARE']; // @phpcs:ignore
}
if ( function_exists( 'phpversion' ) ) {
@ -205,17 +214,18 @@ class WC_Tracker {
/**
* Get all plugins grouped into activated or not.
*
* @return array
*/
private static function get_all_plugins() {
// Ensure get_plugins function is loaded
// Ensure get_plugins function is loaded.
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$plugins = get_plugins();
$active_plugins_keys = get_option( 'active_plugins', array() );
$active_plugins = array();
$active_plugins = array();
foreach ( $plugins as $k => $v ) {
// Take care of formatting the data how we want it.
@ -234,7 +244,7 @@ class WC_Tracker {
$formatted['plugin_uri'] = strip_tags( $v['PluginURI'] );
}
if ( in_array( $k, $active_plugins_keys ) ) {
// Remove active plugins from list so we can show active and inactive separately
// Remove active plugins from list so we can show active and inactive separately.
unset( $plugins[ $k ] );
$active_plugins[ $k ] = $formatted;
} else {
@ -242,11 +252,15 @@ class WC_Tracker {
}
}
return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
return array(
'active_plugins' => $active_plugins,
'inactive_plugins' => $plugins,
);
}
/**
* Get user totals based on user role.
*
* @return array
*/
private static function get_user_counts() {
@ -254,7 +268,7 @@ class WC_Tracker {
$user_count_data = count_users();
$user_count['total'] = $user_count_data['total_users'];
// Get user count based on user role
// Get user count based on user role.
foreach ( $user_count_data['avail_roles'] as $role => $count ) {
$user_count[ $role ] = $count;
}
@ -264,6 +278,7 @@ class WC_Tracker {
/**
* Get product totals based on product type.
*
* @return array
*/
private static function get_product_counts() {
@ -280,22 +295,35 @@ class WC_Tracker {
}
/**
* Get order counts based on order status.
* Get order counts
*
* @return array
*/
private static function get_order_counts() {
$order_count = array();
$order_count_data = wp_count_posts( 'shop_order' );
foreach ( wc_get_order_statuses() as $status_slug => $status_name ) {
$order_count[ $status_slug ] = $order_count_data->{ $status_slug };
}
return $order_count;
}
/**
* Combine all order data.
*
* @return array
*/
private static function get_orders() {
$order_dates = self::get_order_dates();
$order_counts = self::get_order_counts();
$order_totals = self::get_order_totals();
return array_merge( $order_dates, $order_counts, $order_totals );
}
/**
* Get a list of all active payment gateways.
*
* @return array
*/
private static function get_active_payment_gateways() {
@ -303,7 +331,10 @@ class WC_Tracker {
$gateways = WC()->payment_gateways->payment_gateways();
foreach ( $gateways as $id => $gateway ) {
if ( isset( $gateway->enabled ) && 'yes' === $gateway->enabled ) {
$active_gateways[ $id ] = array( 'title' => $gateway->title, 'supports' => $gateway->supports );
$active_gateways[ $id ] = array(
'title' => $gateway->title,
'supports' => $gateway->supports,
);
}
}
@ -312,6 +343,7 @@ class WC_Tracker {
/**
* Get a list of all active shipping methods.
*
* @return array
*/
private static function get_active_shipping_methods() {
@ -319,7 +351,10 @@ class WC_Tracker {
$shipping_methods = WC()->shipping->get_shipping_methods();
foreach ( $shipping_methods as $id => $shipping_method ) {
if ( isset( $shipping_method->enabled ) && 'yes' === $shipping_method->enabled ) {
$active_methods[ $id ] = array( 'title' => $shipping_method->title, 'tax_status' => $shipping_method->tax_status );
$active_methods[ $id ] = array(
'title' => $shipping_method->title,
'tax_status' => $shipping_method->tax_status,
);
}
}
@ -328,6 +363,7 @@ class WC_Tracker {
/**
* Get all options starting with woocommerce_ prefix.
*
* @return array
*/
private static function get_all_woocommerce_options_values() {
@ -354,6 +390,7 @@ class WC_Tracker {
/**
* Look for any template override and return filenames.
*
* @return array
*/
private static function get_all_template_overrides() {
@ -391,11 +428,65 @@ class WC_Tracker {
/**
* When an admin user logs in, there user agent is tracked in user meta and collected here.
*
* @return array
*/
private static function get_admin_user_agents() {
return array_filter( (array) get_option( 'woocommerce_tracker_ua', array() ) );
}
/**
* Get order totals
*
* @return array
*/
private static function get_order_totals() {
global $wpdb;
$gross_total = $wpdb->get_var( "
SELECT
SUM( order_meta.meta_value ) AS 'gross_total'
FROM {$wpdb->prefix}posts AS orders
LEFT JOIN {$wpdb->prefix}postmeta AS order_meta ON order_meta.post_id = orders.ID
WHERE order_meta.meta_key = '_order_total'
AND orders.post_status = 'wc-completed'
GROUP BY order_meta.meta_key
" );
if ( is_null( $gross_total ) ) {
$gross_total = 0;
}
return array(
'gross' => $gross_total,
);
}
/**
* Get last order date
*
* @return string
*/
private static function get_order_dates() {
global $wpdb;
$min_max = $wpdb->get_row( "
SELECT
MIN( post_date_gmt ) as 'first', MAX( post_date_gmt ) as 'last'
FROM {$wpdb->prefix}posts
WHERE post_type = 'shop_order'
AND post_status = 'wc-completed'
", ARRAY_A );
if ( is_null( $min_max ) ) {
$min_max = array(
'first' => '-',
'last' => '-',
);
}
return $min_max;
}
}
WC_Tracker::init();

View File

@ -708,7 +708,7 @@ class WC_Shop_Customizer {
$wp_customize->add_setting(
'woocommerce_checkout_' . $field . '_field',
array(
'default' => 'optional',
'default' => 'phone' === $field ? 'required' : 'optional',
'type' => 'option',
'capability' => 'manage_woocommerce',
'sanitize_callback' => array( $this, 'sanitize_checkout_field_display' ),
@ -844,9 +844,9 @@ class WC_Shop_Customizer {
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial(
'woocommerce_checkout_privacy_policy_text', array(
'selector' => '.woocommerce-terms-and-conditions-text',
'container_inclusive' => false,
'render_callback' => 'wc_privacy_policy_text',
'selector' => '.woocommerce-privacy-policy-text',
'container_inclusive' => true,
'render_callback' => 'wc_checkout_privacy_policy_text',
)
);
$wp_customize->selective_refresh->add_partial(

View File

@ -153,8 +153,13 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
}
$customer_id = $customer->get_id();
// Load meta but exclude deprecated props.
$user_meta = array_diff_key( array_map( 'wc_flatten_meta_callback', get_user_meta( $customer_id ) ), array_flip( array( 'country', 'state', 'postcode', 'city', 'address', 'address_2', 'default', 'location' ) ) );
$user_meta = array_diff_key(
array_map( 'wc_flatten_meta_callback', get_user_meta( $customer_id ) ),
array_flip( array( 'country', 'state', 'postcode', 'city', 'address', 'address_2', 'default', 'location' ) )
);
$customer->set_props( $user_meta );
$customer->set_props(
array(
@ -188,6 +193,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
), $customer
)
);
// Only update password if a new one was set with set_password.
if ( $customer->get_password() ) {
wp_update_user(
@ -198,6 +204,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
);
$customer->set_password( '' );
}
$this->update_user_meta( $customer );
$customer->set_date_modified( get_user_meta( $customer->get_id(), 'last_update', true ) );
$customer->save_meta_data();
@ -216,6 +223,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
if ( ! $customer->get_id() ) {
return;
}
$args = wp_parse_args(
$args, array(
'reassign' => 0,
@ -270,9 +278,11 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
foreach ( $billing_address_props as $meta_key => $prop ) {
$prop_key = substr( $prop, 8 );
if ( ! isset( $changed_props['billing'] ) || ! array_key_exists( $prop_key, $changed_props['billing'] ) ) {
continue;
}
if ( update_user_meta( $customer->get_id(), $meta_key, $customer->{"get_$prop"}( 'edit' ) ) ) {
$updated_props[] = $prop;
}
@ -292,9 +302,11 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
foreach ( $shipping_address_props as $meta_key => $prop ) {
$prop_key = substr( $prop, 9 );
if ( ! isset( $changed_props['shipping'] ) || ! array_key_exists( $prop_key, $changed_props['shipping'] ) ) {
continue;
}
if ( update_user_meta( $customer->get_id(), $meta_key, $customer->{"get_$prop"}( 'edit' ) ) ) {
$updated_props[] = $prop;
}
@ -326,11 +338,11 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
// phpcs:enable
);
if ( $last_order ) {
return wc_get_order( absint( $last_order ) );
} else {
if ( ! $last_order ) {
return false;
}
return wc_get_order( absint( $last_order ) );
}
/**
@ -371,7 +383,11 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
* @return float
*/
public function get_total_spent( &$customer ) {
$spent = apply_filters( 'woocommerce_customer_get_total_spent', get_user_meta( $customer->get_id(), '_money_spent', true ), $customer );
$spent = apply_filters(
'woocommerce_customer_get_total_spent',
get_user_meta( $customer->get_id(), '_money_spent', true ),
$customer
);
if ( '' === $spent ) {
global $wpdb;

View File

@ -232,7 +232,7 @@ class WC_Data_Store_WP {
$wp_query_args['meta_query'][] = array(
'key' => '_' . $key,
'value' => $value,
'compare' => '=',
'compare' => is_array( $value ) ? 'IN' : '=',
);
} else { // Other vars get mapped to wp_query args or just left alone.
$key_mapping = array(

View File

@ -132,7 +132,7 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
public function prepare_data_to_export() {
$columns = $this->get_column_names();
$args = apply_filters( "woocommerce_product_export_{$this->export_type}_query_args", array(
'status' => array( 'private', 'publish', 'draft' ),
'status' => array( 'private', 'publish', 'draft', 'future' ),
'type' => $this->product_types_to_export,
'limit' => $this->get_limit(),
'page' => $this->get_page(),

View File

@ -29,7 +29,7 @@ abstract class WC_Gateway_Paypal_Response {
*/
protected function get_paypal_order( $raw_custom ) {
// We have the data in the correct format, so get the order.
$custom = wp_json_decode( $raw_custom );
$custom = json_decode( $raw_custom );
if ( $custom && is_object( $custom ) ) {
$order_id = $custom->order_id;
$order_key = $custom->order_key;

View File

@ -543,7 +543,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
* @return int
*/
public function parse_int_field( $value ) {
// Remove the ' prepended to fields that start with - if needed
// Remove the ' prepended to fields that start with - if needed.
$value = $this->unescape_negative_number( $value );
return intval( $value );

View File

@ -480,10 +480,12 @@ function wc_get_cart_item_data_hash( $product ) {
return md5(
wp_json_encode(
apply_filters(
'woocommerce_cart_item_data_to_validate', array(
'woocommerce_cart_item_data_to_validate',
array(
'type' => $product->get_type(),
'attributes' => 'variation' === $product->get_type() ? $product->get_variation_attributes() : '',
)
),
$product
)
)
);

View File

@ -537,9 +537,9 @@ function wc_product_has_unique_sku( $product_id, $sku ) {
if ( apply_filters( 'wc_product_has_unique_sku', $sku_found, $product_id, $sku ) ) {
return false;
} else {
return true;
}
return true;
}
/**

View File

@ -789,6 +789,28 @@ function wc_terms_and_conditions_page_content() {
}
}
/**
* Render privacy policy text on the checkout.
*
* @since 3.4.0
*/
function wc_checkout_privacy_policy_text() {
echo '<div class="woocommerce-privacy-policy-text">';
wc_privacy_policy_text( 'checkout' );
echo '</div>';
}
/**
* Render privacy policy text on the register forms.
*
* @since 3.4.0
*/
function wc_registration_privacy_policy_text() {
echo '<div class="woocommerce-privacy-policy-text">';
wc_privacy_policy_text( 'registration' );
echo '</div>';
}
/**
* Output privacy policy text. This is custom text which can be added via the customizer/privacy settings section.
*
@ -797,22 +819,11 @@ function wc_terms_and_conditions_page_content() {
* @since 3.4.0
* @param string $type Type of policy to load. Valid values include registration and checkout.
*/
function wc_privacy_policy_text( $type = '' ) {
function wc_privacy_policy_text( $type = 'checkout' ) {
if ( ! wc_privacy_policy_page_id() ) {
return;
}
if ( ! $type ) {
$type = is_checkout() ? 'checkout' : 'registration';
}
$text = wc_get_privacy_policy_text( $type );
if ( ! $text ) {
return;
}
echo '<div class="woocommerce-terms-and-conditions-text">' . wp_kses_post( wpautop( wc_replace_policy_page_link_placeholders( $text ) ) ) . '</div>';
echo wp_kses_post( wpautop( wc_replace_policy_page_link_placeholders( wc_get_privacy_policy_text( $type ) ) ) );
}
/**

View File

@ -212,7 +212,7 @@ add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_privacy_policy_text', 20 );
add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 );
add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
/**
@ -287,4 +287,4 @@ add_action( 'woocommerce_account_edit-address_endpoint', 'woocommerce_account_ed
add_action( 'woocommerce_account_payment-methods_endpoint', 'woocommerce_account_payment_methods' );
add_action( 'woocommerce_account_add-payment-method_endpoint', 'woocommerce_account_add_payment_method' );
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_account' );
add_action( 'woocommerce_register_form', 'wc_privacy_policy_text', 20 );
add_action( 'woocommerce_register_form', 'wc_registration_privacy_policy_text', 20 );

View File

@ -42,7 +42,7 @@ test.describe( 'Checkout Page', function() {
baseLocation: [ 'United States', 'United States (US) — California' ],
sellingLocation: 'Sell to all countries',
enableTaxes: true,
currency: [ 'United States', 'United States dollar ($)' ],
currency: [ 'United States', 'United States (US) dollar ($)' ],
} );
// Make sure payment method is set in setting.

View File

@ -68,14 +68,14 @@ test.describe( 'Add New Product Page', function() {
attr1.toggle();
const attr2 = panelAttributes.add();
assert.eventually.ok( attr1.displayed() );
assert.eventually.ok( attr2.displayed() );
attr2.setName( 'attr #2' );
attr2.checkVisibleOnTheProductPage();
attr2.checkUsedForVariations();
attr2.setValue( 'val1 | val2' );
const attr3 = panelAttributes.add();
assert.eventually.ok( attr1.displayed() );
assert.eventually.ok( attr3.displayed() );
attr3.setName( 'attr #3' );
attr3.checkVisibleOnTheProductPage();
attr3.checkUsedForVariations();

View File

@ -46,6 +46,7 @@ class WC_Tests_Customer_Functions extends WC_Unit_Test_Case {
$this->assertEquals( 'fred2', $userdata->user_login );
// No password.
update_option( 'woocommerce_registration_generate_password', 'no' );
$id = wc_create_new_customer( 'joe@example.com', 'joecustomer', '' );
$this->assertInstanceOf( 'WP_Error', $id );

View File

@ -10,6 +10,8 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
* Load up the exporter classes since they aren't loaded by default.
*/
public function setUp() {
parent::setUp();
$bootstrap = WC_Unit_Tests_Bootstrap::instance();
require_once $bootstrap->plugin_dir . '/includes/export/class-wc-product-csv-exporter.php';
}
@ -69,12 +71,24 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
$expected = 'cat1, cat2, cat3';
$this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) );
wp_insert_category( array( 'cat_ID' => $term2, 'cat_name' => 'cat2', 'category_parent' => $term1 ) );
wp_insert_category(
array(
'cat_ID' => $term2,
'cat_name' => 'cat2',
'category_parent' => $term1,
)
);
$expected = 'cat1, cat1 > cat2, cat3';
$this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) );
wp_insert_category( array( 'cat_ID' => $term3, 'cat_name' => 'cat3', 'category_parent' => $term2 ) );
wp_insert_category(
array(
'cat_ID' => $term3,
'cat_name' => 'cat3',
'category_parent' => $term2,
)
);
$expected = 'cat1, cat1 > cat2, cat1 > cat2 > cat3';
$this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) );
}
@ -96,7 +110,7 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
$product->set_width( 1 );
$sale_start = time();
$sale_end = $sale_start + DAY_IN_SECONDS;
$sale_end = $sale_start + DAY_IN_SECONDS;
$product->set_date_on_sale_from( $sale_start );
$product->set_date_on_sale_to( $sale_end );
@ -136,9 +150,9 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
$this->assertContains( $row['backorders'], array( 1, 0, 'notify' ) );
$expected_parent = '';
$parent_id = $product->get_parent_id();
$parent_id = $product->get_parent_id();
if ( $parent_id ) {
$parent = wc_get_product( $parent_id );
$parent = wc_get_product( $parent_id );
$expected_parent = $parent->get_sku() ? $parent->get_sku() : 'id:' . $parent->get_id();
}
$this->assertEquals( $expected_parent, $row['parent_id'] );

View File

@ -17,6 +17,8 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
parent::setUp();
$this->csv_file = dirname( __FILE__ ) . '/sample.csv';
$bootstrap = WC_Unit_Tests_Bootstrap::instance();
@ -97,11 +99,6 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
$this->assertEquals( 0, count( $results['failed'] ) );
$this->assertEquals( 0, count( $results['updated'] ) );
$this->assertEquals( 0, count( $results['skipped'] ) );
// Exclude imported products.
foreach ( $results['imported'] as $id ) {
wp_delete_post( $id, true );
}
}
/**
@ -135,7 +132,13 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
* @since 3.1.0
*/
public function test_get_raw_data() {
$importer = new WC_Product_CSV_Importer( $this->csv_file, array( 'parse' => false, 'lines' => 2 ) );
$importer = new WC_Product_CSV_Importer(
$this->csv_file,
array(
'parse' => false,
'lines' => 2,
)
);
$items = array(
array(
'simple',
@ -433,40 +436,40 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'menu_order' => 3,
),
array(
'type' => 'variation',
'sku' => '',
'name' => '',
'featured' => '',
'catalog_visibility' => 'visible',
'short_description' => '',
'description' => 'Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.',
'date_on_sale_from' => null,
'date_on_sale_to' => null,
'tax_status' => 'taxable',
'tax_class' => 'standard',
'stock_status' => 'instock',
'stock_quantity' => 6,
'backorders' => 'no',
'sold_individually' => '',
'weight' => 1.0,
'length' => 2.0,
'width' => 25.0,
'height' => 55.0,
'reviews_allowed' => '',
'purchase_note' => '',
'sale_price' => '',
'regular_price' => '20',
'shipping_class_id' => 0,
'download_limit' => 0,
'download_expiry' => 0,
'product_url' => '',
'button_text' => '',
'status' => 'publish',
'raw_image_id' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'virtual' => false,
'downloadable' => false,
'manage_stock' => true,
'raw_attributes' => array(
'type' => 'variation',
'sku' => '',
'name' => '',
'featured' => '',
'catalog_visibility' => 'visible',
'short_description' => '',
'description' => 'Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.',
'date_on_sale_from' => null,
'date_on_sale_to' => null,
'tax_status' => 'taxable',
'tax_class' => 'standard',
'stock_status' => 'instock',
'stock_quantity' => 6,
'backorders' => 'no',
'sold_individually' => '',
'weight' => 1.0,
'length' => 2.0,
'width' => 25.0,
'height' => 55.0,
'reviews_allowed' => '',
'purchase_note' => '',
'sale_price' => '',
'regular_price' => '20',
'shipping_class_id' => 0,
'download_limit' => 0,
'download_expiry' => 0,
'product_url' => '',
'button_text' => '',
'status' => 'publish',
'raw_image_id' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'virtual' => false,
'downloadable' => false,
'manage_stock' => true,
'raw_attributes' => array(
array(
'name' => 'Color',
),
@ -475,7 +478,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'name' => 'Size',
),
),
'menu_order' => 1,
'menu_order' => 1,
),
array(
'type' => 'variation',
@ -520,7 +523,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'name' => 'Size',
),
),
'menu_order' => 2,
'menu_order' => 2,
),
array(
'type' => 'grouped',
@ -569,15 +572,5 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
}
$this->assertEquals( $items, $parsed_data );
// Remove temporary products.
$temp_products = get_posts( array(
'post_status' => 'importing',
'post_type' => 'product',
'fields' => 'ids',
) );
foreach ( $temp_products as $id ) {
wp_delete_post( $id, true );
}
}
}

View File

@ -11,7 +11,10 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
* Suppress deprecation notice from WC_Order_Item_Meta constructor.
*/
public function setUp() {
add_filter( 'deprecated_function_trigger_error', '__return_false' );
parent::setUp();
wp_insert_term( 'Testing Categories', 'category', array( 'slug' => 'testing' ) );
$this->setExpectedDeprecated( 'WC_Order_Item_Meta::__construct' );
}
/**
@ -29,7 +32,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$expected = array();
foreach ( $item->get_meta_data() as $metadata ) {
$expected[ $metadata->id ] = array(
'key' => $metadata->key,
'key' => $metadata->key,
'label' => wc_attribute_label( $metadata->key, null ),
'value' => $metadata->value,
);
@ -39,9 +42,6 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$this->assertEquals( 3, count( $result ) );
$this->assertEquals( $expected, $result );
// Clean up.
$item->delete( true );
}
/**
@ -50,8 +50,6 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
* @since 3.2.0
*/
public function test_get_formatted() {
wp_insert_term( 'Testing Categories', 'category', array( 'slug' => 'testing' ) );
$item = new WC_Order_Item_Fee();
$item->add_meta_data( 'regularkey', '1' );
$item->add_meta_data( 'category', 'testing' );
@ -60,12 +58,12 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$meta = new WC_Order_Item_Meta( $item );
$expected = array( 'regularkey' => '1', 'category' => 'Testing Categories' );
$actual = wp_list_pluck( $meta->get_formatted(), 'value', 'key' );
$expected = array(
'regularkey' => '1',
'category' => 'Testing Categories',
);
$actual = wp_list_pluck( $meta->get_formatted(), 'value', 'key' );
$this->assertEquals( $expected, $actual );
// Clean up.
$item->delete( true );
}
@ -84,7 +82,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$meta = new WC_Order_Item_Meta( $item );
$expected = "regularkey: 1, \ncategory: Testing Categories";
$flat = $meta->display( true, true );
$flat = $meta->display( true, true );
$this->assertEquals( $expected, $flat );
$not_flat = $meta->display( false, true );
@ -92,8 +90,5 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$this->assertContains( 'class="variation-regularkey"><p>1</p>', $not_flat );
$this->assertContains( 'class="variation-category">category:', $not_flat );
$this->assertContains( 'class="variation-category"><p>Testing Categories</p>', $not_flat );
// Clean up.
$item->delete( true );
}
}

View File

@ -24,6 +24,8 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
parent::setUp();
$customer1 = WC_Helper_Customer::create_customer( 'customer1', 'password', 'test1@test.com' );
$customer1->set_billing_email( 'customer1@test.com' );
$customer1->save();
@ -51,18 +53,6 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
$this->orders[] = WC_Helper_Order::create_order( $customer2->get_id() );
}
/**
* Clean up after test.
*/
public function tearDown() {
foreach ( $this->orders as $object ) {
$object->delete( true );
}
foreach ( $this->customers as $object ) {
$object->delete( true );
}
}
/**
* Test: Customer data exporter.
*/
@ -74,67 +64,70 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
// Do a test export and check response.
$response = WC_Privacy::customer_data_exporter( 'test1@test.com', 1 );
$this->assertTrue( $response['done'] );
$this->assertEquals( array(
$this->assertEquals(
array(
'group_id' => 'woocommerce_customer',
'group_label' => 'Customer Data',
'item_id' => 'user',
'data' => array(
array(
'name' => 'Billing Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Billing Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Billing City',
'value' => 'Philadelphia',
),
array(
'name' => 'Billing Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Billing State',
'value' => 'PA',
),
array(
'name' => 'Billing Country',
'value' => 'US',
),
array(
'name' => 'Email Address',
'value' => 'customer1@test.com',
),
array(
'name' => 'Shipping Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Shipping Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Shipping City',
'value' => 'Philadelphia',
),
array(
'name' => 'Shipping Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Shipping State',
'value' => 'PA',
),
array(
'name' => 'Shipping Country',
'value' => 'US',
array(
'group_id' => 'woocommerce_customer',
'group_label' => 'Customer Data',
'item_id' => 'user',
'data' => array(
array(
'name' => 'Billing Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Billing Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Billing City',
'value' => 'Philadelphia',
),
array(
'name' => 'Billing Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Billing State',
'value' => 'PA',
),
array(
'name' => 'Billing Country',
'value' => 'US',
),
array(
'name' => 'Email Address',
'value' => 'customer1@test.com',
),
array(
'name' => 'Shipping Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Shipping Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Shipping City',
'value' => 'Philadelphia',
),
array(
'name' => 'Shipping Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Shipping State',
'value' => 'PA',
),
array(
'name' => 'Shipping Country',
'value' => 'US',
),
),
),
),
), $response['data'] );
$response['data']
);
}
/**

View File

@ -28,13 +28,15 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
* Setup the cart for totals calculation.
*/
public function setUp() {
parent::setUp();
$this->ids = array();
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
define( 'WOOCOMMERCE_CHECKOUT', 1 );
}
$tax_rate = array(
$tax_rate = array(
'tax_rate_country' => '',
'tax_rate_state' => '',
'tax_rate' => '20.0000',
@ -54,7 +56,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
$product = WC_Helper_Product::create_simple_product();
$product2 = WC_Helper_Product::create_simple_product();
// Variations with parent tax class.
$product3 = WC_Helper_Product::create_variation_product();
$product3 = WC_Helper_Product::create_variation_product();
$variations = $product3->get_available_variations();
// Update product3 so that each variation has the parent tax class.
@ -67,7 +69,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
WC_Helper_Shipping::create_simple_flat_rate();
WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
$coupon = new WC_Coupon;
$coupon = new WC_Coupon();
$coupon->set_code( 'test-coupon-10' );
$coupon->set_amount( 10 );
$coupon->set_discount_type( 'percent' );
@ -131,19 +133,22 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
* Test get and set items.
*/
public function test_get_totals() {
$this->assertEquals( array(
'fees_total' => 40.00,
'fees_total_tax' => 6.00,
'items_subtotal' => 40.00,
'items_subtotal_tax' => 8.00,
'items_total' => 36.00,
'items_total_tax' => 7.20,
'total' => 101.20,
'shipping_total' => 10,
'shipping_tax_total' => 2,
'discounts_total' => 4.00,
'discounts_tax_total' => 0.80,
), $this->totals->get_totals() );
$this->assertEquals(
array(
'fees_total' => 40.00,
'fees_total_tax' => 6.00,
'items_subtotal' => 40.00,
'items_subtotal_tax' => 8.00,
'items_total' => 36.00,
'items_total_tax' => 7.20,
'total' => 101.20,
'shipping_total' => 10,
'shipping_tax_total' => 2,
'discounts_total' => 4.00,
'discounts_tax_total' => 0.80,
),
$this->totals->get_totals()
);
}
/**