Merge branch 'master' into update/store-owner-newsletter

# Conflicts:
#	assets/css/admin-rtl.css
#	assets/css/admin.css
#	assets/css/twenty-seventeen-rtl.css
#	assets/css/twenty-seventeen.css
#	assets/css/woocommerce-rtl.css
#	assets/css/woocommerce.css
This commit is contained in:
Mike Jolley 2017-08-18 18:21:55 +01:00
commit 0dc1754b91
115 changed files with 2694 additions and 1564 deletions

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#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;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;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}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#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;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}

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#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;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;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}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#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;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}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -565,9 +565,19 @@ table.wc_status_table {
width: 1em;
}
td {
padding: 9px;
td, th {
padding: 2em;
font-size: 1.1em;
font-weight: normal;
&.run-tool {
text-align:right;
}
strong.name {
display: block;
margin-bottom: .5em;
}
mark {
background: transparent none;
@ -581,7 +591,7 @@ table.wc_status_table {
color: #999;
}
mark.error {
mark.error, .red {
color: $red;
}
@ -797,22 +807,56 @@ ul.wc_coupon_list,
clear: both;
}
ul.wc_coupon_list li {
margin: 0;
ul.wc_coupon_list {
padding-bottom: 5px;
&.code {
display: inline-block;
li {
margin: 0;
&::after {
content: ', ';
}
&.code {
display: inline-block;
position: relative;
padding-right: 2em;
padding-left: .5em;
background-color: #fff;
border: 1px solid #aaa;
-webkit-box-shadow: 0 1px 0 #dfdfdf;
box-shadow: 0 1px 0 #dfdfdf;
&:last-of-type::after {
display: none;
}
border-radius: 4px;
margin-right: 5px;
margin-top: 5px;
.tips {
cursor: pointer;
.tips {
cursor: pointer;
span {
color: #888;
&:hover {
color: #000;
}
}
}
.remove-coupon {
text-decoration: none;
color: #888;
position: absolute;
top: 7px;
right: 20px;
/*rtl:raw:
left: 7px;
*/
&::before {
@include icon_dashicons( '\f158' );
}
&:hover::before {
color: $red;
}
}
}
}
}
@ -1565,7 +1609,7 @@ ul.wc_coupon_list_block {
font-size: 1.5em;
line-height: 1em;
vertical-align: middle;
margin: 0;
margin: 0 auto;
&::before {
@include icon( '\e007' );
@ -1578,7 +1622,7 @@ ul.wc_coupon_list_block {
font-size: 1.5em;
line-height: 1em;
vertical-align: middle;
margin: 0;
margin: 0 auto;
&::before {
@include icon( '\e014' );
@ -1592,7 +1636,7 @@ ul.wc_coupon_list_block {
font-size: 1.5em;
line-height: 1em;
vertical-align: middle;
margin: 0;
margin: 0 auto;
&::before {
@include icon( '\e01a' );
@ -3010,7 +3054,6 @@ img.help_tip {
nav.woo-nav-tab-wrapper {
margin: 1.5em 0 1em;
border-bottom: 1px solid #ccc;
}
.subsubsub {

View File

@ -1 +1 @@
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;text-align:center;float:right;font-size:.8em;border-right:1px solid #fff;border-left:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-right:0}ul.woocommerce_stats li:last-child{border-left:0}ul.woocommerce_stats strong{font-family:Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:right;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:left;position:absolute;left:0;top:50%;margin-left:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover::before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;right:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:right;margin-left:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a::before{font-family:Dashicons;content:'\f185'}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-left:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.processing-orders a::before{content:'\e011';color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a::before{content:'\e033';color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock{border-left:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a::before{content:'\e016';color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a::before{content:'\e013';color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:right;margin:0 0 5px 10px}#woocommerce_dashboard_recent_reviews .star-rating{float:left;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-right:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b2b2;float:right;top:0;right:0;position:absolute;letter-spacing:.1em}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:right;top:0;right:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span::before{content:'\e020\e020\e020\e020\e020';top:0;position:absolute;right:0;letter-spacing:.1em;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;text-align:center;float:right;font-size:.8em;border-right:1px solid #fff;border-left:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-right:0}ul.woocommerce_stats li:last-child{border-left:0}ul.woocommerce_stats strong{font-family:Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:right;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;-webkit-transition:all ease .5s;transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:left;position:absolute;left:0;top:50%;margin-left:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover::before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;right:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:right;margin-left:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a::before{font-family:Dashicons;content:'\f185'}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-left:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.processing-orders a::before{content:'\e011';color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a::before{content:'\e033';color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock{border-left:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a::before{content:'\e016';color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a::before{content:'\e013';color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:right;margin:0 0 5px 10px}#woocommerce_dashboard_recent_reviews .star-rating{float:left;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-right:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b2b2;float:right;top:0;right:0;position:absolute;letter-spacing:.1em}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:right;top:0;right:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span::before{content:'\e020\e020\e020\e020\e020';top:0;position:absolute;right:0;letter-spacing:.1em;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}

View File

@ -1 +1 @@
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;text-align:center;float:left;font-size:.8em;border-left:1px solid #fff;border-right:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-left:0}ul.woocommerce_stats li:last-child{border-right:0}ul.woocommerce_stats strong{font-family:Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:left;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:right;position:absolute;right:0;top:50%;margin-right:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover::before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left;margin-right:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a::before{font-family:Dashicons;content:'\f185'}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.processing-orders a::before{content:'\e011';color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a::before{content:'\e033';color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock{border-right:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a::before{content:'\e016';color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a::before{content:'\e013';color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:left;margin:0 10px 5px 0}#woocommerce_dashboard_recent_reviews .star-rating{float:right;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-left:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b2b2;float:left;top:0;left:0;position:absolute;letter-spacing:.1em}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:left;top:0;left:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span::before{content:'\e020\e020\e020\e020\e020';top:0;position:absolute;left:0;letter-spacing:.1em;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;text-align:center;float:left;font-size:.8em;border-left:1px solid #fff;border-right:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-left:0}ul.woocommerce_stats li:last-child{border-right:0}ul.woocommerce_stats strong{font-family:Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:left;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;-webkit-transition:all ease .5s;transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:right;position:absolute;right:0;top:50%;margin-right:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover::before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left;margin-right:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a::before{font-family:Dashicons;content:'\f185'}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.processing-orders a::before{content:'\e011';color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a::before{content:'\e033';color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock{border-right:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a::before{content:'\e016';color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a::before{content:'\e013';color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:left;margin:0 10px 5px 0}#woocommerce_dashboard_recent_reviews .star-rating{float:right;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-left:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b2b2;float:left;top:0;left:0;position:absolute;letter-spacing:.1em}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:left;top:0;left:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span::before{content:'\e020\e020\e020\e020\e020';top:0;position:absolute;left:0;letter-spacing:.1em;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
*{background:0 0!important;color:#000!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-right:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-right:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-right:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}
*{background:0 0!important;color:#000!important;text-shadow:none!important;-webkit-filter:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-right:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-right:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-right:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}

View File

@ -1 +1 @@
*{background:0 0!important;color:#000!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-left:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-left:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-left:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}
*{background:0 0!important;color:#000!important;text-shadow:none!important;-webkit-filter:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-left:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-left:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-left:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -367,6 +367,12 @@ table.variations {
figure {
margin: 0;
padding: 0;
}
.woocommerce-product-gallery__wrapper {
margin: 0;
padding: 0;
}
.zoomImg {
@ -561,6 +567,10 @@ button.pswp__button--zoom:hover {
background-position: -88px 0;
}
.pswp img {
max-width: none;
}
/**
* Widgets
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -169,6 +169,8 @@ p.demo_store,
.woocommerce-product-gallery__wrapper {
transition: all cubic-bezier(0.795, -0.035, 0.000, 1.000) .5s;
margin: 0;
padding: 0;
}
.woocommerce-product-gallery__wrapper .zoomImg {

View File

@ -1 +1 @@
!function(e,t,n){"use strict";e.fn.WCBackboneModal=function(t){return this.each(function(){new e.WCBackboneModal(e(this),t)})},e.WCBackboneModal=function(t,n){var o=e.extend({},e.WCBackboneModal.defaultOptions,n);o.template&&new e.WCBackboneModal.View({target:o.template,string:o.variable})},e.WCBackboneModal.defaultOptions={template:"",variable:{}},e.WCBackboneModal.View=t.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:undefined,_string:undefined,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions"},resizeContent:function(){var t=e(".wc-backbone-modal-content").find("article"),n=.75*e(window).height();t.css({"max-height":n+"px"})},initialize:function(t){var o=this;this._target=t.target,this._string=t.string,n.bindAll(this,"render"),this.render(),e(window).resize(function(){o.resizeContent()})},render:function(){var t=wp.template(this._target);this.$el.attr("tabindex","0").append(t(this._string)),e(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$el.focus(),e(document.body).trigger("init_tooltips"),e(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(t){t.preventDefault(),e(document.body).trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),e(document).off("focusin"),e(document.body).css({overflow:"auto"}),this.remove(),e(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(t){e(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(t)},getFormData:function(){var t={};return e(document.body).trigger("wc_backbone_modal_before_update",this._target),e.each(e("form",this.$el).serializeArray(),function(n,o){-1!==o.name.indexOf("[]")?(o.name=o.name.replace("[]",""),t[o.name]=e.makeArray(t[o.name]),t[o.name].push(o.value)):t[o.name]=o.value}),t},keyboardActions:function(e){var t=e.keyCode||e.which;13!==t||e.target.tagName&&("input"===e.target.tagName.toLowerCase()||"textarea"===e.target.tagName.toLowerCase())||this.addButton(e),27===t&&this.closeButton(e)}})}(jQuery,Backbone,_);
!function(e,t,n){"use strict";e.fn.WCBackboneModal=function(t){return this.each(function(){new e.WCBackboneModal(e(this),t)})},e.WCBackboneModal=function(t,n){var o=e.extend({},e.WCBackboneModal.defaultOptions,n);o.template&&new e.WCBackboneModal.View({target:o.template,string:o.variable})},e.WCBackboneModal.defaultOptions={template:"",variable:{}},e.WCBackboneModal.View=t.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:undefined,_string:undefined,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions"},resizeContent:function(){var t=e(".wc-backbone-modal-content").find("article"),n=.75*e(window).height();t.css({"max-height":n+"px"})},initialize:function(t){var o=this;this._target=t.target,this._string=t.string,n.bindAll(this,"render"),this.render(),e(window).resize(function(){o.resizeContent()})},render:function(){var t=wp.template(this._target);this.$el.append(t(this._string)),e(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$(".wc-backbone-modal-content").attr("tabindex","0").focus(),e(document.body).trigger("init_tooltips"),e(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(t){t.preventDefault(),e(document.body).trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),e(document).off("focusin"),e(document.body).css({overflow:"auto"}),this.remove(),e(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(t){e(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(t)},getFormData:function(){var t={};return e(document.body).trigger("wc_backbone_modal_before_update",this._target),e.each(e("form",this.$el).serializeArray(),function(n,o){-1!==o.name.indexOf("[]")?(o.name=o.name.replace("[]",""),t[o.name]=e.makeArray(t[o.name]),t[o.name].push(o.value)):t[o.name]=o.value}),t},keyboardActions:function(e){var t=e.keyCode||e.which;13!==t||e.target.tagName&&("input"===e.target.tagName.toLowerCase()||"textarea"===e.target.tagName.toLowerCase())||this.addButton(e),27===t&&this.closeButton(e)}})}(jQuery,Backbone,_);

View File

@ -234,6 +234,8 @@ jQuery( function ( $ ) {
$( '#woocommerce-order-items' )
.on( 'click', 'button.add-line-item', this.add_line_item )
.on( 'click', 'button.add-coupon', this.add_coupon )
.on( 'click', 'a.remove-coupon', this.remove_coupon )
.on( 'click', 'button.refund-items', this.refund_items )
.on( 'click', '.cancel-action', this.cancel )
.on( 'click', 'button.add-order-item', this.add_item )
@ -376,6 +378,62 @@ jQuery( function ( $ ) {
return false;
},
add_coupon: function() {
var value = window.prompt( woocommerce_admin_meta_boxes.i18n_apply_coupon );
if ( value != null ) {
wc_meta_boxes_order_items.block();
var data = {
action : 'woocommerce_add_coupon_discount',
dataType : 'json',
order_id : woocommerce_admin_meta_boxes.post_id,
security : woocommerce_admin_meta_boxes.order_item_nonce,
coupon : value
};
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
wc_meta_boxes_order_items.unblock();
});
}
return false;
},
remove_coupon: function() {
var $this = $( this );
wc_meta_boxes_order_items.block();
var data = {
action : 'woocommerce_remove_order_coupon',
dataType : 'json',
order_id : woocommerce_admin_meta_boxes.post_id,
security : woocommerce_admin_meta_boxes.order_item_nonce,
coupon : $this.data( 'code' )
};
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
wc_meta_boxes_order_items.unblock();
});
},
refund_items: function() {
$( 'div.wc-order-refund-items' ).slideDown();
$( 'div.wc-order-data-row-toggle' ).not( 'div.wc-order-refund-items' ).slideUp();
@ -478,17 +536,26 @@ jQuery( function ( $ ) {
wc_meta_boxes_order_items.block();
var data = {
order_id : woocommerce_admin_meta_boxes.post_id,
order_item_ids: order_item_id,
action: 'woocommerce_remove_order_item',
security: woocommerce_admin_meta_boxes.order_item_nonce
action : 'woocommerce_remove_order_item',
security : woocommerce_admin_meta_boxes.order_item_nonce
};
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function() {
$item.remove();
success: function( response ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
wc_meta_boxes_order_items.unblock();
}
});
@ -512,11 +579,16 @@ jQuery( function ( $ ) {
data: data,
type: 'POST',
success: function( response ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response );
wc_meta_boxes_order.init_tiptip();
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
}
});
}
@ -885,6 +957,7 @@ jQuery( function ( $ ) {
deferred.push( $.ajax({
url : woocommerce_admin_meta_boxes.ajax_url,
data: {
order_id : woocommerce_admin_meta_boxes.post_id,
order_item_ids: delete_items,
action: 'woocommerce_remove_order_item',
security: woocommerce_admin_meta_boxes.order_item_nonce

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -257,7 +257,7 @@ jQuery( function( $ ) {
date_picker_select( $( this ) );
}
});
$( this ).find( 'input' ).each( function() { date_picker_select( $( this ) ) } );
$( this ).find( 'input' ).each( function() { date_picker_select( $( this ) ); } );
});
// ATTRIBUTE TABLES.

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1 +1 @@
!function(e,n,i,o){e(function(){var t=e(".wc-shipping-zones"),s=e(".wc-shipping-zone-rows"),d=e(".wc-shipping-zone-save"),a=i.template("wc-shipping-zone-row"),r=i.template("wc-shipping-zone-row-blank"),l=Backbone.Model.extend({changes:{},logChanges:function(e){var n=this.changes||{};_.each(e,function(e,i){n[i]=_.extend(n[i]||{zone_id:i},e)}),this.changes=n,this.trigger("change:zones")},discardChanges:function(e){var n=this.changes||{},i=null,o=_.indexBy(this.get("zones"),"zone_id");n[e]&&n[e].zone_order!==undefined&&(i=n[e].zone_order),delete n[e],null!==i&&o[e]&&o[e].zone_order!==i&&(n[e]=_.extend(n[e]||{},{zone_id:e,zone_order:i})),this.changes=n,0===_.size(this.changes)&&p.clearUnloadConfirmation()},save:function(){_.size(this.changes)?e.post(o+(o.indexOf("?")>0?"&":"?")+"action=woocommerce_shipping_zones_save_changes",{wc_shipping_zones_nonce:n.wc_shipping_zones_nonce,changes:this.changes},this.onSaveResponse,"json"):h.trigger("saved:zones")},onSaveResponse:function(e,i){"success"===i&&(e.success?(h.set("zones",e.data.zones),h.trigger("change:zones"),h.changes={},h.trigger("saved:zones")):window.alert(n.strings.save_failed))}}),c=Backbone.View.extend({rowTemplate:a,initialize:function(){this.listenTo(this.model,"change:zones",this.setUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.clearUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.render),s.on("change",{view:this},this.updateModelOnChange),s.on("sortupdate",{view:this},this.updateModelOnSort),e(window).on("beforeunload",{view:this},this.unloadConfirmation),e(document.body).on("click",".wc-shipping-zone-add",{view:this},this.onAddNewRow)},block:function(){e(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e(this.el).unblock()},render:function(){var n=_.indexBy(this.model.get("zones"),"zone_id"),i=this;i.$el.empty(),i.unblock(),_.size(n)?(n=_(n).chain().sortBy(function(e){return-1*parseInt(e.zone_id,10)}).sortBy(function(e){return parseInt(e.zone_order,10)}).value(),e.each(n,function(e,n){i.renderRow(n)})):i.$el.append(r),i.initRows()},renderRow:function(e){var n=this;n.$el.append(n.rowTemplate(e)),n.initRow(e)},initRow:function(e){var n=this,i=n.$el.find('tr[data-id="'+e.zone_id+'"]');n.renderShippingMethods(e.zone_id,e.shipping_methods),i.find(".wc-shipping-zone-delete").on("click",{view:this},this.onDeleteRow)},initRows:function(){0==e("tbody.wc-shipping-zone-rows tr").length%2?t.find("tbody.wc-shipping-zone-rows").next("tbody").find("tr").addClass("odd"):t.find("tbody.wc-shipping-zone-rows").next("tbody").find("tr").removeClass("odd"),e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:50})},renderShippingMethods:function(i,o){var t=e('.wc-shipping-zones tr[data-id="'+i+'"]').find(".wc-shipping-zone-methods ul");t.find(".wc-shipping-zone-method").remove(),_.size(o)?(o=_.sortBy(o,function(e){return parseInt(e.method_order,10)}),_.each(o,function(e){var n="method_disabled";"yes"===e.enabled&&(n="method_enabled"),t.append('<li class="wc-shipping-zone-method '+n+'">'+e.title+"</li>")})):t.append('<li class="wc-shipping-zone-method">'+n.strings.no_shipping_methods_offered+"</li>")},onDeleteRow:function(i){var o=i.data.view.model,t=_.indexBy(o.get("zones"),"zone_id"),s={},d=e(this).closest("tr").data("id");i.preventDefault(),window.confirm(n.strings.delete_confirmation_msg)&&t[d]&&(delete t[d],s[d]=_.extend(s[d]||{},{deleted:"deleted"}),o.set("zones",t),o.logChanges(s),i.data.view.block(),i.data.view.model.save())},setUnloadConfirmation:function(){this.needsUnloadConfirm=!0,d.prop("disabled",!1)},clearUnloadConfirmation:function(){this.needsUnloadConfirm=!1,d.prop("disabled",!0)},unloadConfirmation:function(e){if(e.data.view.needsUnloadConfirm)return e.returnValue=n.strings.unload_confirmation_msg,window.event.returnValue=n.strings.unload_confirmation_msg,n.strings.unload_confirmation_msg},updateModelOnChange:function(n){var i=n.data.view.model,o=e(n.target),t=o.closest("tr").data("id"),s=o.data("attribute"),d=o.val(),a=_.indexBy(i.get("zones"),"zone_id"),r={};a[t]&&a[t][s]===d||(r[t]={},r[t][s]=d),i.logChanges(r)},updateModelOnSort:function(n){var i=n.data.view.model,o=_.indexBy(i.get("zones"),"zone_id"),t=e("tbody.wc-shipping-zone-rows tr"),s={};_.each(t,function(n){var i=e(n).data("id"),t=null,d=parseInt(e(n).index(),10);o[i]&&(t=parseInt(o[i].zone_order,10)),t!==d&&(s[i]=_.extend(s[i]||{},{zone_order:d}))}),_.size(s)&&(i.logChanges(s),n.data.view.block(),n.data.view.model.save())}}),h=new l({zones:n.zones}),p=new c({model:h,el:s});p.render(),s.sortable({items:"tr",cursor:"move",axis:"y",handle:"td.wc-shipping-zone-sort",scrollSensitivity:40})})}(jQuery,shippingZonesLocalizeScript,wp,ajaxurl);
!function(e,n,i,o){e(function(){var t=e(".wc-shipping-zones"),s=e(".wc-shipping-zone-rows"),d=e(".wc-shipping-zone-save"),a=i.template("wc-shipping-zone-row"),r=i.template("wc-shipping-zone-row-blank"),l=Backbone.Model.extend({changes:{},logChanges:function(e){var n=this.changes||{};_.each(e,function(e,i){n[i]=_.extend(n[i]||{zone_id:i},e)}),this.changes=n,this.trigger("change:zones")},discardChanges:function(e){var n=this.changes||{},i=null,o=_.indexBy(this.get("zones"),"zone_id");n[e]&&n[e].zone_order!==undefined&&(i=n[e].zone_order),delete n[e],null!==i&&o[e]&&o[e].zone_order!==i&&(n[e]=_.extend(n[e]||{},{zone_id:e,zone_order:i})),this.changes=n,0===_.size(this.changes)&&p.clearUnloadConfirmation()},save:function(){_.size(this.changes)?e.post(o+(o.indexOf("?")>0?"&":"?")+"action=woocommerce_shipping_zones_save_changes",{wc_shipping_zones_nonce:n.wc_shipping_zones_nonce,changes:this.changes},this.onSaveResponse,"json"):h.trigger("saved:zones")},onSaveResponse:function(e,i){"success"===i&&(e.success?(h.set("zones",e.data.zones),h.trigger("change:zones"),h.changes={},h.trigger("saved:zones")):window.alert(n.strings.save_failed))}}),c=Backbone.View.extend({rowTemplate:a,initialize:function(){this.listenTo(this.model,"change:zones",this.setUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.clearUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.render),s.on("change",{view:this},this.updateModelOnChange),s.on("sortupdate",{view:this},this.updateModelOnSort),e(window).on("beforeunload",{view:this},this.unloadConfirmation),e(document.body).on("click",".wc-shipping-zone-add",{view:this},this.onAddNewRow)},block:function(){e(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e(this.el).unblock()},render:function(){var n=_.indexBy(this.model.get("zones"),"zone_id"),i=this;i.$el.empty(),i.unblock(),_.size(n)?(n=_(n).chain().sortBy(function(e){return parseInt(e.zone_id,10)}).sortBy(function(e){return parseInt(e.zone_order,10)}).value(),e.each(n,function(e,n){i.renderRow(n)})):i.$el.append(r),i.initRows()},renderRow:function(e){var n=this;n.$el.append(n.rowTemplate(e)),n.initRow(e)},initRow:function(e){var n=this,i=n.$el.find('tr[data-id="'+e.zone_id+'"]');n.renderShippingMethods(e.zone_id,e.shipping_methods),i.find(".wc-shipping-zone-delete").on("click",{view:this},this.onDeleteRow)},initRows:function(){0==e("tbody.wc-shipping-zone-rows tr").length%2?t.find("tbody.wc-shipping-zone-rows").next("tbody").find("tr").addClass("odd"):t.find("tbody.wc-shipping-zone-rows").next("tbody").find("tr").removeClass("odd"),e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:50})},renderShippingMethods:function(i,o){var t=e('.wc-shipping-zones tr[data-id="'+i+'"]').find(".wc-shipping-zone-methods ul");t.find(".wc-shipping-zone-method").remove(),_.size(o)?(o=_.sortBy(o,function(e){return parseInt(e.method_order,10)}),_.each(o,function(e){var n="method_disabled";"yes"===e.enabled&&(n="method_enabled"),t.append('<li class="wc-shipping-zone-method '+n+'">'+e.title+"</li>")})):t.append('<li class="wc-shipping-zone-method">'+n.strings.no_shipping_methods_offered+"</li>")},onDeleteRow:function(i){var o=i.data.view.model,t=_.indexBy(o.get("zones"),"zone_id"),s={},d=e(this).closest("tr").data("id");i.preventDefault(),window.confirm(n.strings.delete_confirmation_msg)&&t[d]&&(delete t[d],s[d]=_.extend(s[d]||{},{deleted:"deleted"}),o.set("zones",t),o.logChanges(s),i.data.view.block(),i.data.view.model.save())},setUnloadConfirmation:function(){this.needsUnloadConfirm=!0,d.prop("disabled",!1)},clearUnloadConfirmation:function(){this.needsUnloadConfirm=!1,d.prop("disabled",!0)},unloadConfirmation:function(e){if(e.data.view.needsUnloadConfirm)return e.returnValue=n.strings.unload_confirmation_msg,window.event.returnValue=n.strings.unload_confirmation_msg,n.strings.unload_confirmation_msg},updateModelOnChange:function(n){var i=n.data.view.model,o=e(n.target),t=o.closest("tr").data("id"),s=o.data("attribute"),d=o.val(),a=_.indexBy(i.get("zones"),"zone_id"),r={};a[t]&&a[t][s]===d||(r[t]={},r[t][s]=d),i.logChanges(r)},updateModelOnSort:function(n){var i=n.data.view.model,o=_.indexBy(i.get("zones"),"zone_id"),t=e("tbody.wc-shipping-zone-rows tr"),s={};_.each(t,function(n){var i=e(n).data("id"),t=null,d=parseInt(e(n).index(),10);o[i]&&(t=parseInt(o[i].zone_order,10)),t!==d&&(s[i]=_.extend(s[i]||{},{zone_order:d}))}),_.size(s)&&(i.logChanges(s),n.data.view.block(),n.data.view.model.save())}}),h=new l({zones:n.zones}),p=new c({model:h,el:s});p.render(),s.sortable({items:"tr",cursor:"move",axis:"y",handle:"td.wc-shipping-zone-sort",scrollSensitivity:40})})}(jQuery,shippingZonesLocalizeScript,wp,ajaxurl);

View File

@ -6,7 +6,7 @@
var VariationForm = function( $form ) {
this.$form = $form;
this.$attributeFields = $form.find( '.variations select' );
this.$singleVariation = $form.find( '.single_variation' ),
this.$singleVariation = $form.find( '.single_variation' );
this.$singleVariationWrap = $form.find( '.single_variation_wrap' );
this.$resetVariations = $form.find( '.reset_variations' );
this.$product = $form.closest( '.product' );

View File

@ -272,7 +272,7 @@ jQuery( function( $ ) {
$( document ).on(
'wc_update_cart',
this.update_cart );
function() { cart.update_cart.apply( cart, [].slice.call( arguments, 1 ) ); } );
$( document ).on(
'click',
'.woocommerce-cart-form input[type=submit]',

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
!function(t,e,i){function n(){h=e[o](function(){r.each(function(){var e=t(this),i=e.width(),n=e.height(),h=t.data(this,u);i===h.w&&n===h.h||e.trigger(a,[h.w=i,h.h=n])}),n()},s[d])}var h,r=t([]),s=t.resize=t.extend(t.resize,{}),o="setTimeout",a="resize",u=a+"-special-event",d="delay",c="throttleWindow";s[d]=250,s[c]=!0,t.event.special[a]={setup:function(){if(!s[c]&&this[o])return!1;var e=t(this);r=r.add(e),t.data(this,u,{w:e.width(),h:e.height()}),1===r.length&&n()},teardown:function(){if(!s[c]&&this[o])return!1;var e=t(this);r=r.not(e),e.removeData(u),r.length||clearTimeout(h)},add:function(e){function n(e,n,r){var s=t(this),o=t.data(this,u);o.w=n!==i?n:s.width(),o.h=r!==i?r:s.height(),h.apply(this,arguments)}if(!s[c]&&this[o])return!1;var h;if(t.isFunction(e))return h=e,n;h=e.handler,e.handler=n}}}(jQuery,this),function(t){var e={};t.plot.plugins.push({init:function(t){function e(){var e=t.getPlaceholder();0!=e.width()&&0!=e.height()&&(t.resize(),t.setupGrid(),t.draw())}t.hooks.bindEvents.push(function(t,i){t.getPlaceholder().resize(e)}),t.hooks.shutdown.push(function(t,i){t.getPlaceholder().unbind("resize",e)})},options:e,name:"resize",version:"1.0"})}(jQuery);
!function(t,e,i){function n(){h=e[o](function(){r.each(function(){var e=t(this),i=e.width(),n=e.height(),h=t.data(this,u);i===h.w&&n===h.h||e.trigger(a,[h.w=i,h.h=n])}),n()},s[d])}var h,r=t([]),s=t.resize=t.extend(t.resize,{}),o="setTimeout",a="resize",u=a+"-special-event",d="delay",c="throttleWindow";s[d]=250,s[c]=!0,t.event.special[a]={setup:function(){if(!s[c]&&this[o])return!1;var e=t(this);r=r.add(e),t.data(this,u,{w:e.width(),h:e.height()}),1===r.length&&n()},teardown:function(){if(!s[c]&&this[o])return!1;var e=t(this);r=r.not(e),e.removeData(u),r.length||clearTimeout(h)},add:function(e){function n(e,n,r){var s=t(this),o=t.data(this,u);o.w=n!==i?n:s.width(),o.h=r!==i?r:s.height(),h.apply(this,arguments)}if(!s[c]&&this[o])return!1;var h;if(t.isFunction(e))return h=e,n;h=e.handler,e.handler=n}}}(jQuery,this),function(t){var e={};jQuery.plot.plugins.push({init:function(t){function e(){var e=t.getPlaceholder();0!=e.width()&&0!=e.height()&&(t.resize(),t.setupGrid(),t.draw())}t.hooks.bindEvents.push(function(t,i){t.getPlaceholder().resize(e)}),t.hooks.shutdown.push(function(t,i){t.getPlaceholder().unbind("resize",e)})},options:e,name:"resize",version:"1.0"})}();

View File

@ -1 +1 @@
!function(s){var n={series:{stack:null}};s.plot.plugins.push({init:function(s){function n(s,n){for(var t=null,i=0;i<n.length&&s!=n[i];++i)n[i].stack==s.stack&&(t=n[i]);return t}s.hooks.processDatapoints.push(function(s,t,i){if(null!=t.stack&&!1!==t.stack){var l=n(t,s.getData());if(l){for(var o,e,u,f,a,p,r,h,c=i.pointsize,g=i.points,k=l.datapoints.pointsize,v=l.datapoints.points,m=[],z=t.lines.show,d=t.bars.horizontal,y=c>2&&(d?i.format[2].x:i.format[2].y),D=z&&t.lines.steps,b=!0,j=d?1:0,w=d?0:1,x=0,Q=0;!(x>=g.length);){if(r=m.length,null==g[x]){for(h=0;h<c;++h)m.push(g[x+h]);x+=c}else if(Q>=v.length){if(!z)for(h=0;h<c;++h)m.push(g[x+h]);x+=c}else if(null==v[Q]){for(h=0;h<c;++h)m.push(null);b=!0,Q+=k}else{if(o=g[x+j],e=g[x+w],f=v[Q+j],a=v[Q+w],p=0,o==f){for(h=0;h<c;++h)m.push(g[x+h]);m[r+w]+=a,p=a,x+=c,Q+=k}else if(o>f){if(z&&x>0&&null!=g[x-c]){for(u=e+(g[x-c+w]-e)*(f-o)/(g[x-c+j]-o),m.push(f),m.push(u+a),h=2;h<c;++h)m.push(g[x+h]);p=a}Q+=k}else{if(b&&z){x+=c;continue}for(h=0;h<c;++h)m.push(g[x+h]);z&&Q>0&&null!=v[Q-k]&&(p=a+(v[Q-k+w]-a)*(o-f)/(v[Q-k+j]-f)),m[r+w]+=p,x+=c}b=!1,r!=m.length&&y&&(m[r+2]+=p)}if(D&&r!=m.length&&r>0&&null!=m[r]&&m[r]!=m[r-c]&&m[r+1]!=m[r-c+1]){for(h=0;h<c;++h)m[r+c+h]=m[r+h];m[r+1]=m[r-c+1]}}i.points=m}}})},options:n,name:"stack",version:"1.2"})}(jQuery);
!function(s){var n={series:{stack:null}};jQuery.plot.plugins.push({init:function(s){function n(s,n){for(var t=null,i=0;i<n.length&&s!=n[i];++i)n[i].stack==s.stack&&(t=n[i]);return t}s.hooks.processDatapoints.push(function(s,t,i){if(null!=t.stack&&!1!==t.stack){var l=n(t,s.getData());if(l){for(var o,e,u,f,a,p,r,h,c=i.pointsize,g=i.points,k=l.datapoints.pointsize,v=l.datapoints.points,m=[],z=t.lines.show,d=t.bars.horizontal,y=c>2&&(d?i.format[2].x:i.format[2].y),D=z&&t.lines.steps,b=!0,j=d?1:0,w=d?0:1,x=0,Q=0;!(x>=g.length);){if(r=m.length,null==g[x]){for(h=0;h<c;++h)m.push(g[x+h]);x+=c}else if(Q>=v.length){if(!z)for(h=0;h<c;++h)m.push(g[x+h]);x+=c}else if(null==v[Q]){for(h=0;h<c;++h)m.push(null);b=!0,Q+=k}else{if(o=g[x+j],e=g[x+w],f=v[Q+j],a=v[Q+w],p=0,o==f){for(h=0;h<c;++h)m.push(g[x+h]);m[r+w]+=a,p=a,x+=c,Q+=k}else if(o>f){if(z&&x>0&&null!=g[x-c]){for(u=e+(g[x-c+w]-e)*(f-o)/(g[x-c+j]-o),m.push(f),m.push(u+a),h=2;h<c;++h)m.push(g[x+h]);p=a}Q+=k}else{if(b&&z){x+=c;continue}for(h=0;h<c;++h)m.push(g[x+h]);z&&Q>0&&null!=v[Q-k]&&(p=a+(v[Q-k+w]-a)*(o-f)/(v[Q-k+j]-f)),m[r+w]+=p,x+=c}b=!1,r!=m.length&&y&&(m[r+2]+=p)}if(D&&r!=m.length&&r>0&&null!=m[r]&&m[r]!=m[r-c]&&m[r+1]!=m[r-c+1]){for(h=0;h<c;++h)m[r+c+h]=m[r+h];m[r+1]=m[r-c+1]}}i.points=m}}})},options:n,name:"stack",version:"1.2"})}();

View File

@ -189,8 +189,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// Add/save items.
foreach ( $this->items as $item_group => $items ) {
if ( is_array( $items ) ) {
foreach ( array_filter( $items ) as $item_key => $item ) {
$items = array_filter( $items );
foreach ( $items as $item_key => $item ) {
$item->set_order_id( $this->get_id() );
$item_id = $item->save();
// If ID changed (new item saved to DB)...
@ -699,10 +701,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $types as $type ) {
if ( $group = $this->type_to_group( $type ) ) {
if ( ! isset( $this->items[ $group ] ) ) {
$this->items[ $group ] = $this->data_store->read_items( $this, $type );
$this->items[ $group ] = array_filter( $this->data_store->read_items( $this, $type ) );
}
// Don't use array_merge here because keys are numeric
$items = array_filter( $items + $this->items[ $group ] );
$items = $items + $this->items[ $group ];
}
}
@ -785,11 +787,34 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* Get an order item object, based on it's type.
*
* @since 3.0.0
* @param int $item_id
* @return WC_Order_Item
* @param int $item_id ID of item to get.
* @param bool $load_from_db Prior to 3.2 this item was loaded direct from WC_Order_Factory, not this object. This param is here for backwards compatility with that. If false, uses the local items variable instead.
* @return WC_Order_Item|false
*/
public function get_item( $item_id ) {
return WC_Order_Factory::get_order_item( $item_id );
public function get_item( $item_id, $load_from_db = true ) {
if ( $load_from_db ) {
return WC_Order_Factory::get_order_item( $item_id );
}
// Search for item id.
if ( $this->items ) {
foreach ( $this->items as $group => $items ) {
if ( isset( $items[ $item_id ] ) ) {
return $items[ $item_id ];
}
}
}
// Load all items of type and cache.
$type = $this->data_store->get_order_item_type( $this, $item_id );
if ( ! $type ) {
return false;
}
$items = $this->get_items( $type );
return ! empty( $items[ $item_id ] ) ? $items[ $item_id ] : false;
}
/**
@ -818,7 +843,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* Remove item from the order.
*
* @param int $item_id
*
* @return false|void
*/
public function remove_item( $item_id ) {
@ -839,7 +863,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @since 3.0.0
* @param WC_Order_Item Order item object (product, shipping, fee, coupon, tax)
*
* * @return false|void
* @return false|void
*/
public function add_item( $item ) {
if ( ! $items_key = $this->get_items_key( $item ) ) {
@ -854,7 +878,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// Set parent.
$item->set_order_id( $this->get_id() );
// Append new row with generated temporary ID
// Append new row with generated temporary ID.
if ( $item_id = $item->get_id() ) {
$this->items[ $items_key ][ $item_id ] = $item;
} else {
@ -862,6 +886,170 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
}
/**
* Apply a coupon to the order and recalculate totals.
*
* @since 3.2.0
* @param string|WC_Coupon $coupon Coupon code or object.
* @return true|WP_Error True if applied, error if not.
*/
public function apply_coupon( $coupon ) {
if ( ! is_a( $coupon, 'WC_Coupon' ) ) {
$code = wc_format_coupon_code( $coupon );
$coupon = new WC_Coupon( $code );
if ( $coupon->get_code() !== $code || ! $coupon->is_valid() ) {
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon code', 'woocommerce' ) );
}
}
// Check to make sure coupon is not already applied.
$applied_coupons = $this->get_items( 'coupon' );
foreach ( $applied_coupons as $applied_coupon ) {
if ( $applied_coupon->get_code() === $coupon->get_code() ) {
return new WP_Error( 'invalid_coupon', __( 'Coupon code already applied!', 'woocommerce' ) );
}
}
$discounts = new WC_Discounts( $this );
$applied = $discounts->apply_coupon( $coupon );
if ( is_wp_error( $applied ) ) {
return $applied;
}
$this->set_coupon_discount_amounts( $discounts );
// Add discounts to line items.
if ( $item_discounts = $discounts->get_discounts_by_item() ) {
foreach ( $item_discounts as $item_id => $amount ) {
$item = $this->get_item( $item_id, false );
$item->set_total( max( 0, $item->get_total() - $amount ) );
}
}
// Recalculate totals and taxes.
$this->calculate_totals( true );
// Record usage so counts and validation is correct.
if ( ! $used_by = $this->get_user_id() ) {
$used_by = $this->get_billing_email();
}
$coupon->increase_usage_count( $used_by );
return true;
}
/**
* Remove a coupon from the order and recalculate totals.
*
* Coupons affect line item totals, but there is no relationship between
* coupon and line total, so to remove a coupon we need to work from the
* line subtotal (price before discount) and re-apply all coupons in this
* order.
*
* Manual discounts are not affected; those are separate and do not affect
* stored line totals.
*
* @since 3.2.0
* @param string $code Coupon code.
* @return void
*/
public function remove_coupon( $code ) {
$coupons = $this->get_items( 'coupon' );
// Remove the coupon line.
foreach ( $coupons as $item_id => $coupon ) {
if ( $coupon->get_code() === $code ) {
$this->remove_item( $item_id );
$coupon_object = new WC_Coupon( $code );
$coupon_object->decrease_usage_count( $this->get_user_id() );
break;
}
}
// Reset line item totals.
$this->recalculate_coupons();
}
/**
* Apply all coupons in this order again to all line items.
*
* @since 3.2.0
*/
protected function recalculate_coupons() {
$discounts = new WC_Discounts( $this );
$coupons = $this->get_items( 'coupon' );
foreach ( $coupons as $coupon ) {
$coupon_object = new WC_Coupon( $coupon->get_code() );
$discounts->apply_coupon( $coupon_object );
}
$this->set_coupon_discount_amounts( $discounts );
// Reset line item totals.
foreach ( $this->get_items() as $item ) {
$item->set_total( $item->get_subtotal() );
$item->set_total_tax( $item->get_subtotal_tax() );
}
// Add discounts to line items.
if ( $item_discounts = $discounts->get_discounts_by_item() ) {
foreach ( $item_discounts as $item_id => $amount ) {
$item = $this->get_item( $item_id, false );
$item->set_total( max( 0, $item->get_total() - $amount ) );
}
}
// Recalculate totals and taxes.
$this->calculate_totals( true );
}
/**
* After applying coupons via the WC_Disounts class, update or create coupon items.
*
* @since 3.2.0
* @param WC_Discounts $discounts Discounts class.
*/
protected function set_coupon_discount_amounts( $discounts ) {
$coupons = $this->get_items( 'coupon' );
$coupon_code_to_id = wc_list_pluck( $coupons, 'get_id', 'get_code' );
$all_discounts = $discounts->get_discounts();
$item_discounts = $discounts->get_discounts_by_item();
$coupon_discounts = $discounts->get_discounts_by_coupon();
if ( $coupon_discounts ) {
foreach ( $coupon_discounts as $coupon_code => $amount ) {
$item_id = isset( $coupon_code_to_id[ $coupon_code ] ) ? $coupon_code_to_id[ $coupon_code ] : 0;
if ( ! $item_id ) {
$coupon_item = new WC_Order_Item_Coupon();
$coupon_item->set_code( $coupon_code );
} else {
$coupon_item = $this->get_item( $item_id, false );
}
$coupon_item->set_discount( $amount );
// Work out how much tax has been removed as a result of the discount from this coupon.
if ( wc_tax_enabled() && isset( $all_discounts[ $coupon_code ] ) ) {
$discount_tax = 0;
foreach ( $all_discounts[ $coupon_code ] as $item_id => $item_discount_amount ) {
$item = $this->get_item( $item_id, false );
$discount_tax += array_sum( WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ) ) );
}
$coupon_item->set_discount_tax( $discount_tax );
}
$this->add_item( $coupon_item );
}
}
}
/**
* Add a product line item to the order. This is the only line item type with
* it's own method because it saves looking up order amounts (costs are added up for you).
@ -1054,12 +1242,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// Trigger tax recalculation for all items.
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
$item->calculate_taxes( $calculate_tax_for );
$item->save();
}
foreach ( $this->get_shipping_methods() as $item_id => $item ) {
$item->calculate_taxes( array_merge( $calculate_tax_for, array( 'tax_class' => $shipping_tax_class ) ) );
$item->save();
}
$this->update_taxes();
@ -1125,37 +1311,48 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return float calculated grand total.
*/
public function calculate_totals( $and_taxes = true ) {
$cart_subtotal = 0;
$cart_total = 0;
$fee_total = 0;
$cart_subtotal_tax = 0;
$cart_total_tax = 0;
if ( $and_taxes ) {
$this->calculate_taxes();
}
$cart_subtotal = 0;
$cart_total = 0;
$fee_total = 0;
$shipping_total = 0;
$cart_subtotal_tax = 0;
$cart_total_tax = 0;
// Sum line item costs.
foreach ( $this->get_items() as $item ) {
$cart_subtotal += $item->get_subtotal();
$cart_total += $item->get_total();
$cart_subtotal_tax += $item->get_subtotal_tax();
$cart_total_tax += $item->get_total_tax();
$cart_subtotal += $item->get_subtotal();
$cart_total += $item->get_total();
}
$this->calculate_shipping();
// Sum fee costs.
foreach ( $this->get_fees() as $item ) {
$fee_total += $item->get_total();
}
$grand_total = round( $cart_total + $fee_total + $this->get_shipping_total() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals() );
// Sum shipping costs.
foreach ( $this->get_shipping_methods() as $shipping ) {
$shipping_total += $shipping->get_total();
}
$this->set_shipping_total( $shipping_total );
// Calculate taxes for items, shipping, discounts.
if ( $and_taxes ) {
$this->calculate_taxes();
}
// Sum taxes.
foreach ( $this->get_items() as $item ) {
$cart_subtotal_tax += $item->get_subtotal_tax();
$cart_total_tax += $item->get_total_tax();
}
$this->set_discount_total( $cart_subtotal - $cart_total );
$this->set_discount_tax( $cart_subtotal_tax - $cart_total_tax );
$this->set_total( $grand_total );
$this->set_total( round( $cart_total + $fee_total + $this->get_shipping_total() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals() ) );
$this->save();
return $grand_total;
return $this->get_total();
}
/**

View File

@ -888,8 +888,14 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @param string $class Tax class.
*/
public function set_tax_class( $class ) {
$class = sanitize_title( $class );
$class = 'standard' === $class ? '' : $class;
$class = sanitize_title( $class );
$class = 'standard' === $class ? '' : $class;
$valid_classes = WC_Tax::get_tax_class_slugs();
if ( ! in_array( $class, $valid_classes ) ) {
$class = '';
}
$this->set_prop( 'tax_class', $class );
}

View File

@ -358,7 +358,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
}
}
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $available, $package );
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $available, $package, $this );
}
/**

View File

@ -305,6 +305,7 @@ class WC_Admin_Assets {
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ),
'i18n_apply_coupon' => __( 'Enter a coupon code to apply to this order.', 'woocommerce' ),
);
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );

View File

@ -150,9 +150,11 @@ class WC_Admin_Post_Types {
7 => __( 'Product saved.', 'woocommerce' ),
/* translators: %s: product url */
8 => sprintf( __( 'Product submitted. <a target="_blank" href="%s">Preview product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
/* translators: 1: date 2: product url */
9 => sprintf( __( 'Product scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview product</a>', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ),
9 => sprintf(
/* translators: 1: date 2: product url */
__( 'Product scheduled for: %1$s. <a target="_blank" href="%2$s">Preview product</a>', 'woocommerce' ),
'<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) . '</strong>'
),
/* translators: %s: product url */
10 => sprintf( __( 'Product draft updated. <a target="_blank" href="%s">Preview product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
);
@ -168,9 +170,11 @@ class WC_Admin_Post_Types {
6 => __( 'Order updated.', 'woocommerce' ),
7 => __( 'Order saved.', 'woocommerce' ),
8 => __( 'Order submitted.', 'woocommerce' ),
/* translators: %s: date */
9 => sprintf( __( 'Order scheduled for: <strong>%1$s</strong>.', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ),
9 => sprintf(
/* translators: %s: date */
__( 'Order scheduled for: %s.', 'woocommerce' ),
'<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) . '</strong>'
),
10 => __( 'Order draft updated.', 'woocommerce' ),
11 => __( 'Order updated and sent to the customer.', 'woocommerce' ),
);
@ -186,9 +190,11 @@ class WC_Admin_Post_Types {
6 => __( 'Coupon updated.', 'woocommerce' ),
7 => __( 'Coupon saved.', 'woocommerce' ),
8 => __( 'Coupon submitted.', 'woocommerce' ),
/* translators: %s: date */
9 => sprintf( __( 'Coupon scheduled for: <strong>%1$s</strong>.', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ),
9 => sprintf(
/* translators: %s: date */
__( 'Coupon scheduled for: %s.', 'woocommerce' ),
'<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) . '</strong>'
),
10 => __( 'Coupon draft updated.', 'woocommerce' ),
);

View File

@ -201,7 +201,7 @@ class WC_Admin_Webhooks {
}
if ( ! current_user_can( 'publish_shop_webhooks' ) ) {
wp_die( __( 'You do not have permissions to create Webhooks!', 'woocommerce' ) );
wp_die( __( 'You do not have permission to create Webhooks', 'woocommerce' ) );
}
$webhook_id = wp_insert_post( array(
@ -286,7 +286,7 @@ class WC_Admin_Webhooks {
}
if ( ! current_user_can( 'edit_shop_webhooks' ) ) {
wp_die( __( 'You do not have permissions to edit Webhooks!', 'woocommerce' ) );
wp_die( __( 'You do not have permission to edit Webhooks', 'woocommerce' ) );
}
$webhooks = array_map( 'absint', (array) $_GET['webhook'] );
@ -315,7 +315,7 @@ class WC_Admin_Webhooks {
}
if ( ! current_user_can( 'delete_shop_webhooks' ) ) {
wp_die( __( 'You do not have permissions to delete Webhooks!', 'woocommerce' ) );
wp_die( __( 'You do not have permission to delete Webhooks', 'woocommerce' ) );
}
$webhooks = get_posts( array(

View File

@ -11,6 +11,7 @@ $payment_gateway = wc_get_payment_gateway_by_order( $order );
// Get line items
$line_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', 'line_item' ) );
$discounts = $order->get_items( 'discount' );
$line_items_fee = $order->get_items( 'fee' );
$line_items_shipping = $order->get_items( 'shipping' );
@ -18,7 +19,7 @@ if ( wc_tax_enabled() ) {
$order_taxes = $order->get_taxes();
$tax_classes = WC_Tax::get_tax_classes();
$classes_options = wc_get_product_tax_class_options();
$show_tax_columns = sizeof( $order_taxes ) === 1;
$show_tax_columns = count( $order_taxes ) === 1;
}
?>
<div class="woocommerce_order_items_wrapper wc-order-items-editable">
@ -92,14 +93,17 @@ if ( wc_tax_enabled() ) {
</table>
</div>
<div class="wc-order-data-row wc-order-item-bulk-edit" style="display:none;">
<button type="button" class="button bulk-delete-items"><?php _e( 'Delete selected row(s)', 'woocommerce' ); ?></button>
<?php if ( $order->is_editable() ) : ?>
<button type="button" class="button bulk-delete-items"><?php _e( 'Delete selected row(s)', 'woocommerce' ); ?></button>
<?php endif; ?>
<button type="button" class="button bulk-decrease-stock"><?php _e( 'Reduce stock', 'woocommerce' ); ?></button>
<button type="button" class="button bulk-increase-stock"><?php _e( 'Increase stock', 'woocommerce' ); ?></button>
<?php do_action( 'woocommerce_admin_order_item_bulk_actions', $order ); ?>
</div>
<div class="wc-order-data-row wc-order-totals-items wc-order-items-editable">
<?php
$coupons = $order->get_items( array( 'coupon' ) );
$coupons = $order->get_items( 'coupon' );
if ( $coupons ) {
?>
<div class="wc-used-coupons">
@ -109,7 +113,7 @@ if ( wc_tax_enabled() ) {
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) );
$link = $post_id ? add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) : add_query_arg( array( 's' => $item->get_code(), 'post_status' => 'all', 'post_type' => 'shop_coupon' ), admin_url( 'edit.php' ) );
echo '<li class="code"><a href="' . esc_url( $link ) . '" class="tips" data-tip="' . esc_attr( wc_price( $item->get_discount(), array( 'currency' => $order->get_currency() ) ) ) . '"><span>' . esc_html( $item->get_code() ) . '</span></a></li>';
echo '<li class="code"><a href="' . esc_url( $link ) . '" class="tips" data-tip="' . esc_attr( wc_price( $item->get_discount(), array( 'currency' => $order->get_currency() ) ) ) . '"><span>' . esc_html( $item->get_code() ) . '</span></a> <a class="remove-coupon" href="javascript:void(0)" aria-label="Remove" data-code="' . esc_attr( $item->get_code() ) . '"></a></li>';
}
?></ul>
</div>
@ -117,28 +121,7 @@ if ( wc_tax_enabled() ) {
}
?>
<table class="wc-order-totals">
<tr>
<td class="label"><?php echo wc_help_tip( __( 'This is the total discount. Discounts are defined per line item.', 'woocommerce' ) ); ?> <?php _e( 'Discount:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); ?>
</td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->get_id() ); ?>
<tr>
<td class="label"><?php echo wc_help_tip( __( 'This is the shipping and handling total costs for the order.', 'woocommerce' ) ); ?> <?php _e( 'Shipping:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total"><?php
if ( ( $refunded = $order->get_total_shipping_refunded() ) > 0 ) {
echo '<del>' . strip_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>';
} else {
echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) );
}
?></td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_shipping', $order->get_id() ); ?>
<?php if ( wc_tax_enabled() ) : ?>
@ -186,12 +169,10 @@ if ( wc_tax_enabled() ) {
<p class="add-items">
<?php if ( $order->is_editable() ) : ?>
<button type="button" class="button add-line-item"><?php _e( 'Add item(s)', 'woocommerce' ); ?></button>
<button type="button" class="button add-coupon"><?php _e( 'Apply coupon', 'woocommerce' ); ?></button>
<?php else : ?>
<span class="description"><?php echo wc_help_tip( __( 'To edit this order change the status back to "Pending"', 'woocommerce' ) ); ?> <?php _e( 'This order is no longer editable.', 'woocommerce' ); ?></span>
<?php endif; ?>
<?php if ( wc_tax_enabled() && $order->is_editable() ) : ?>
<button type="button" class="button add-order-tax"><?php _e( 'Add tax', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php if ( 0 < $order->get_total() - $order->get_total_refunded() || 0 < absint( $order->get_item_count() - $order->get_item_count_refunded() ) ) : ?>
<button type="button" class="button refund-items"><?php _e( 'Refund', 'woocommerce' ); ?></button>
<?php endif; ?>
@ -208,6 +189,9 @@ if ( wc_tax_enabled() ) {
<button type="button" class="button add-order-item"><?php _e( 'Add product(s)', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-fee"><?php _e( 'Add fee', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-shipping"><?php _e( 'Add shipping cost', 'woocommerce' ); ?></button>
<?php if ( wc_tax_enabled() ) : ?>
<button type="button" class="button add-order-tax"><?php _e( 'Add tax', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php
// allow adding custom buttons
do_action( 'woocommerce_order_item_add_line_buttons', $order );

View File

@ -13,11 +13,25 @@ $who_refunded = new WP_User( $refund->get_refunded_by() );
<td class="name">
<?php
/* translators: 1: refund id 2: date */
printf( __( 'Refund #%1$s - %2$s', 'woocommerce' ), $refund->get_id(), wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) ) );
if ( $who_refunded->exists() ) {
echo ' ' . esc_attr_x( 'by', 'Ex: Refund - $date >by< $username', 'woocommerce' ) . ' ' . '<abbr class="refund_by" title="' . sprintf( esc_attr__( 'ID: %d', 'woocommerce' ), absint( $who_refunded->ID ) ) . '">' . esc_attr( $who_refunded->display_name ) . '</abbr>' ;
printf(
/* translators: 1: refund id 2: refund date 3: username */
__( 'Refund #%1$s - %2$s by %3$s', 'woocommerce' ),
$refund->get_id(),
wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) ),
sprintf(
'<abbr class="refund_by" title="%1$s">%2$s</abbr>',
sprintf( esc_attr__( 'ID: %d', 'woocommerce' ), absint( $who_refunded->ID ) ),
esc_html( $who_refunded->display_name )
)
);
} else {
printf(
/* translators: 1: refund id 2: refund date */
__( 'Refund #%1$s - %2$s', 'woocommerce' ),
$refund->get_id(),
wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) )
);
}
?>
<?php if ( $refund->get_reason() ) : ?>

View File

@ -391,7 +391,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
// Total the refunds and sales amounts. Sales subract refunds. Note - total_sales also includes shipping costs.
$this->report_data->total_sales = wc_format_decimal( array_sum( wp_list_pluck( $this->report_data->orders, 'total_sales' ) ) - $this->report_data->total_refunds, 2 );
$this->report_data->net_sales = wc_format_decimal( $this->report_data->total_sales - $this->report_data->total_shipping - $this->report_data->total_tax - $this->report_data->total_shipping_tax, 2 );
$this->report_data->net_sales = wc_format_decimal( $this->report_data->total_sales - $this->report_data->total_shipping - max( 0, $this->report_data->total_tax ) - max( 0, $this->report_data->total_shipping_tax ), 2 );
// Calculate average based on net
$this->report_data->average_sales = wc_format_decimal( $this->report_data->net_sales / ( $this->chart_interval + 1 ), 2 );

View File

@ -245,7 +245,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
foreach ( $top_sellers as $product ) {
echo '<tr class="' . ( in_array( $product->product_id, $this->product_ids ) ? 'active' : '' ) . '">
<td class="count">' . $product->order_item_qty . '</td>
<td class="name"><a href="' . esc_url( add_query_arg( 'product_ids', $product->product_id ) ) . '">' . get_the_title( $product->product_id ) . '</a></td>
<td class="name"><a href="' . esc_url( add_query_arg( 'product_ids', $product->product_id ) ) . '">' . esc_html( get_the_title( $product->product_id ) ) . '</a></td>
<td class="sparkline">' . $this->sales_sparkline( $product->product_id, 7, 'count' ) . '</td>
</tr>';
}
@ -293,7 +293,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
foreach ( $top_freebies as $product ) {
echo '<tr class="' . ( in_array( $product->product_id, $this->product_ids ) ? 'active' : '' ) . '">
<td class="count">' . $product->order_item_qty . '</td>
<td class="name"><a href="' . esc_url( add_query_arg( 'product_ids', $product->product_id ) ) . '">' . get_the_title( $product->product_id ) . '</a></td>
<td class="name"><a href="' . esc_url( add_query_arg( 'product_ids', $product->product_id ) ) . '">' . esc_html( get_the_title( $product->product_id ) ) . '</a></td>
<td class="sparkline">' . $this->sales_sparkline( $product->product_id, 7, 'count' ) . '</td>
</tr>';
}
@ -333,7 +333,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
foreach ( $top_earners as $product ) {
echo '<tr class="' . ( in_array( $product->product_id, $this->product_ids ) ? 'active' : '' ) . '">
<td class="count">' . wc_price( $product->order_item_total ) . '</td>
<td class="name"><a href="' . esc_url( add_query_arg( 'product_ids', $product->product_id ) ) . '">' . get_the_title( $product->product_id ) . '</a></td>
<td class="name"><a href="' . esc_url( add_query_arg( 'product_ids', $product->product_id ) ) . '">' . esc_html( get_the_title( $product->product_id ) ) . '</a></td>
<td class="sparkline">' . $this->sales_sparkline( $product->product_id, 7, 'sales' ) . '</td>
</tr>';
}

View File

@ -101,7 +101,7 @@ class WC_Report_Stock extends WP_List_Table {
case 'parent' :
if ( $item->parent ) {
echo get_the_title( $item->parent );
echo esc_html( get_the_title( $item->parent ) );
} else {
echo '-';
}

View File

@ -23,13 +23,10 @@ class WC_Settings_Accounts extends WC_Settings_Page {
* Constructor.
*/
public function __construct() {
$this->id = 'account';
$this->label = __( 'Accounts', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
parent::__construct();
}
/**

View File

@ -26,11 +26,8 @@ class WC_Settings_Rest_API extends WC_Settings_Page {
$this->id = 'api';
$this->label = __( 'API', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'woocommerce_settings_form_method_tab_' . $this->id, array( $this, 'form_method' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
parent::__construct();
$this->notices();
}

View File

@ -23,15 +23,11 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
* Constructor.
*/
public function __construct() {
$this->id = 'checkout';
$this->label = _x( 'Checkout', 'Settings tab label', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
parent::__construct();
}
/**

View File

@ -26,11 +26,8 @@ class WC_Settings_Emails extends WC_Settings_Page {
$this->id = 'email';
$this->label = __( 'Emails', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
add_action( 'woocommerce_admin_field_email_notification', array( $this, 'email_notification_setting' ) );
parent::__construct();
}
/**

View File

@ -23,13 +23,10 @@ class WC_Settings_General extends WC_Settings_Page {
* Constructor.
*/
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
parent::__construct();
}
/**

View File

@ -23,15 +23,11 @@ class WC_Settings_Integrations extends WC_Settings_Page {
* Constructor.
*/
public function __construct() {
$this->id = 'integration';
$this->label = __( 'Integration', 'woocommerce' );
if ( isset( WC()->integrations ) && WC()->integrations->get_integrations() ) {
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
parent::__construct();
}
}

View File

@ -23,14 +23,10 @@ class WC_Settings_Products extends WC_Settings_Page {
* Constructor.
*/
public function __construct() {
$this->id = 'products';
$this->label = __( 'Products', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
parent::__construct();
}
/**

View File

@ -25,10 +25,8 @@ class WC_Settings_Shipping extends WC_Settings_Page {
public function __construct() {
$this->id = 'shipping';
$this->label = __( 'Shipping', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
parent::__construct();
}
/**

View File

@ -19,18 +19,13 @@ if ( ! class_exists( 'WC_Settings_Tax', false ) ) :
*/
class WC_Settings_Tax extends WC_Settings_Page {
/**
* Setting page id.
*
* @var string
*/
protected $id = 'tax';
/**
* Constructor.
*/
public function __construct() {
$this->id = 'tax';
$this->label = __( 'Tax', 'woocommerce' );
parent::__construct();
}

View File

@ -13,14 +13,15 @@ if ( ! class_exists( 'WC_REST_System_Status_Controller', false ) ) {
wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Controller.' );
}
$system_status = new WC_REST_System_Status_Controller;
$environment = $system_status->get_environment_info();
$database = $system_status->get_database_info();
$active_plugins = $system_status->get_active_plugins();
$theme = $system_status->get_theme_info();
$security = $system_status->get_security_info();
$settings = $system_status->get_settings();
$pages = $system_status->get_pages();
$system_status = new WC_REST_System_Status_Controller;
$environment = $system_status->get_environment_info();
$database = $system_status->get_database_info();
$post_type_counts = $system_status->get_post_type_counts();
$active_plugins = $system_status->get_active_plugins();
$theme = $system_status->get_theme_info();
$security = $system_status->get_security_info();
$settings = $system_status->get_settings();
$pages = $system_status->get_pages();
?>
<div class="updated woocommerce-message inline">
<p><?php _e( 'Please copy and paste this information in your ticket when contacting support:', 'woocommerce' ); ?> </p>
@ -263,7 +264,7 @@ $pages = $system_status->get_pages();
if ( $environment['remote_post_successful'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'wp_remote_post() failed. Contact your hosting provider.', 'woocommerce' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>';
} ?>
</td>
</tr>
@ -274,7 +275,7 @@ $pages = $system_status->get_pages();
if ( $environment['remote_get_successful'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'wp_remote_get() failed. Contact your hosting provider.', 'woocommerce' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>';
} ?>
</td>
</tr>
@ -302,57 +303,106 @@ $pages = $system_status->get_pages();
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Database"><h2><?php _e( 'Database', 'woocommerce' ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="WC Database Version"><?php _e( 'WC database version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce version.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $database['wc_database_version'] ); ?></td>
</tr>
<tr>
<td data-export-label="WC Database Prefix"><?php _e( 'Database prefix', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php
if ( strlen( $database['database_prefix'] ) > 20 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '<a href="https://docs.woocommerce.com/document/completed-order-email-doesnt-contain-download-links/#section-2" target="_blank">' . __( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>';
}
?>
</td>
</tr>
<?php
foreach ( $database['database_tables'] as $table => $table_exists ) {
<thead>
<tr>
<th colspan="3" data-export-label="Database"><h2><?php _e( 'Database', 'woocommerce' ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="WC Database Version"><?php _e( 'WC database version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce version.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $database['wc_database_version'] ); ?></td>
</tr>
<tr>
<td data-export-label="WC Database Prefix"><?php _e( 'Database prefix', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php
if ( strlen( $database['database_prefix'] ) > 20 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '<a href="https://docs.woocommerce.com/document/completed-order-email-doesnt-contain-download-links/#section-2" target="_blank">' . __( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>';
}
?>
<tr>
<td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td>
<td><?php echo ! $table_exists ? '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>' : '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; ?></td>
</tr>
<?php
}
</td>
</tr>
if ( $settings['geolocation_enabled'] ) {
?>
<tr>
<td data-export-label="MaxMind GeoIP Database"><?php _e( 'MaxMind GeoIP database', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The GeoIP database from MaxMind is used to geolocate customers.', 'woocommerce' ) ); ?></td>
<td><?php
if ( file_exists( $database['maxmind_geoip_database'] ) ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $database['maxmind_geoip_database'] ) . '</code></mark> ';
} else {
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . $database['maxmind_geoip_database'] . '</code>' ) . '</mark>', WC_LOG_DIR );
}
?></td>
</tr>
<?php
}
<?php if ( $settings['geolocation_enabled'] ) { ?>
<tr>
<td data-export-label="MaxMind GeoIP Database"><?php _e( 'MaxMind GeoIP database', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The GeoIP database from MaxMind is used to geolocate customers.', 'woocommerce' ) ); ?></td>
<td><?php
if ( file_exists( $database['maxmind_geoip_database'] ) ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $database['maxmind_geoip_database'] ) . '</code></mark> ';
} else {
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . $database['maxmind_geoip_database'] . '</code>' ) . '</mark>', WC_LOG_DIR );
}
?></td>
</tr>
<?php } ?>
<tr>
<td><?php _e( 'Total Database Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['data'] ); ?></td>
</tr>
<tr>
<td><?php _e( 'Database Data Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['index'] ); ?></td>
</tr>
<tr>
<td><?php _e( 'Database Index Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['data'] + $database['database_size']['index'] ); ?></td>
</tr>
<?php foreach ( $database['database_tables']['woocommerce'] as $table => $table_data ) { ?>
<tr>
<td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php if( ! $table_data ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>';
} else {
printf( __( 'Data: %.2fMB + Index: %.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) );
} ?>
</td>
</tr>
<?php } ?>
<?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?>
<tr>
<td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php printf( __( 'Data: %.2fMB + Index: %.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) ); ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Post Type Counts"><h2><?php _e( 'Post Type Counts', 'woocommerce' ); ?></h2></th>
</tr>
</thead>
<tbody>
<?php
foreach ( $post_type_counts as $post_type ) {
?>
</tbody>
<tr>
<td><?php echo esc_html( $post_type->type ); ?></td>
<td class="help">&nbsp;</td>
<td><?php echo absint( $post_type->count ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>

View File

@ -14,18 +14,15 @@ if ( ! defined( 'ABSPATH' ) ) {
<tbody class="tools">
<?php foreach ( $tools as $action => $tool ) : ?>
<tr class="<?php echo sanitize_html_class( $action ); ?>">
<td><?php echo esc_html( $tool['name'] ); ?></td>
<td>
<p>
<a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wc-status&tab=tools&action=' . $action ), 'debug_action' ); ?>" class="button <?php echo esc_attr( $action ); ?>"><?php echo esc_html( $tool['button'] ); ?></a>
<span class="description"><?php echo wp_kses_post( $tool['desc'] ); ?></span>
</p>
<th>
<strong class="name"><?php echo esc_html( $tool['name'] ); ?></strong>
<p class="description"><?php echo wp_kses_post( $tool['desc'] ); ?></p>
</th>
<td class="run-tool">
<a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wc-status&tab=tools&action=' . $action ), 'debug_action' ); ?>" class="button button-large <?php echo esc_attr( $action ); ?>"><?php echo esc_html( $tool['button'] ); ?></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ) ?>" />
</p>
</form>

View File

@ -186,12 +186,10 @@ function woocommerce_settings_get_option( $option_name, $default = '' ) {
* @param array $items Order items to save
*/
function wc_save_order_items( $order_id, $items ) {
// Allow other plugins to check change in order items before they are saved
// Allow other plugins to check change in order items before they are saved.
do_action( 'woocommerce_before_save_order_items', $order_id, $items );
$order = wc_get_order( $order_id );
// Line items and fees
// Line items and fees.
if ( isset( $items['order_item_id'] ) ) {
$data_keys = array(
'line_tax' => array(),
@ -203,7 +201,7 @@ function wc_save_order_items( $order_id, $items ) {
'line_subtotal' => null,
);
foreach ( $items['order_item_id'] as $item_id ) {
if ( ! $item = $order->get_item( absint( $item_id ) ) ) {
if ( ! $item = WC_Order_Factory::get_order_item( absint( $item_id ) ) ) {
continue;
}
@ -260,7 +258,7 @@ function wc_save_order_items( $order_id, $items ) {
);
foreach ( $items['shipping_method_id'] as $item_id ) {
if ( ! $item = $order->get_item( absint( $item_id ) ) ) {
if ( ! $item = WC_Order_Factory::get_order_item( absint( $item_id ) ) ) {
continue;
}
@ -299,10 +297,8 @@ function wc_save_order_items( $order_id, $items ) {
}
}
// Updates tax totals
$order = wc_get_order( $order_id );
$order->update_taxes();
// Calc totals - this also triggers save
$order->calculate_totals( false );
// Inform other plugins that the items have been saved

View File

@ -636,8 +636,18 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
public function get_database_info() {
global $wpdb;
$database_table_sizes = $wpdb->get_results( $wpdb->prepare( "
SELECT
table_name AS 'name',
round( ( data_length / 1024 / 1024 ), 2 ) 'data',
round( ( index_length / 1024 / 1024 ), 2 ) 'index'
FROM information_schema.TABLES
WHERE table_schema = %s
ORDER BY name ASC;
", DB_NAME ) );
// WC Core tables to check existence of
$tables = apply_filters( 'woocommerce_database_tables', array(
$core_tables = apply_filters( 'woocommerce_database_tables', array(
'woocommerce_sessions',
'woocommerce_api_keys',
'woocommerce_attribute_taxonomies',
@ -651,14 +661,48 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'woocommerce_shipping_zone_methods',
'woocommerce_payment_tokens',
'woocommerce_payment_tokenmeta',
'woocommerce_log',
) );
if ( get_option( 'db_version' ) < 34370 ) {
$tables[] = 'woocommerce_termmeta';
$core_tables[] = 'woocommerce_termmeta';
}
$table_exists = array();
foreach ( $tables as $table ) {
$table_exists[ $table ] = ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s;", $wpdb->prefix . $table ) ) === $wpdb->prefix . $table );
/**
* Adding the prefix to the tables array, for backwards compatibility.
*
* If we changed the tables above to include the prefix, then any filters against that table could break.
*/
$core_tables = array_map( function( $table ) {
global $wpdb;
return $wpdb->prefix . $table;
}, $core_tables );
/**
* Organize WooCommerce and non-WooCommerce tables separately for display purposes later.
*
* To ensure we include all WC tables, even if they do not exist, pre-populate the WC array with all the tables.
*/
$tables = array(
'woocommerce' => array_fill_keys( $core_tables, false ),
'other' => array()
);
$database_size = array(
'data' => 0,
'index' => 0
);
foreach ( $database_table_sizes as $table ) {
$table_type = in_array( $table->name, $core_tables ) ? 'woocommerce' : 'other';
$tables[ $table_type ][ $table->name ] = array(
'data' => $table->data,
'index' => $table->index
);
$database_size[ 'data' ] += $table->data;
$database_size[ 'index' ] += $table->index;
}
// Return all database info. Described by JSON Schema.
@ -666,10 +710,24 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'wc_database_version' => get_option( 'woocommerce_db_version' ),
'database_prefix' => $wpdb->prefix,
'maxmind_geoip_database' => WC_Geolocation::get_local_database_path(),
'database_tables' => $table_exists,
'database_tables' => $tables,
'database_size' => $database_size,
);
}
/**
* Get array of counts of objects. Orders, products, etc.
*
* @return array
*/
public function get_post_type_counts() {
global $wpdb;
$post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" );
return is_array( $post_type_counts ) ? $post_type_counts : array();
}
/**
* Get a list of plugins active on the site.
*

View File

@ -118,13 +118,13 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
public function get_tools() {
$tools = array(
'clear_transients' => array(
'name' => __( 'WC transients', 'woocommerce' ),
'name' => __( 'WooCommerce transients', 'woocommerce' ),
'button' => __( 'Clear transients', 'woocommerce' ),
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ),
),
'clear_expired_transients' => array(
'name' => __( 'Expired transients', 'woocommerce' ),
'button' => __( 'Clear expired transients', 'woocommerce' ),
'button' => __( 'Clear transients', 'woocommerce' ),
'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ),
),
'delete_orphaned_variations' => array(
@ -134,7 +134,7 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
),
'add_order_indexes' => array(
'name' => __( 'Order address indexes', 'woocommerce' ),
'button' => __( 'Add order address indexes', 'woocommerce' ),
'button' => __( 'Index orders', 'woocommerce' ),
'desc' => __( 'This tool will add address indexes to orders that do not have them yet. This improves order search results.', 'woocommerce' ),
),
'recount_terms' => array(
@ -148,8 +148,8 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ),
),
'clear_sessions' => array(
'name' => __( 'Customer sessions', 'woocommerce' ),
'button' => __( 'Clear all sessions', 'woocommerce' ),
'name' => __( 'Clear customer sessions', 'woocommerce' ),
'button' => __( 'Clear', 'woocommerce' ),
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
@ -157,8 +157,8 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
),
),
'install_pages' => array(
'name' => __( 'Install WooCommerce pages', 'woocommerce' ),
'button' => __( 'Install pages', 'woocommerce' ),
'name' => __( 'Create default WooCommerce pages', 'woocommerce' ),
'button' => __( 'Create pages', 'woocommerce' ),
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
@ -166,17 +166,26 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
),
),
'delete_taxes' => array(
'name' => __( 'Delete all WooCommerce tax rates', 'woocommerce' ),
'button' => __( 'Delete ALL tax rates', 'woocommerce' ),
'name' => __( 'Delete WooCommerce tax rates', 'woocommerce' ),
'button' => __( 'Delete tax rates', 'woocommerce' ),
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
__( 'This option will delete ALL of your tax rates, use with caution.', 'woocommerce' )
__( 'This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce' )
),
),
'delete_webhook_logs' => array(
'name' => __( 'Delete WebHook logs', 'woocommerce' ),
'button' => __( 'Delete logs', 'woocommerce' ),
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
__( 'This tool removes WebHook logs. This will not delete the WebHooks themselves.', 'woocommerce' )
),
),
'reset_tracking' => array(
'name' => __( 'Reset usage tracking settings', 'woocommerce' ),
'button' => __( 'Reset usage tracking settings', 'woocommerce' ),
'name' => __( 'Reset usage tracking', 'woocommerce' ),
'button' => __( 'Reset', 'woocommerce' ),
'desc' => __( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', 'woocommerce' ),
),
);
@ -218,11 +227,11 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
}
$tool = $tools[ $request['id'] ];
return rest_ensure_response( $this->prepare_item_for_response( array(
'id' => $request['id'],
'name' => $tool['name'],
'action' => $tool['button'],
'description' => $tool['desc'],
), $request ) );
'id' => $request['id'],
'name' => $tool['name'],
'action' => $tool['button'],
'description' => $tool['desc'],
), $request ) );
}
/**
@ -459,6 +468,12 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
WC_Cache_Helper::incr_cache_prefix( 'taxes' );
$message = __( 'Tax rates successfully deleted', 'woocommerce' );
break;
case 'delete_webhook_logs' :
$result = absint( $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type='webhook_delivery';" ) );
$wpdb->query( "DELETE commentmeta FROM {$wpdb->commentmeta} commentmeta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = commentmeta.comment_id WHERE comments.comment_ID IS NULL;" );
$message = sprintf( __( '%d logs deleted', 'woocommerce' ), $result );
break;
case 'reset_tracking' :
delete_option( 'woocommerce_allow_tracking' );
WC_Admin_Notices::add_notice( 'tracking' );

View File

@ -297,6 +297,7 @@ class WC_API_Coupons extends WC_API_Resource {
update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $coupon_data['customer_emails'] ) ) );
do_action( 'woocommerce_api_create_coupon', $id, $data );
do_action( 'woocommerce_new_coupon', $id );
$this->server->send_status( 201 );
@ -432,6 +433,7 @@ class WC_API_Coupons extends WC_API_Resource {
}
do_action( 'woocommerce_api_edit_coupon', $id, $data );
do_action( 'woocommerce_update_coupon', $id );
return $this->get_coupon( $id );
} catch ( WC_API_Exception $e ) {

View File

@ -464,6 +464,7 @@ class WC_API_Orders extends WC_API_Resource {
wc_delete_shop_order_transients( $order );
do_action( 'woocommerce_api_create_order', $order->get_id(), $data, $this );
do_action( 'woocommerce_new_order', $order->get_id() );
wc_transaction_query( 'commit' );
@ -632,6 +633,7 @@ class WC_API_Orders extends WC_API_Resource {
wc_delete_shop_order_transients( $order );
do_action( 'woocommerce_api_edit_order', $order->get_id(), $data, $this );
do_action( 'woocommerce_update_order', $order->get_id() );
return $this->get_order( $id );

View File

@ -295,6 +295,7 @@ class WC_API_Coupons extends WC_API_Resource {
update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $coupon_data['customer_emails'] ) ) );
do_action( 'woocommerce_api_create_coupon', $id, $data );
do_action( 'woocommerce_new_coupon', $id );
$this->server->send_status( 201 );
@ -430,6 +431,7 @@ class WC_API_Coupons extends WC_API_Resource {
}
do_action( 'woocommerce_api_edit_coupon', $id, $data );
do_action( 'woocommerce_update_coupon', $id );
return $this->get_coupon( $id );
} catch ( WC_API_Exception $e ) {

View File

@ -506,6 +506,7 @@ class WC_API_Orders extends WC_API_Resource {
wc_delete_shop_order_transients( $order );
do_action( 'woocommerce_api_create_order', $order->get_id(), $data, $this );
do_action( 'woocommerce_new_order', $order->get_id() );
wc_transaction_query( 'commit' );
@ -671,6 +672,7 @@ class WC_API_Orders extends WC_API_Resource {
wc_delete_shop_order_transients( $order );
do_action( 'woocommerce_api_edit_order', $order->get_id(), $data, $this );
do_action( 'woocommerce_update_order', $order->get_id() );
return $this->get_order( $id );
} catch ( WC_Data_Exception $e ) {

View File

@ -338,15 +338,13 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
$customer->set_username( $request['username'] );
$customer->set_password( $request['password'] );
$customer->set_email( $request['email'] );
$this->update_customer_meta_fields( $customer, $request );
$customer->save();
if ( ! $customer->get_id() ) {
throw new WC_REST_Exception( 'woocommerce_rest_cannot_create', __( 'This resource cannot be created.', 'woocommerce' ), 400 );
}
$this->update_customer_meta_fields( $customer, $request );
$customer->save();
$user_data = get_userdata( $customer->get_id() );
$this->update_additional_fields_for_object( $user_data, $request );

View File

@ -113,6 +113,8 @@ class WC_AJAX {
'add_order_fee' => false,
'add_order_shipping' => false,
'add_order_tax' => false,
'add_coupon_discount' => false,
'remove_order_coupon' => false,
'remove_order_item' => false,
'remove_order_tax' => false,
'reduce_order_item_stock' => false,
@ -365,7 +367,7 @@ class WC_AJAX {
do_action( 'woocommerce_ajax_added_to_cart', $product_id );
if ( get_option( 'woocommerce_cart_redirect_after_add' ) == 'yes' ) {
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
wc_add_to_cart_message( array( $product_id => $quantity ), true );
}
@ -891,6 +893,60 @@ class WC_AJAX {
}
}
/**
* Add order discount via ajax.
*/
public static function add_coupon_discount() {
check_ajax_referer( 'order-item', 'security' );
if ( ! current_user_can( 'edit_shop_orders' ) ) {
wp_die( -1 );
}
try {
$order_id = absint( $_POST['order_id'] );
$order = wc_get_order( $order_id );
$order->apply_coupon( wc_clean( $_POST['coupon'] ) );
ob_start();
include( 'admin/meta-boxes/views/html-order-items.php' );
wp_send_json_success( array(
'html' => ob_get_clean(),
) );
} catch ( Exception $e ) {
wp_send_json_error( array( 'error' => $e->getMessage() ) );
}
}
/**
* Remove coupon from an order via ajax.
*/
public static function remove_order_coupon() {
check_ajax_referer( 'order-item', 'security' );
if ( ! current_user_can( 'edit_shop_orders' ) ) {
wp_die( -1 );
}
try {
$order_id = absint( $_POST['order_id'] );
$order = wc_get_order( $order_id );
$order->remove_coupon( wc_clean( $_POST['coupon'] ) );
ob_start();
include( 'admin/meta-boxes/views/html-order-items.php' );
wp_send_json_success( array(
'html' => ob_get_clean(),
) );
} catch ( Exception $e ) {
wp_send_json_error( array( 'error' => $e->getMessage() ) );
}
}
/**
* Remove an order item.
*/
@ -901,18 +957,32 @@ class WC_AJAX {
wp_die( -1 );
}
$order_item_ids = $_POST['order_item_ids'];
try {
$order_id = absint( $_POST['order_id'] );
$order_item_ids = $_POST['order_item_ids'];
if ( ! is_array( $order_item_ids ) && is_numeric( $order_item_ids ) ) {
$order_item_ids = array( $order_item_ids );
}
if ( sizeof( $order_item_ids ) > 0 ) {
foreach ( $order_item_ids as $id ) {
wc_delete_order_item( absint( $id ) );
if ( ! is_array( $order_item_ids ) && is_numeric( $order_item_ids ) ) {
$order_item_ids = array( $order_item_ids );
}
if ( sizeof( $order_item_ids ) > 0 ) {
foreach ( $order_item_ids as $id ) {
wc_delete_order_item( absint( $id ) );
}
}
$order = wc_get_order( $order_id );
$order->calculate_totals( true );
ob_start();
include( 'admin/meta-boxes/views/html-order-items.php' );
wp_send_json_success( array(
'html' => ob_get_clean(),
) );
} catch ( Exception $e ) {
wp_send_json_error( array( 'error' => $e->getMessage() ) );
}
wp_die();
}
/**
@ -925,15 +995,24 @@ class WC_AJAX {
wp_die( -1 );
}
$order_id = absint( $_POST['order_id'] );
$rate_id = absint( $_POST['rate_id'] );
try {
$order_id = absint( $_POST['order_id'] );
$rate_id = absint( $_POST['rate_id'] );
wc_delete_order_item( $rate_id );
wc_delete_order_item( $rate_id );
// Return HTML items
$order = wc_get_order( $order_id );
include( 'admin/meta-boxes/views/html-order-items.php' );
wp_die();
$order = wc_get_order( $order_id );
$order->calculate_totals( false );
ob_start();
include( 'admin/meta-boxes/views/html-order-items.php' );
wp_send_json_success( array(
'html' => ob_get_clean(),
) );
} catch ( Exception $e ) {
wp_send_json_error( array( 'error' => $e->getMessage() ) );
}
}
/**

View File

@ -374,7 +374,7 @@ class WC_Auth {
exit;
}
} else {
throw new Exception( __( 'You do not have permissions to access this page!', 'woocommerce' ) );
throw new Exception( __( 'You do not have permission to access this page', 'woocommerce' ) );
}
} catch ( Exception $e ) {
$this->maybe_delete_key( $consumer_data );

View File

@ -73,21 +73,21 @@ class WC_Autoloader {
$file = $this->get_file_name_from_class( $class );
$path = '';
if ( strpos( $class, 'wc_addons_gateway_' ) === 0 ) {
if ( 0 === strpos( $class, 'wc_addons_gateway_' ) ) {
$path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 18 ) . '/';
} elseif ( strpos( $class, 'wc_gateway_' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_gateway_' ) ) {
$path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 11 ) . '/';
} elseif ( strpos( $class, 'wc_shipping_' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_shipping_' ) ) {
$path = $this->include_path . 'shipping/' . substr( str_replace( '_', '-', $class ), 12 ) . '/';
} elseif ( strpos( $class, 'wc_shortcode_' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_shortcode_' ) ) {
$path = $this->include_path . 'shortcodes/';
} elseif ( strpos( $class, 'wc_meta_box' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_meta_box' ) ) {
$path = $this->include_path . 'admin/meta-boxes/';
} elseif ( strpos( $class, 'wc_admin' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_admin' ) ) {
$path = $this->include_path . 'admin/';
} elseif ( strpos( $class, 'wc_payment_token_' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_payment_token_' ) ) {
$path = $this->include_path . 'payment-tokens/';
} elseif ( strpos( $class, 'wc_log_handler_' ) === 0 ) {
} elseif ( 0 === strpos( $class, 'wc_log_handler_' ) ) {
$path = $this->include_path . 'log-handlers/';
}

View File

@ -155,7 +155,7 @@ class WC_Breadcrumb {
} else {
$cat = current( get_the_category( $post ) );
if ( $cat ) {
$this->term_ancestors( $cat->term_id, 'post_category' );
$this->term_ancestors( $cat->term_id, 'category' );
$this->add_crumb( $cat->name, get_term_link( $cat ) );
}
}
@ -247,8 +247,7 @@ class WC_Breadcrumb {
$this_category = get_category( $GLOBALS['wp_query']->get_queried_object() );
if ( 0 != $this_category->parent ) {
$this->term_ancestors( $this_category->parent, 'post_category' );
$this->add_crumb( $this_category->name, get_category_link( $this_category->term_id ) );
$this->term_ancestors( $this_category->term_id, 'category' );
}
$this->add_crumb( single_cat_title( '', false ), get_category_link( $this_category->term_id ) );

View File

@ -0,0 +1,201 @@
<?php
/**
* Cart session handling class.
*
* @author Automattic
* @package WooCommerce/Classes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC_Cart_Session class.
*
* @since 3.2.0
*/
final class WC_Cart_Session {
/**
* Reference to cart object.
*
* @since 3.2.0
* @var array
*/
protected $cart;
/**
* Sets up the items provided, and calculate totals.
*
* @since 3.2.0
* @param object $cart Cart object to calculate totals for.
*/
public function __construct( &$cart = null ) {
$this->cart = $cart;
add_action( 'wp_loaded', array( $this, 'get_cart_from_session' ) );
add_action( 'woocommerce_cart_emptied', array( $this, 'destroy_cart_session' ) );
add_action( 'wp', array( $this, 'maybe_set_cart_cookies' ), 99 );
add_action( 'shutdown', array( $this, 'maybe_set_cart_cookies' ), 0 );
add_action( 'woocommerce_add_to_cart', array( $this, 'maybe_set_cart_cookies' ) );
add_action( 'woocommerce_after_calculate_totals', array( $this, 'set_session' ) );
add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'set_session' ) );
add_action( 'woocommerce_removed_coupon', array( $this, 'set_session' ) );
add_action( 'woocommerce_cart_updated', array( $this, 'persistent_cart_update' ) );
}
/**
* Get the cart data from the PHP session and store it in class variables.
*
* @since 3.2.0
*/
public function get_cart_from_session() {
$update_cart_session = false;
$totals = WC()->session->get( 'cart_totals', null );
$cart = WC()->session->get( 'cart', null );
$this->cart->set_totals( $totals );
$this->cart->set_applied_coupons( WC()->session->get( 'applied_coupons', array() ) );
$this->cart->set_coupon_discount_totals( WC()->session->get( 'coupon_discount_totals', array() ) );
$this->cart->set_coupon_discount_tax_totals( WC()->session->get( 'coupon_discount_tax_totals', array() ) );
$this->cart->set_removed_cart_contents( WC()->session->get( 'removed_cart_contents', array() ) );
if ( is_null( $cart ) && ( $saved_cart = get_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), true ) ) ) {
$cart = $saved_cart['cart'];
$update_cart_session = true;
} elseif ( is_null( $cart ) ) {
$cart = array();
}
if ( is_array( $cart ) ) {
$cart_contents = array();
update_meta_cache( 'post', wp_list_pluck( $cart, 'product_id' ) ); // Prime meta cache to reduce future queries.
update_object_term_cache( wp_list_pluck( $cart, 'product_id' ), 'product' );
foreach ( $cart as $key => $values ) {
$product = wc_get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] );
if ( ! empty( $product ) && $product->exists() && $values['quantity'] > 0 ) {
if ( ! $product->is_purchasable() ) {
$update_cart_session = true; // Flag to indicate the stored cart should be updated.
/* translators: %s: product name */
wc_add_notice( sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'woocommerce' ), $product->get_name() ), 'error' );
do_action( 'woocommerce_remove_cart_item_from_session', $key, $values );
} else {
// Put session data into array. Run through filter so other plugins can load their own session data.
$session_data = array_merge( $values, array( 'data' => $product ) );
$cart_contents[ $key ] = apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key );
}
}
}
$this->cart->set_cart_contents( $cart_contents );
}
do_action( 'woocommerce_cart_loaded_from_session', $this->cart );
if ( $update_cart_session || is_null( $totals ) ) {
WC()->session->set( 'cart', $this->get_cart_for_session() );
$this->cart->calculate_totals();
}
}
/**
* Destroy cart session data.
*
* @since 3.2.0
*/
public function destroy_cart_session() {
WC()->session->set( 'cart', null );
WC()->session->set( 'cart_totals', null );
WC()->session->set( 'applied_coupons', null );
WC()->session->set( 'coupon_discount_totals', null );
WC()->session->set( 'coupon_discount_tax_totals', null );
WC()->session->set( 'removed_cart_contents', null );
WC()->session->set( 'order_awaiting_payment', null );
}
/**
* Will set cart cookies if needed and when possible.
*
* @since 3.2.0
*/
public function maybe_set_cart_cookies() {
if ( ! headers_sent() && did_action( 'wp_loaded' ) ) {
if ( ! $this->cart->is_empty() ) {
$this->set_cart_cookies( true );
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
$this->set_cart_cookies( false );
}
}
}
/**
* Sets the php session data for the cart and coupons.
*/
public function set_session() {
WC()->session->set( 'cart', $this->get_cart_for_session() );
WC()->session->set( 'cart_totals', $this->cart->get_totals() );
WC()->session->set( 'applied_coupons', $this->cart->get_applied_coupons() );
WC()->session->set( 'coupon_discount_totals', $this->cart->get_coupon_discount_totals() );
WC()->session->set( 'coupon_discount_tax_totals', $this->cart->get_coupon_discount_tax_totals() );
WC()->session->set( 'removed_cart_contents', $this->cart->get_removed_cart_contents() );
do_action( 'woocommerce_cart_updated' );
}
/**
* Returns the contents of the cart in an array without the 'data' element.
*
* @return array contents of the cart
*/
public function get_cart_for_session() {
$cart_session = array();
foreach ( $this->cart->get_cart() as $key => $values ) {
$cart_session[ $key ] = $values;
unset( $cart_session[ $key ]['data'] ); // Unset product object.
}
return $cart_session;
}
/**
* Save the persistent cart when the cart is updated.
*/
public function persistent_cart_update() {
if ( get_current_user_id() ) {
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), array( 'cart' => $this->get_cart_for_session() ) );
}
}
/**
* Delete the persistent cart permanently.
*/
public function persistent_cart_destroy() {
if ( get_current_user_id() ) {
delete_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id() );
}
}
/**
* Set cart hash cookie and items in cart.
*
* @access private
* @param bool $set Should cookies be set (true) or unset.
*/
private function set_cart_cookies( $set = true ) {
if ( $set ) {
wc_setcookie( 'woocommerce_items_in_cart', 1 );
wc_setcookie( 'woocommerce_cart_hash', md5( wp_json_encode( $this->get_cart_for_session() ) ) );
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS );
wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS );
}
do_action( 'woocommerce_set_cart_cookies', $set );
}
}

View File

@ -26,7 +26,7 @@ final class WC_Cart_Totals {
* @since 3.2.0
* @var array
*/
protected $object;
protected $cart;
/**
* Reference to customer object.
@ -69,12 +69,20 @@ final class WC_Cart_Totals {
protected $coupons = array();
/**
* Discount amounts in cents after calculation for the cart.
* Item/coupon discount totals.
*
* @since 3.2.0
* @var array
*/
protected $discount_totals = array();
protected $coupon_discount_totals = array();
/**
* Item/coupon discount tax totals.
*
* @since 3.2.0
* @var array
*/
protected $coupon_discount_tax_totals = array();
/**
* Should taxes be calculated?
@ -97,12 +105,9 @@ final class WC_Cart_Totals {
'items_total' => 0,
'items_total_tax' => 0,
'total' => 0,
'taxes' => array(),
'tax_total' => 0,
'shipping_total' => 0,
'shipping_tax_total' => 0,
'discounts_total' => 0,
'discounts_tax_total' => 0,
);
/**
@ -113,7 +118,7 @@ final class WC_Cart_Totals {
*/
public function __construct( &$cart = null ) {
if ( is_a( $cart, 'WC_Cart' ) ) {
$this->object = $cart;
$this->cart = $cart;
$this->calculate_tax = wc_tax_enabled() && ! $cart->get_customer()->get_is_vat_exempt();
$this->calculate();
}
@ -126,8 +131,8 @@ final class WC_Cart_Totals {
*/
protected function calculate() {
$this->calculate_item_totals();
$this->calculate_fee_totals();
$this->calculate_shipping_totals();
$this->calculate_fee_totals();
$this->calculate_totals();
}
@ -140,6 +145,8 @@ final class WC_Cart_Totals {
protected function get_default_item_props() {
return (object) array(
'object' => null,
'tax_class' => '',
'taxable' => false,
'quantity' => 0,
'product' => false,
'price_includes_tax' => false,
@ -159,6 +166,9 @@ final class WC_Cart_Totals {
*/
protected function get_default_fee_props() {
return (object) array(
'object' => null,
'tax_class' => '',
'taxable' => false,
'total_tax' => 0,
'taxes' => array(),
);
@ -172,6 +182,9 @@ final class WC_Cart_Totals {
*/
protected function get_default_shipping_props() {
return (object) array(
'object' => null,
'tax_class' => '',
'taxable' => false,
'total' => 0,
'total_tax' => 0,
'taxes' => array(),
@ -200,12 +213,14 @@ final class WC_Cart_Totals {
*
* @since 3.2.0
*/
protected function set_items() {
protected function get_items_from_cart() {
$this->items = array();
foreach ( $this->object->get_cart() as $cart_item_key => $cart_item ) {
foreach ( $this->cart->get_cart() as $cart_item_key => $cart_item ) {
$item = $this->get_default_item_props();
$item->object = $cart_item;
$item->tax_class = $cart_item['data']->get_tax_class();
$item->taxable = 'taxable' === $cart_item['data']->get_tax_status();
$item->price_includes_tax = wc_prices_include_tax();
$item->quantity = $cart_item['quantity'];
$item->subtotal = wc_add_number_precision_deep( $cart_item['data']->get_price() ) * $cart_item['quantity'];
@ -221,17 +236,19 @@ final class WC_Cart_Totals {
*
* @since 3.2.0
*/
protected function set_fees() {
protected function get_fees_from_cart() {
$this->fees = array();
$this->object->calculate_fees();
$this->cart->calculate_fees();
foreach ( $this->object->get_fees() as $fee_key => $fee_object ) {
$fee = $this->get_default_fee_props();
$fee->object = $fee_object;
$fee->total = wc_add_number_precision_deep( $fee->object->amount );
foreach ( $this->cart->get_fees() as $fee_key => $fee_object ) {
$fee = $this->get_default_fee_props();
$fee->object = $fee_object;
$fee->tax_class = $fee->object->tax_class;
$fee->taxable = $fee->object->taxable;
$fee->total = wc_add_number_precision_deep( $fee->object->amount );
if ( $this->calculate_tax && $fee->object->taxable ) {
$fee->taxes = WC_Tax::calc_tax( $fee->total, WC_Tax::get_rates( $fee->object->tax_class, $this->object->get_customer() ), false );
$fee->taxes = WC_Tax::calc_tax( $fee->total, WC_Tax::get_rates( $fee->object->tax_class, $this->cart->get_customer() ), false );
$fee->total_tax = array_sum( $fee->taxes );
if ( ! $this->round_at_subtotal() ) {
@ -248,12 +265,14 @@ final class WC_Cart_Totals {
*
* @since 3.2.0
*/
protected function set_shipping() {
protected function get_shipping_from_cart() {
$this->shipping = array();
foreach ( $this->object->calculate_shipping() as $key => $shipping_object ) {
foreach ( $this->cart->calculate_shipping() as $key => $shipping_object ) {
$shipping_line = $this->get_default_shipping_props();
$shipping_line->object = $shipping_object;
$shipping_line->tax_class = get_option( 'woocommerce_shipping_tax_class' );
$shipping_line->taxable = true;
$shipping_line->total = wc_add_number_precision_deep( $shipping_object->cost );
$shipping_line->taxes = wc_add_number_precision_deep( $shipping_object->taxes );
$shipping_line->total_tax = wc_add_number_precision_deep( array_sum( $shipping_object->taxes ) );
@ -272,8 +291,41 @@ final class WC_Cart_Totals {
*
* @since 3.2.0
*/
protected function set_coupons() {
$this->coupons = $this->object->get_coupons();
protected function get_coupons_from_cart() {
$this->coupons = $this->cart->get_coupons();
foreach ( $this->coupons as $coupon ) {
switch ( $coupon->get_discount_type() ) {
case 'fixed_product' :
$coupon->sort = 1;
break;
case 'percent' :
$coupon->sort = 2;
break;
case 'fixed_cart' :
$coupon->sort = 3;
break;
default:
$coupon->sort = 0;
break;
}
}
uasort( $this->coupons, array( $this, 'sort_coupons_callback' ) );
}
/**
* Sort coupons so discounts apply consistently.
*
* @param WC_Coupon $a Coupon object.
* @param WC_Coupon $b Coupon object.
* @return int
*/
protected function sort_coupons_callback( $a, $b ) {
if ( $a->sort === $b->sort ) {
return $a->get_id() - $b->get_id();
}
return ( $a->sort < $b->sort ) ? -1 : 1;
}
/**
@ -311,7 +363,7 @@ final class WC_Cart_Totals {
*/
protected function get_discounted_price_in_cents( $item_key ) {
$item = $this->items[ $item_key ];
$price = $item->subtotal - $this->discount_totals[ $item_key ];
$price = isset( $this->coupon_discount_totals[ $item_key ] ) ? $item->subtotal - $this->coupon_discount_totals[ $item_key ] : $item->subtotal;
if ( $item->price_includes_tax ) {
$price += $item->subtotal_tax;
@ -327,7 +379,33 @@ final class WC_Cart_Totals {
*/
protected function get_item_tax_rates( $item ) {
$tax_class = $item->product->get_tax_class();
return isset( $this->item_tax_rates[ $tax_class ] ) ? $this->item_tax_rates[ $tax_class ] : $this->item_tax_rates[ $tax_class ] = WC_Tax::get_rates( $item->product->get_tax_class(), $this->object->get_customer() );
return isset( $this->item_tax_rates[ $tax_class ] ) ? $this->item_tax_rates[ $tax_class ] : $this->item_tax_rates[ $tax_class ] = WC_Tax::get_rates( $item->product->get_tax_class(), $this->cart->get_customer() );
}
/**
* Get item costs grouped by tax class.
*
* @since 3.2.0
* @return array
*/
protected function get_item_costs_by_tax_class() {
$tax_classes = array(
'non-taxable' => 0,
);
foreach ( $this->items + $this->fees + $this->shipping as $item ) {
if ( ! isset( $tax_classes[ $item->tax_class ] ) ) {
$tax_classes[ $item->tax_class ] = 0;
}
if ( $item->taxable ) {
$tax_classes[ $item->tax_class ] += $item->total;
} else {
$tax_classes['non-taxable'] += $item->total;
}
}
return $tax_classes;
}
/**
@ -366,32 +444,56 @@ final class WC_Cart_Totals {
}
/**
* Get all tax rows from items (including shipping and product line items).
* Get taxes merged by type.
*
* @since 3.2.0
* @since 3.2.0
* @param array|string $types Types to merge and return. Defaults to all.
* @return array
*/
protected function get_merged_taxes() {
protected function get_merged_taxes( $in_cents = false, $types = array( 'items', 'fees', 'shipping' ) ) {
$items = array();
$taxes = array();
foreach ( array_merge( $this->items, $this->fees, $this->shipping ) as $item ) {
foreach ( $item->taxes as $rate_id => $rate ) {
$taxes[ $rate_id ] = array( 'tax_total' => 0, 'shipping_tax_total' => 0 );
if ( is_string( $types ) ) {
$types = array( $types );
}
foreach ( $types as $type ) {
if ( isset( $this->$type ) ) {
$items = array_merge( $items, $this->$type );
}
}
foreach ( $this->items + $this->fees as $item ) {
foreach ( $items as $item ) {
foreach ( $item->taxes as $rate_id => $rate ) {
$taxes[ $rate_id ]['tax_total'] = $taxes[ $rate_id ]['tax_total'] + $rate;
if ( ! isset( $taxes[ $rate_id ] ) ) {
$taxes[ $rate_id ] = 0;
}
$taxes[ $rate_id ] += $rate;
}
}
foreach ( $this->shipping as $item ) {
foreach ( $item->taxes as $rate_id => $rate ) {
$taxes[ $rate_id ]['shipping_tax_total'] = $taxes[ $rate_id ]['shipping_tax_total'] + $rate;
return $in_cents ? $taxes : wc_remove_number_precision_deep( $taxes );
}
/**
* Combine item taxes into a single array, preserving keys.
*
* @since 3.2.0
* @param array $taxes Taxes to combine.
* @return array
*/
protected function combine_item_taxes( $item_taxes ) {
$merged_taxes = array();
foreach ( $item_taxes as $taxes ) {
foreach ( $taxes as $tax_id => $tax_amount ) {
if ( ! isset( $merged_taxes[ $tax_id ] ) ) {
$merged_taxes[ $tax_id ] = 0;
}
$merged_taxes[ $tax_id ] += $tax_amount;
}
}
return $taxes;
return $merged_taxes;
}
/*
@ -406,7 +508,7 @@ final class WC_Cart_Totals {
* @since 3.2.0
*/
protected function calculate_item_totals() {
$this->set_items();
$this->get_items_from_cart();
$this->calculate_item_subtotals();
$this->calculate_discounts();
@ -420,10 +522,10 @@ final class WC_Cart_Totals {
*
* This is legacy and should probably be deprecated in the future.
* $item->object is the cart item object.
* $this->object is the cart object.
* $this->cart is the cart object.
*/
$item->total = wc_add_number_precision(
apply_filters( 'woocommerce_get_discounted_price', wc_remove_number_precision( $item->total ), $item->object, $this->object )
apply_filters( 'woocommerce_get_discounted_price', wc_remove_number_precision( $item->total ), $item->object, $this->cart )
);
}
@ -442,8 +544,9 @@ final class WC_Cart_Totals {
}
}
$this->object->cart_contents[ $item_key ]['line_total'] = wc_remove_number_precision( $item->total );
$this->object->cart_contents[ $item_key ]['line_tax'] = wc_remove_number_precision( $item->total_tax );
$this->cart->cart_contents[ $item_key ]['line_tax_data']['total'] = wc_remove_number_precision_deep( $item->taxes );
$this->cart->cart_contents[ $item_key ]['line_total'] = wc_remove_number_precision( $item->total );
$this->cart->cart_contents[ $item_key ]['line_tax'] = wc_remove_number_precision( $item->total_tax );
}
$this->set_total( 'items_total', array_sum( array_values( wp_list_pluck( $this->items, 'total' ) ) ) );
@ -470,6 +573,8 @@ final class WC_Cart_Totals {
$item = $this->adjust_non_base_location_price( $item );
}
$subtotal_taxes = array();
if ( $this->calculate_tax && $item->product->is_taxable() ) {
$subtotal_taxes = WC_Tax::calc_tax( $item->subtotal, $item->tax_rates, $item->price_includes_tax );
$item->subtotal_tax = array_sum( $subtotal_taxes );
@ -483,29 +588,30 @@ final class WC_Cart_Totals {
}
}
$this->object->cart_contents[ $item_key ]['line_subtotal'] = wc_remove_number_precision( $item->subtotal );
$this->object->cart_contents[ $item_key ]['line_subtotal_tax'] = wc_remove_number_precision( $item->subtotal_tax );
$this->cart->cart_contents[ $item_key ]['line_tax_data'] = array( 'subtotal' => wc_remove_number_precision_deep( $subtotal_taxes ) );
$this->cart->cart_contents[ $item_key ]['line_subtotal'] = wc_remove_number_precision( $item->subtotal );
$this->cart->cart_contents[ $item_key ]['line_subtotal_tax'] = wc_remove_number_precision( $item->subtotal_tax );
}
$this->set_total( 'items_subtotal', array_sum( array_values( wp_list_pluck( $this->items, 'subtotal' ) ) ) );
$this->set_total( 'items_subtotal_tax', array_sum( array_values( wp_list_pluck( $this->items, 'subtotal_tax' ) ) ) );
$this->object->subtotal = $this->get_total( 'items_subtotal' ) + $this->get_total( 'items_subtotal_tax' );
$this->object->subtotal_ex_tax = $this->get_total( 'items_subtotal' );
$this->cart->set_subtotal( $this->get_total( 'items_subtotal' ) );
$this->cart->set_subtotal_tax( $this->get_total( 'items_subtotal_tax' ) );
}
/**
* Calculate all discount and coupon amounts.
* Calculate COUPON based discounts which change item prices.
*
* @since 3.2.0
* @uses WC_Discounts class.
*/
protected function calculate_discounts() {
$this->set_coupons();
$this->get_coupons_from_cart();
$discounts = new WC_Discounts( $this->object );
$discounts = new WC_Discounts( $this->cart );
foreach ( $this->coupons as $coupon ) {
$discounts->apply_discount( $coupon );
$discounts->apply_coupon( $coupon );
}
$coupon_discount_amounts = $discounts->get_discounts_by_coupon( true );
@ -516,40 +622,26 @@ final class WC_Cart_Totals {
foreach ( $discounts->get_discounts( true ) as $coupon_code => $coupon_discounts ) {
$coupon_discount_tax_amounts[ $coupon_code ] = 0;
foreach ( $coupon_discounts as $item_key => $item_discount ) {
foreach ( $coupon_discounts as $item_key => $coupon_discount ) {
$item = $this->items[ $item_key ];
if ( $item->product->is_taxable() ) {
$item_tax = array_sum( WC_Tax::calc_tax( $item_discount, $item->tax_rates, $item->price_includes_tax ) );
$item_tax = array_sum( WC_Tax::calc_tax( $coupon_discount, $item->tax_rates, $item->price_includes_tax ) );
$coupon_discount_tax_amounts[ $coupon_code ] += $item_tax;
}
}
$coupon_discount_amounts[ $coupon_code ] -= $coupon_discount_tax_amounts[ $coupon_code ];
if ( wc_prices_include_tax() ) {
$coupon_discount_amounts[ $coupon_code ] -= $coupon_discount_tax_amounts[ $coupon_code ];
}
}
}
$this->discount_totals = $discounts->get_discounts_by_item( true );
$this->object->coupon_discount_amounts = wc_remove_number_precision_deep( $coupon_discount_amounts );
$this->object->coupon_discount_tax_amounts = wc_remove_number_precision_deep( $coupon_discount_tax_amounts );
$this->coupon_discount_totals = (array) $discounts->get_discounts_by_item( true );
$this->coupon_discount_tax_totals = $coupon_discount_tax_amounts;
$this->set_total( 'discounts_total', ! empty( $this->discount_totals ) ? array_sum( $this->discount_totals ) : 0 );
$this->set_total( 'discounts_tax_total', array_sum( $coupon_discount_tax_amounts ) );
}
/**
* Return discounted tax amount for an item.
*
* @param object $item
* @param int $discount_amount
* @return int
*/
protected function get_item_discount_tax( $item, $discount_amount ) {
if ( $item->product->is_taxable() ) {
$taxes = WC_Tax::calc_tax( $discount_amount, $item->tax_rates, false );
return array_sum( $taxes );
}
return 0;
$this->cart->set_coupon_discount_totals( wc_remove_number_precision_deep( $coupon_discount_amounts ) );
$this->cart->set_coupon_discount_tax_totals( wc_remove_number_precision_deep( $coupon_discount_tax_amounts ) );
}
/**
@ -560,15 +652,18 @@ final class WC_Cart_Totals {
* @since 3.2.0
*/
protected function calculate_fee_totals() {
$this->set_fees();
$this->get_fees_from_cart();
$this->set_total( 'fees_total', array_sum( wp_list_pluck( $this->fees, 'total' ) ) );
$this->set_total( 'fees_total_tax', array_sum( wp_list_pluck( $this->fees, 'total_tax' ) ) );
foreach ( $this->fees as $fee_key => $fee ) {
$this->object->fees[ $fee_key ]->tax = wc_remove_number_precision_deep( $fee->total_tax );
$this->object->fees[ $fee_key ]->tax_data = wc_remove_number_precision_deep( $fee->taxes );
$this->cart->fees[ $fee_key ]->tax = wc_remove_number_precision_deep( $fee->total_tax );
$this->cart->fees[ $fee_key ]->tax_data = wc_remove_number_precision_deep( $fee->taxes );
}
$this->object->fee_total = wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total' ) ) );
$this->cart->set_fee_total( wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total' ) ) ) );
$this->cart->set_fee_tax( wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total_tax' ) ) ) );
$this->cart->set_fee_taxes( wc_remove_number_precision_deep( $this->combine_item_taxes( wp_list_pluck( $this->fees, 'taxes' ) ) ) );
}
/**
@ -577,12 +672,13 @@ final class WC_Cart_Totals {
* @since 3.2.0
*/
protected function calculate_shipping_totals() {
$this->set_shipping();
$this->get_shipping_from_cart();
$this->set_total( 'shipping_total', array_sum( wp_list_pluck( $this->shipping, 'total' ) ) );
$this->set_total( 'shipping_tax_total', array_sum( wp_list_pluck( $this->shipping, 'total_tax' ) ) );
$this->object->shipping_total = $this->get_total( 'shipping_total' );
$this->object->shipping_tax_total = $this->get_total( 'shipping_tax_total' );
$this->cart->set_shipping_total( $this->get_total( 'shipping_total' ) );
$this->cart->set_shipping_tax( $this->get_total( 'shipping_tax_total' ) );
$this->cart->set_shipping_taxes( wc_remove_number_precision_deep( $this->combine_item_taxes( wp_list_pluck( $this->shipping, 'taxes' ) ) ) );
}
/**
@ -591,26 +687,24 @@ final class WC_Cart_Totals {
* @since 3.2.0
*/
protected function calculate_totals() {
$this->set_total( 'taxes', $this->get_merged_taxes() );
$this->set_total( 'tax_total', array_sum( wp_list_pluck( $this->get_total( 'taxes', true ), 'tax_total' ) ) );
$this->set_total( 'total', round( $this->get_total( 'items_total', true ) + $this->get_total( 'fees_total', true ) + $this->get_total( 'shipping_total', true ) + $this->get_total( 'tax_total', true ) + $this->get_total( 'shipping_tax_total', true ) ) );
$this->set_total( 'discounts_total', array_sum( $this->coupon_discount_totals ) );
$this->set_total( 'discounts_tax_total', array_sum( $this->coupon_discount_tax_totals ) );
$this->set_total( 'total', round( $this->get_total( 'items_total', true ) + $this->get_total( 'fees_total', true ) + $this->get_total( 'shipping_total', true ) + array_sum( $this->get_merged_taxes( true ) ) ) );
// Add totals to cart object.
$this->object->taxes = wp_list_pluck( $this->get_total( 'taxes' ), 'shipping_tax_total' );
$this->object->shipping_taxes = wp_list_pluck( $this->get_total( 'taxes' ), 'tax_total' );
$this->object->cart_contents_total = $this->get_total( 'items_total' );
$this->object->tax_total = $this->get_total( 'tax_total' );
$this->object->total = $this->get_total( 'total' );
$this->object->discount_cart = $this->get_total( 'discounts_total' ) - $this->get_total( 'discounts_tax_total' );
$this->object->discount_cart_tax = $this->get_total( 'discounts_tax_total' );
$this->cart->set_cart_contents_total( $this->get_total( 'items_total' ) );
$this->cart->set_cart_contents_tax( array_sum( $this->get_merged_taxes( false, 'items' ) ) );
$this->cart->set_cart_contents_taxes( $this->get_merged_taxes( false, 'items' ) );
$this->cart->set_discount_total( $this->get_total( 'discounts_total' ) );
$this->cart->set_discount_tax( $this->get_total( 'discounts_tax_total' ) );
$this->cart->set_total_tax( array_sum( $this->get_merged_taxes( false ) ) );
// Allow plugins to hook and alter totals before final total is calculated.
if ( has_action( 'woocommerce_calculate_totals' ) ) {
do_action( 'woocommerce_calculate_totals', $this->object );
do_action( 'woocommerce_calculate_totals', $this->cart );
}
// Allow plugins to filter the grand total, and sum the cart totals in case of modifications.
$totals_to_sum = wc_add_number_precision_deep( array( $this->object->cart_contents_total, $this->object->tax_total, $this->object->shipping_tax_total, $this->object->shipping_total, $this->object->fee_total ) );
$this->object->total = max( 0, apply_filters( 'woocommerce_calculated_total', wc_remove_number_precision( round( array_sum( $totals_to_sum ) ) ), $this->object ) );
$this->cart->set_total( max( 0, apply_filters( 'woocommerce_calculated_total', $this->get_total( 'total' ), $this->cart ) ) );
}
}

File diff suppressed because it is too large Load Diff

View File

@ -216,7 +216,7 @@ class WC_Checkout {
if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) {
$this->fields['account']['account_password'] = array(
'type' => 'password',
'label' => __( 'Account password', 'woocommerce' ),
'label' => __( 'Create account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
);
@ -313,12 +313,12 @@ class WC_Checkout {
$order->set_customer_user_agent( wc_get_user_agent() );
$order->set_customer_note( isset( $data['order_comments'] ) ? $data['order_comments'] : '' );
$order->set_payment_method( isset( $available_gateways[ $data['payment_method'] ] ) ? $available_gateways[ $data['payment_method'] ] : $data['payment_method'] );
$order->set_shipping_total( WC()->cart->shipping_total );
$order->set_discount_total( WC()->cart->get_cart_discount_total() );
$order->set_discount_tax( WC()->cart->get_cart_discount_tax_total() );
$order->set_cart_tax( WC()->cart->tax_total );
$order->set_shipping_tax( WC()->cart->shipping_tax_total );
$order->set_total( WC()->cart->total );
$order->set_shipping_total( WC()->cart->get_shipping_total() );
$order->set_discount_total( WC()->cart->get_discount_total() );
$order->set_discount_tax( WC()->cart->get_discount_tax() );
$order->set_cart_tax( WC()->cart->get_cart_contents_tax() + WC()->cart->get_fee_tax() );
$order->set_shipping_tax( WC()->cart->get_shipping_tax() );
$order->set_total( WC()->cart->get_total( 'edit' ) );
$this->create_order_line_items( $order, WC()->cart );
$this->create_order_fee_lines( $order, WC()->cart );
$this->create_order_shipping_lines( $order, WC()->session->get( 'chosen_shipping_methods' ), WC()->shipping->get_packages() );

View File

@ -447,6 +447,12 @@ class WC_Coupon extends WC_Legacy_Coupon {
* @throws WC_Data_Exception
*/
public function set_amount( $amount ) {
if ( $amount < 0 ) {
$this->error( 'coupon_invalid_amount', __( 'Invalid discount amount', 'woocommerce' ) );
}
if ( 'percent' === $this->get_discount_type() && $amount > 100 ) {
$this->error( 'coupon_invalid_amount', __( 'Invalid discount amount', 'woocommerce' ) );
}
$this->set_prop( 'amount', wc_format_decimal( $amount ) );
}

View File

@ -1,82 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* A discount.
*
* Represents a fixed, percent or coupon based discount calculated by WC_Discounts class.
*
* @author Automattic
* @package WooCommerce/Classes
* @version 3.2.0
* @since 3.2.0
*/
class WC_Discount {
/**
* Data array, with defaults.
*
* @var array
*/
protected $data = array(
'amount' => 0, // Discount amount.
'discount_type' => 'fixed', // Fixed, percent, or coupon.
'discount_total' => 0,
);
/**
* Get discount amount.
*
* @return int
*/
public function get_amount() {
return $this->data['amount'];
}
/**
* Discount amount - either fixed or percentage.
*
* @param string $raw_amount Amount discount gives.
*/
public function set_amount( $raw_amount ) {
$this->data['amount'] = wc_format_decimal( $raw_amount );
}
/**
* Get discount type.
*
* @return string
*/
public function get_discount_type() {
return $this->data['discount_type'];
}
/**
* Set discount type.
*
* @param string $discount_type Type of discount.
*/
public function set_discount_type( $discount_type ) {
$this->data['discount_type'] = $discount_type;
}
/**
* Get discount total.
*
* @return int
*/
public function get_discount_total() {
return $this->data['discount_total'];
}
/**
* Discount total.
*
* @param string $total Total discount applied.
*/
public function set_discount_total( $total ) {
$this->data['discount_total'] = wc_format_decimal( $total );
}
}

View File

@ -32,31 +32,26 @@ class WC_Discounts {
protected $discounts = array();
/**
* An array of applied WC_Discount objects.
*
* @var array
*/
protected $manual_discounts = array();
/**
* Constructor. @todo accept order objects.
* Constructor.
*
* @param array $object Cart or order object.
*/
public function __construct( $object = array() ) {
if ( is_a( $object, 'WC_Cart' ) ) {
$this->set_items_from_cart( $object );
} elseif ( is_a( $object, 'WC_Order' ) ) {
$this->set_items_from_order( $object );
}
}
/**
* Normalise cart/order items which will be discounted.
* Normalise cart items which will be discounted.
*
* @since 3.2.0
* @param array $cart Cart object.
*/
public function set_items_from_cart( $cart ) {
$this->items = $this->discounts = $this->manual_discounts = array();
$this->items = $this->discounts = array();
if ( ! is_a( $cart, 'WC_Cart' ) ) {
return;
@ -75,6 +70,32 @@ class WC_Discounts {
uasort( $this->items, array( $this, 'sort_by_price' ) );
}
/**
* Normalise order items which will be discounted.
*
* @since 3.2.0
* @param array $order Cart object.
*/
public function set_items_from_order( $order ) {
$this->items = $this->discounts = array();
if ( ! is_a( $order, 'WC_Order' ) ) {
return;
}
foreach ( $order->get_items() as $order_item ) {
$item = new stdClass();
$item->key = $order_item->get_id();
$item->object = $order_item;
$item->product = $order_item->get_product();
$item->quantity = $order_item->get_quantity();
$item->price = wc_add_number_precision_deep( $order_item->get_total() );
$this->items[ $order_item->get_id() ] = $item;
}
uasort( $this->items, array( $this, 'sort_by_price' ) );
}
/**
* Get items.
*
@ -107,11 +128,6 @@ class WC_Discounts {
*/
public function get_discounts( $in_cents = false ) {
$discounts = $this->discounts;
foreach ( $this->get_manual_discounts() as $manual_discount_key => $manual_discount ) {
$discounts[ $manual_discount_key ] = $manual_discount->get_discount_total();
}
return $in_cents ? $discounts : wc_remove_number_precision_deep( $discounts );
}
@ -124,7 +140,7 @@ class WC_Discounts {
*/
public function get_discounts_by_item( $in_cents = false ) {
$discounts = $this->discounts;
$item_discount_totals = array_shift( $discounts );
$item_discount_totals = (array) array_shift( $discounts );
foreach ( $discounts as $item_discounts ) {
foreach ( $item_discounts as $item_key => $item_discount ) {
@ -148,16 +164,6 @@ class WC_Discounts {
return $in_cents ? $coupon_discount_totals : wc_remove_number_precision_deep( $coupon_discount_totals );
}
/**
* Get an array of manual discounts which have been applied.
*
* @since 3.2.0
* @return WC_Discount[]
*/
public function get_manual_discounts() {
return $this->manual_discounts;
}
/**
* Get discounted price of an item without precision.
*
@ -180,88 +186,6 @@ class WC_Discounts {
return absint( $item->price - $this->get_discount( $item->key, true ) );
}
/**
* Get total remaining after discounts.
*
* @since 3.2.0
* @return int
*/
protected function get_total_after_discounts() {
$total_to_discount = 0;
foreach ( $this->items as $item ) {
$total_to_discount += $this->get_discounted_price_in_cents( $item );
}
foreach ( $this->manual_discounts as $key => $value ) {
$total_to_discount = $total_to_discount - $value->get_discount_total();
}
return $total_to_discount;
}
/**
* Generate a unique ID for a discount.
*
* @param WC_Discount $discount Discount object.
* @return string
*/
protected function generate_discount_id( $discount ) {
$discount_id = '';
$index = 1;
while ( ! $discount_id ) {
$discount_id = 'discount-' . $discount->get_amount() . ( 'percent' === $discount->get_discount_type() ? '%' : '' );
if ( 1 < $index ) {
$discount_id .= '-' . $index;
}
if ( isset( $this->manual_discounts[ $discount_id ] ) ) {
$index ++;
$discount_id = '';
}
}
return $discount_id;
}
/**
* Apply a discount to all items.
*
* @param string|object $raw_discount Accepts a string (fixed or percent discounts), or WC_Coupon object.
* @return bool|WP_Error True if applied or WP_Error instance in failure.
*/
public function apply_discount( $raw_discount ) {
if ( is_a( $raw_discount, 'WC_Coupon' ) ) {
return $this->apply_coupon( $raw_discount );
}
$discount = new WC_Discount;
if ( strstr( $raw_discount, '%' ) ) {
$discount->set_discount_type( 'percent' );
$discount->set_amount( trim( $raw_discount, '%' ) );
} elseif ( 0 < absint( $raw_discount ) ) {
$discount->set_discount_type( 'fixed' );
$discount->set_amount( wc_add_number_precision( absint( $raw_discount ) ) );
}
if ( ! $discount->get_amount() ) {
return new WP_Error( 'invalid_coupon', __( 'Invalid discount', 'woocommerce' ) );
}
$total_to_discount = $this->get_total_after_discounts();
if ( 'percent' === $discount->get_discount_type() ) {
$discount->set_discount_total( $discount->get_amount() * ( $total_to_discount / 100 ) );
} else {
$discount->set_discount_total( min( $discount->get_amount(), $total_to_discount ) );
}
$this->manual_discounts[ $this->generate_discount_id( $discount ) ] = $discount;
return true;
}
/**
* Apply a discount to all items using a coupon.
*
@ -269,7 +193,11 @@ class WC_Discounts {
* @param WC_Coupon $coupon Coupon object being applied to the items.
* @return bool|WP_Error True if applied or WP_Error instance in failure.
*/
protected function apply_coupon( $coupon ) {
public function apply_coupon( $coupon ) {
if ( ! is_a( $coupon, 'WC_Coupon' ) ) {
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon', 'woocommerce' ) );
}
$is_coupon_valid = $this->is_coupon_valid( $coupon );
if ( is_wp_error( $is_coupon_valid ) ) {
@ -298,7 +226,8 @@ class WC_Discounts {
foreach ( $items_to_apply as $item ) {
$discounted_price = $this->get_discounted_price_in_cents( $item );
$price_to_discount = wc_remove_number_precision( ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $item->price : $discounted_price );
$discount = min( $discounted_price, wc_add_number_precision( $coupon->get_discount_amount( $price_to_discount ), $item->object ) );
$discount = wc_add_number_precision( $coupon->get_discount_amount( $price_to_discount, $item->object ) ) * $item->quantity;
$discount = min( $discounted_price, $discount );
// Store code and discount amount per item.
$this->discounts[ $coupon->get_code() ][ $item->key ] += $discount;
@ -401,8 +330,14 @@ class WC_Discounts {
$cart_total += $price_to_discount;
// Run coupon calculations.
$discount = floor( $price_to_discount * ( $coupon->get_amount() / 100 ) );
$discount = min( $discounted_price, apply_filters( 'woocommerce_coupon_get_discount_amount', $discount, $price_to_discount, $item->object, false, $coupon ) );
$discount = floor( $price_to_discount * ( $coupon->get_amount() / 100 ) );
if ( has_filter( 'woocommerce_coupon_get_discount_amount' ) ) {
// Send through the legacy filter, but not as cents.
$discount = wc_add_number_precision( apply_filters( 'woocommerce_coupon_get_discount_amount', wc_remove_number_precision( $discount ), wc_remove_number_precision( $price_to_discount ), $item->object, false, $coupon ) );
}
$discount = min( $discounted_price, $discount );
$total_discount += $discount;
// Store code and discount amount per item.
@ -430,7 +365,7 @@ class WC_Discounts {
*/
protected function apply_coupon_fixed_product( $coupon, $items_to_apply, $amount = null ) {
$total_discount = 0;
$amount = $amount ? $amount: wc_add_number_precision( $coupon->get_amount() );
$amount = $amount ? $amount : wc_add_number_precision( $coupon->get_amount() );
foreach ( $items_to_apply as $item ) {
// Find out how much price is available to discount for the item.
@ -440,8 +375,14 @@ class WC_Discounts {
$price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $item->price: $discounted_price;
// Run coupon calculations.
$discount = $amount * $item->quantity;
$discount = min( $discounted_price, apply_filters( 'woocommerce_coupon_get_discount_amount', $discount, $price_to_discount, $item->object, false, $coupon ) );
$discount = $amount * $item->quantity;
if ( has_filter( 'woocommerce_coupon_get_discount_amount' ) ) {
// Send through the legacy filter, but not as cents.
$discount = wc_add_number_precision( apply_filters( 'woocommerce_coupon_get_discount_amount', wc_remove_number_precision( $discount ), wc_remove_number_precision( $price_to_discount ), $item->object, false, $coupon ) );
}
$discount = min( $discounted_price, $discount );
$total_discount += $discount;
// Store code and discount amount per item.
@ -468,19 +409,24 @@ class WC_Discounts {
return $total_discount;
}
$per_item_discount = absint( $amount / $item_count ); // round it down to the nearest cent.
if ( ! $amount ) {
// If there is no amount we still send it through so filters are fired.
$total_discount = $this->apply_coupon_fixed_product( $coupon, $items_to_apply, 0 );
} else {
$per_item_discount = absint( $amount / $item_count ); // round it down to the nearest cent.
if ( $per_item_discount > 0 ) {
$total_discount = $this->apply_coupon_fixed_product( $coupon, $items_to_apply, $per_item_discount );
if ( $per_item_discount > 0 ) {
$total_discount = $this->apply_coupon_fixed_product( $coupon, $items_to_apply, $per_item_discount );
/**
* If there is still discount remaining, repeat the process.
*/
if ( $total_discount > 0 && $total_discount < $amount ) {
$total_discount += $this->apply_coupon_fixed_cart( $coupon, $items_to_apply, $amount - $total_discount );
/**
* If there is still discount remaining, repeat the process.
*/
if ( $total_discount > 0 && $total_discount < $amount ) {
$total_discount += $this->apply_coupon_fixed_cart( $coupon, $items_to_apply, $amount - $total_discount );
}
} elseif ( $amount > 0 ) {
$total_discount += $this->apply_coupon_remainder( $coupon, $items_to_apply, $amount );
}
} elseif ( $amount > 0 ) {
$total_discount += $this->apply_coupon_remainder( $coupon, $items_to_apply, $amount );
}
return $total_discount;
}
@ -582,7 +528,7 @@ class WC_Discounts {
$user_id = get_current_user_id();
}
if ( $coupon->get_usage_limit_per_user() > 0 && is_user_logged_in() && $coupon->get_id() && $coupon->get_data_store() ) {
if ( $coupon && $user_id && $coupon->get_usage_limit_per_user() > 0 && $coupon->get_id() && $coupon->get_data_store() ) {
$date_store = $coupon->get_data_store();
$usage_count = $date_store->get_usage_by_user_id( $coupon, $user_id );
if ( $usage_count >= $coupon->get_usage_limit_per_user() ) {
@ -742,7 +688,7 @@ class WC_Discounts {
* @return bool
*/
protected function validate_coupon_excluded_items( $coupon ) {
if ( ! $this->items && $coupon->is_type( wc_get_product_coupon_types() ) ) {
if ( ! empty( $this->items ) && $coupon->is_type( wc_get_product_coupon_types() ) ) {
$valid = false;
foreach ( $this->items as $item ) {

View File

@ -84,6 +84,10 @@ class WC_Install {
'wc_update_310_old_comments',
'wc_update_310_db_version',
),
'3.1.2' => array(
'wc_update_312_shop_manager_capabilities',
'wc_update_312_db_version',
),
'3.2.0' => array(
'wc_update_320_mexican_states',
'wc_update_320_db_version',
@ -702,7 +706,6 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta (
'manage_categories' => true,
'manage_links' => true,
'moderate_comments' => true,
'unfiltered_html' => true,
'upload_files' => true,
'export' => true,
'import' => true,

View File

@ -54,8 +54,10 @@ class WC_Logger implements WC_Logger_Interface {
wc_doing_it_wrong(
__METHOD__,
sprintf(
__( 'The provided handler <code>%s</code> does not implement WC_Log_Handler_Interface.', 'woocommerce' ),
esc_html( is_object( $handler ) ? get_class( $handler ) : $handler )
/* translators: 1: class name 2: WC_Log_Handler_Interface */
__( 'The provided handler %1$s does not implement %2$s.', 'woocommerce' ),
'<code>' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '</code>',
'<code>WC_Log_Handler_Interface</code>'
),
'3.0'
);
@ -124,7 +126,8 @@ class WC_Logger implements WC_Logger_Interface {
*/
public function log( $level, $message, $context = array() ) {
if ( ! WC_Log_Levels::is_valid_level( $level ) ) {
wc_doing_it_wrong( __METHOD__, sprintf( __( 'WC_Logger::log was called with an invalid level "%s".', 'woocommerce' ), $level ), '3.0' );
/* translators: 1: WC_Logger::log 2: level */
wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'woocommerce' ), '<code>WC_Logger::log</code>', $level ), '3.0' );
}
if ( $this->should_handle( $level ) ) {

View File

@ -221,6 +221,16 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
return $this->get_prop( 'taxes', $context );
}
/**
* Get tax class.
*
* @param string $context
* @return string
*/
public function get_tax_class( $context = 'view' ) {
return get_option( 'woocommerce_shipping_tax_class' );
}
/*
|--------------------------------------------------------------------------
| Array Access Methods

View File

@ -68,6 +68,25 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
}
}
/**
* Merge changes with data and clear.
* Overrides WC_Data::apply_changes.
* array_replace_recursive does not work well for order items because it merges taxes instead
* of replacing them.
*
* @since 3.2.0
*/
public function apply_changes() {
if ( function_exists( 'array_replace' ) ) {
$this->data = array_replace( $this->data, $this->changes );
} else { // PHP 5.2 compatibility.
foreach ( $this->changes as $key => $change ) {
$this->data[ $key ] = $change;
}
}
$this->changes = array();
}
/*
|--------------------------------------------------------------------------
| Getters
@ -111,6 +130,24 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
return 1;
}
/**
* Get tax status.
* @return string
*/
public function get_tax_status() {
return 'taxable';
}
/**
* Get tax class.
*
* @param string $context
* @return string
*/
public function get_tax_class() {
return '';
}
/**
* Get parent order object.
* @return WC_Order

View File

@ -303,25 +303,27 @@ class WC_Order extends WC_Abstract_Order {
* Handle the status transition.
*/
protected function status_transition() {
if ( $this->status_transition ) {
do_action( 'woocommerce_order_status_' . $this->status_transition['to'], $this->get_id(), $this );
$status_transition = $this->status_transition;
if ( ! empty( $this->status_transition['from'] ) ) {
// Reset status transition variable
$this->status_transition = false;
if ( $status_transition ) {
do_action( 'woocommerce_order_status_' . $status_transition['to'], $this->get_id(), $this );
if ( ! empty( $status_transition['from'] ) ) {
/* translators: 1: old order status 2: new order status */
$transition_note = sprintf( __( 'Order status changed from %1$s to %2$s.', 'woocommerce' ), wc_get_order_status_name( $this->status_transition['from'] ), wc_get_order_status_name( $this->status_transition['to'] ) );
$transition_note = sprintf( __( 'Order status changed from %1$s to %2$s.', 'woocommerce' ), wc_get_order_status_name( $status_transition['from'] ), wc_get_order_status_name( $status_transition['to'] ) );
do_action( 'woocommerce_order_status_' . $this->status_transition['from'] . '_to_' . $this->status_transition['to'], $this->get_id(), $this );
do_action( 'woocommerce_order_status_changed', $this->get_id(), $this->status_transition['from'], $this->status_transition['to'], $this );
do_action( 'woocommerce_order_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
do_action( 'woocommerce_order_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
} else {
/* translators: %s: new order status */
$transition_note = sprintf( __( 'Order status set to %s.', 'woocommerce' ), wc_get_order_status_name( $this->status_transition['to'] ) );
$transition_note = sprintf( __( 'Order status set to %s.', 'woocommerce' ), wc_get_order_status_name( $status_transition['to'] ) );
}
// Note the transition occurred
$this->add_order_note( trim( $this->status_transition['note'] . ' ' . $transition_note ), 0, $this->status_transition['manual'] );
// This has ran, so reset status transition variable
$this->status_transition = false;
$this->add_order_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
}
}
@ -1836,7 +1838,6 @@ class WC_Order extends WC_Abstract_Order {
$total_rows = array();
$this->add_order_item_totals_subtotal_row( $total_rows, $tax_display );
$this->add_order_item_totals_discount_row( $total_rows, $tax_display );
$this->add_order_item_totals_shipping_row( $total_rows, $tax_display );
$this->add_order_item_totals_fee_rows( $total_rows, $tax_display );
$this->add_order_item_totals_tax_rows( $total_rows, $tax_display );

View File

@ -66,7 +66,7 @@ class WC_Post_Data {
* @return string
*/
public static function variation_post_link( $permalink, $post ) {
if ( isset( $post->ID, $post->post_type ) && 'product_variation' === $post->post_type && ( $variation = wc_get_product( $post->ID ) ) ) {
if ( isset( $post->ID, $post->post_type ) && 'product_variation' === $post->post_type && ( $variation = wc_get_product( $post->ID ) ) && $variation->get_parent_id() ) {
return $variation->get_permalink();
}
return $permalink;

View File

@ -72,6 +72,22 @@ class WC_Shipping {
wc_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woocommerce' ), '2.1' );
}
/**
* Magic getter.
*
* @param string $name Property name.
* @return mixed
*/
public function __get( $name ) {
// Grab from cart for backwards compatibility with versions prior to 3.2.
if ( 'shipping_total' === $name ){
return wc()->cart->get_shipping_total();
}
if ( 'shipping_taxes' === $name ){
return wc()->cart->get_shipping_taxes();
}
}
/**
* Initialize shipping.
*/
@ -131,7 +147,7 @@ class WC_Shipping {
$this->shipping_methods = $shipping_zone->get_shipping_methods( true );
// Debug output
if ( $debug_mode && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! wc_has_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' ) ) {
if ( $debug_mode && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! defined( 'WC_DOING_AJAX' ) && ! wc_has_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' ) ) {
wc_add_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' );
}
} else {

View File

@ -610,11 +610,11 @@ class WC_Webhook {
$topic_hooks = array(
'coupon.created' => array(
'woocommerce_process_shop_coupon_meta',
'woocommerce_api_create_coupon',
'woocommerce_new_coupon',
),
'coupon.updated' => array(
'woocommerce_process_shop_coupon_meta',
'woocommerce_api_edit_coupon',
'woocommerce_update_coupon',
),
'coupon.deleted' => array(
'wp_trash_post',
@ -625,26 +625,22 @@ class WC_Webhook {
'customer.created' => array(
'user_register',
'woocommerce_created_customer',
'woocommerce_api_create_customer',
'woocommerce_new_customer',
),
'customer.updated' => array(
'profile_update',
'woocommerce_api_edit_customer',
'woocommerce_customer_save_address',
'woocommerce_update_customer',
),
'customer.deleted' => array(
'delete_user',
),
'order.created' => array(
'woocommerce_checkout_order_processed',
'woocommerce_process_shop_order_meta',
'woocommerce_api_create_order',
'woocommerce_new_order',
),
'order.updated' => array(
'woocommerce_process_shop_order_meta',
'woocommerce_api_edit_order',
'woocommerce_order_edit_status',
'woocommerce_order_status_changed',
'woocommerce_update_order',
),
'order.deleted' => array(
'wp_trash_post',
@ -654,13 +650,13 @@ class WC_Webhook {
),
'product.created' => array(
'woocommerce_process_product_meta',
'woocommerce_api_create_product',
'woocommerce_new_product',
'woocommerce_new_product_variation',
),
'product.updated' => array(
'woocommerce_process_product_meta',
'woocommerce_api_edit_product',
'woocommerce_product_quick_edit_save',
'woocommerce_product_bulk_edit_save',
'woocommerce_update_product',
'woocommerce_update_product_variation',
),
'product.deleted' => array(
'wp_trash_post',

View File

@ -23,7 +23,7 @@ class WC_CLI_Tool_Command {
public static function register_commands() {
global $wp_rest_server;
$request = new WP_REST_Request( 'OPTIONS', '/wc/v1/system_status/tools' );
$request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status/tools' );
$response = $wp_rest_server->dispatch( $request );
$response_data = $response->get_data();
if ( empty( $response_data ) ) {
@ -42,7 +42,7 @@ class WC_CLI_Tool_Command {
'optional' => false,
);
$method = 'update_item';
$route = '/wc/v1/system_status/tools/(?P<id>[\w-]+)';
$route = '/wc/v2/system_status/tools/(?P<id>[\w-]+)';
} elseif ( 'list' === $command ) {
$synopsis[] = array(
'name' => 'fields',
@ -75,7 +75,7 @@ class WC_CLI_Tool_Command {
),
);
$method = 'list_items';
$route = '/wc/v1/system_status/tools';
$route = '/wc/v2/system_status/tools';
}
$before_invoke = null;

View File

@ -210,8 +210,8 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
/**
* Read order data. Can be overridden by child classes to load other props.
*
* @param WC_Order
* @param object $post_object
* @param WC_Order $order
* @param object $post_object
* @since 3.0.0
*/
protected function read_order_data( &$order, $post_object ) {
@ -278,7 +278,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
/**
* Clear any caches.
*
* @param WC_Order
* @param WC_Order $order
* @since 3.0.0
*/
protected function clear_caches( &$order ) {
@ -323,8 +323,8 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
/**
* Remove all line items (products, coupons, shipping, taxes) from the order.
*
* @param WC_Order
* @param string $type Order item type. Default null.
* @param WC_Order $order
* @param string $type Order item type. Default null.
*/
public function delete_items( $order, $type = null ) {
global $wpdb;
@ -341,7 +341,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
/**
* Get token ids for an order.
*
* @param WC_Order
* @param WC_Order $order
* @return array
*/
public function get_payment_token_ids( $order ) {
@ -352,8 +352,8 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
/**
* Update token ids for an order.
*
* @param WC_Order
* @param array $token_ids
* @param WC_Order $order
* @param array $token_ids
*/
public function update_payment_token_ids( $order, $token_ids ) {
update_post_meta( $order->get_id(), '_payment_tokens', $token_ids );

View File

@ -144,5 +144,6 @@ abstract class Abstract_WC_Order_Item_Type_Data_Store extends WC_Data_Store_WP i
public function clear_cache( &$item ) {
wp_cache_delete( 'item-' . $item->get_id(), 'order-items' );
wp_cache_delete( 'order-items-' . $item->get_order_id(), 'orders' );
wp_cache_delete( $item->get_id(), $this->meta_type . '_meta' );
}
}

View File

@ -82,8 +82,8 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
/**
* Read order data. Can be overridden by child classes to load other props.
*
* @param WC_Order
* @param object $post_object
* @param WC_Order $order
* @param object $post_object
* @since 3.0.0
*/
protected function read_order_data( &$order, $post_object ) {
@ -155,7 +155,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
/**
* Helper method that updates all the post meta for an order based on it's settings in the WC_Order class.
*
* @param WC_Order
* @param WC_Order $order
* @since 3.0.0
*/
protected function update_post_meta( &$order ) {
@ -270,7 +270,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
/**
* Get amount already refunded.
*
* @param WC_Order
* @param WC_Order $order
* @return string
*/
public function get_total_refunded( $order ) {
@ -290,7 +290,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
/**
* Get the total tax refunded.
*
* @param WC_Order
* @param WC_Order $order
* @return float
*/
public function get_total_tax_refunded( $order ) {
@ -311,7 +311,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
/**
* Get the total shipping refunded.
*
* @param WC_Order
* @param WC_Order $order
* @return float
*/
public function get_total_shipping_refunded( $order ) {
@ -704,4 +704,17 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
return $orders;
}
/**
* Return the order type of a given item which belongs to WC_Order.
*
* @since 3.2.0
* @param WC_Order $order Order Object.
* @param int $order_item_id Order item id.
* @return string Order Item type
*/
public function get_order_item_type( $order, $order_item_id ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT order_item_type FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d and order_item_id = %d;", $order->get_id(), $order_item_id ) );
}
}

View File

@ -255,6 +255,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
* @since 3.0.0
*/
protected function update_version_and_type( &$product ) {
wp_set_object_terms( $product->get_id(), '', 'product_type' );
update_post_meta( $product->get_id(), '_product_version', WC_VERSION );
}

View File

@ -620,7 +620,7 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
$wc_product_attributes = array();
foreach ( wc_get_attribute_taxonomies() as $taxonomy ) {
$wc_product_attributes[ wc_attribute_taxonomy_name( $taxonomy['attribute_name'] ) ] = $taxonomy;
$wc_product_attributes[ wc_attribute_taxonomy_name( $taxonomy->attribute_name ) ] = $taxonomy;
}
return $attribute_id;

View File

@ -125,17 +125,17 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
* If mapping to a SKU and the product ID does not exist, a temporary object
* will be created so it can be updated later.
*
* @param string $field Field value.
* @param string $value Field value.
* @return int|string
*/
public function parse_relative_field( $field ) {
public function parse_relative_field( $value ) {
global $wpdb;
if ( empty( $field ) ) {
if ( empty( $value ) ) {
return '';
}
if ( preg_match( '/^id:(\d+)$/', $field, $matches ) ) {
if ( preg_match( '/^id:(\d+)$/', $value, $matches ) ) {
$id = intval( $matches[1] );
$original_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_original_id' AND meta_value = %s;", $id ) );
@ -154,15 +154,15 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
return $id;
}
if ( $id = wc_get_product_id_by_sku( $field ) ) {
if ( $id = wc_get_product_id_by_sku( $value ) ) {
return $id;
}
try {
$product = new WC_Product_Simple();
$product->set_name( 'Import placeholder for ' . $field );
$product->set_name( 'Import placeholder for ' . $value );
$product->set_status( 'importing' );
$product->set_sku( $field );
$product->set_sku( $value );
$id = $product->save();
if ( $id && ! is_wp_error( $id ) ) {
@ -181,13 +181,13 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
* If we're not doing an update, create a placeholder product so mapping works
* for rows following this one.
*
* @param stirng $field
* @param string $value Field value.
* @return int
*/
public function parse_id_field( $field ) {
public function parse_id_field( $value ) {
global $wpdb;
$id = absint( $field );
$id = absint( $value );
if ( ! $id ) {
return 0;
@ -225,77 +225,91 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
/**
* Parse relative comma-delineated field and return product ID.
*
* @param string $field Field value.
* @param string $value Field value.
* @return array
*/
public function parse_relative_comma_field( $field ) {
if ( empty( $field ) ) {
public function parse_relative_comma_field( $value ) {
if ( empty( $value ) ) {
return array();
}
return array_filter( array_map( array( $this, 'parse_relative_field' ), $this->explode_values( $field ) ) );
return array_filter( array_map( array( $this, 'parse_relative_field' ), $this->explode_values( $value ) ) );
}
/**
* Parse a comma-delineated field from a CSV.
*
* @param string $field Field value.
* @param string $value Field value.
* @return array
*/
public function parse_comma_field( $field ) {
if ( empty( $field ) ) {
public function parse_comma_field( $value ) {
if ( empty( $value ) ) {
return array();
}
return array_map( 'wc_clean', $this->explode_values( $field ) );
return array_map( 'wc_clean', $this->explode_values( $value ) );
}
/**
* Parse a field that is generally '1' or '0' but can be something else.
*
* @param string $field Field value.
* @param string $value Field value.
* @return bool|string
*/
public function parse_bool_field( $field ) {
if ( '0' === $field ) {
public function parse_bool_field( $value ) {
if ( '0' === $value ) {
return false;
}
if ( '1' === $field ) {
if ( '1' === $value ) {
return true;
}
// Don't return explicit true or false for empty fields or values like 'notify'.
return wc_clean( $field );
return wc_clean( $value );
}
/**
* Parse a float value field.
*
* @param string $field Field value.
* @param string $value Field value.
* @return float|string
*/
public function parse_float_field( $field ) {
if ( '' === $field ) {
return $field;
public function parse_float_field( $value ) {
if ( '' === $value ) {
return $value;
}
return floatval( $field );
return floatval( $value );
}
/**
* Parse the stock qty field.
*
* @param string $value Field value.
* @return float|string
*/
public function parse_stock_quantity_field( $value ) {
if ( '' === $value ) {
return $value;
}
return wc_stock_amount( $value );
}
/**
* Parse a category field from a CSV.
* Categories are separated by commas and subcategories are "parent > subcategory".
*
* @param string $field Field value.
* @param string $value Field value.
* @return array of arrays with "parent" and "name" keys.
*/
public function parse_categories_field( $field ) {
if ( empty( $field ) ) {
public function parse_categories_field( $value ) {
if ( empty( $value ) ) {
return array();
}
$row_terms = $this->explode_values( $field );
$row_terms = $this->explode_values( $value );
$categories = array();
foreach ( $row_terms as $row_term ) {
@ -313,6 +327,11 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
$term_id = $term['term_id'];
} else {
$term = wp_insert_term( $_term, 'product_cat', array( 'parent' => intval( $parent ) ) );
if ( is_wp_error( $term ) ) {
break; // We cannot continue if the term cannot be inserted.
}
$term_id = $term['term_id'];
}
@ -332,15 +351,15 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
/**
* Parse a tag field from a CSV.
*
* @param string $field Field value.
* @param string $value Field value.
* @return array
*/
public function parse_tags_field( $field ) {
if ( empty( $field ) ) {
public function parse_tags_field( $value ) {
if ( empty( $value ) ) {
return array();
}
$names = $this->explode_values( $field );
$names = $this->explode_values( $value );
$tags = array();
foreach ( $names as $name ) {
@ -350,7 +369,9 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
$term = (object) wp_insert_term( $name, 'product_tag' );
}
$tags[] = $term->term_id;
if ( ! is_wp_error( $term ) ) {
$tags[] = $term->term_id;
}
}
return $tags;
@ -359,18 +380,22 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
/**
* Parse a shipping class field from a CSV.
*
* @param string $field Field value.
* @param string $value Field value.
* @return int
*/
public function parse_shipping_class_field( $field ) {
if ( empty( $field ) ) {
public function parse_shipping_class_field( $value ) {
if ( empty( $value ) ) {
return 0;
}
$term = get_term_by( 'name', $field, 'product_shipping_class' );
$term = get_term_by( 'name', $value, 'product_shipping_class' );
if ( ! $term || is_wp_error( $term ) ) {
$term = (object) wp_insert_term( $field, 'product_shipping_class' );
$term = (object) wp_insert_term( $value, 'product_shipping_class' );
}
if ( is_wp_error( $term ) ) {
return 0;
}
return $term->term_id;
@ -379,17 +404,17 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
/**
* Parse images list from a CSV. Images can be filenames or URLs.
*
* @param string $field Field value.
* @param string $value Field value.
* @return array
*/
public function parse_images_field( $field ) {
if ( empty( $field ) ) {
public function parse_images_field( $value ) {
if ( empty( $value ) ) {
return array();
}
$images = array();
foreach ( $this->explode_values( $field ) as $image ) {
foreach ( $this->explode_values( $value ) as $image ) {
if ( stristr( $image, '://' ) ) {
$images[] = esc_url_raw( $image );
} else {
@ -404,17 +429,17 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
* Parse dates from a CSV.
* Dates requires the format YYYY-MM-DD and time is optional.
*
* @param string $field Field value.
* @param string $value Field value.
* @return string|null
*/
public function parse_date_field( $field ) {
if ( empty( $field ) ) {
public function parse_date_field( $value ) {
if ( empty( $value ) ) {
return null;
}
if ( preg_match( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])([ 01-9:]*)$/', $field ) ) {
if ( preg_match( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])([ 01-9:]*)$/', $value ) ) {
// Don't include the time if the field had time in it.
return current( explode( ' ', $field ) );
return current( explode( ' ', $value ) );
}
return null;
@ -423,25 +448,38 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
/**
* Parse backorders from a CSV.
*
* @param string $field Field value.
* @param string $value Field value.
* @return string
*/
public function parse_backorders_field( $field ) {
if ( empty( $field ) ) {
public function parse_backorders_field( $value ) {
if ( empty( $value ) ) {
return '';
}
$field = $this->parse_bool_field( $field );
$value = $this->parse_bool_field( $value );
if ( 'notify' === $field ) {
if ( 'notify' === $value ) {
return 'notify';
} elseif ( is_bool( $field ) ) {
return $field ? 'yes' : 'no';
} elseif ( is_bool( $value ) ) {
return $value ? 'yes' : 'no';
}
return '';
}
/**
* Just skip current field.
*
* By default is applied wc_clean() to all not listed fields
* in self::get_formating_callback(), use this method to skip any formating.
*
* @param string $value Field value.
* @return string
*/
public function parse_skip_field( $value ) {
return $value;
}
/**
* Get formatting callback.
*
@ -460,9 +498,9 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
'featured' => array( $this, 'parse_bool_field' ),
'date_on_sale_from' => array( $this, 'parse_date_field' ),
'date_on_sale_to' => array( $this, 'parse_date_field' ),
'name' => 'wp_filter_post_kses',
'short_description' => 'wp_filter_post_kses',
'description' => 'wp_filter_post_kses',
'name' => array( $this, 'parse_skip_field' ),
'short_description' => array( $this, 'parse_skip_field' ),
'description' => array( $this, 'parse_skip_field' ),
'manage_stock' => array( $this, 'parse_bool_field' ),
'backorders' => array( $this, 'parse_backorders_field' ),
'stock_status' => array( $this, 'parse_bool_field' ),
@ -475,7 +513,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
'purchase_note' => 'wp_filter_post_kses',
'price' => 'wc_format_decimal',
'regular_price' => 'wc_format_decimal',
'stock_quantity' => 'wc_stock_amount',
'stock_quantity' => array( $this, 'parse_stock_quantity_field' ),
'category_ids' => array( $this, 'parse_categories_field' ),
'tag_ids' => array( $this, 'parse_tags_field' ),
'shipping_class_id' => array( $this, 'parse_shipping_class_field' ),
@ -571,7 +609,13 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
}
if ( isset( $data['stock_quantity'] ) ) {
$data['manage_stock'] = 0 < $data['stock_quantity'];
if ( '' === $data['stock_quantity'] ) {
$data['manage_stock'] = false;
$data['stock_status'] = isset( $data['stock_status'] ) ? $data['stock_status'] : true;
} else {
$data['manage_stock'] = true;
$data['stock_status'] = 0 < $data['stock_quantity'];
}
}
// Stock is bool.

View File

@ -20,6 +20,29 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
abstract class WC_Legacy_Cart {
/**
* Array of defaults. Not used since 3.2.
*
* @deprecated 3.2.0
*/
public $cart_session_data = array(
'cart_contents_total' => 0,
'total' => 0,
'subtotal' => 0,
'subtotal_ex_tax' => 0,
'tax_total' => 0,
'taxes' => array(),
'shipping_taxes' => array(),
'discount_cart' => 0,
'discount_cart_tax' => 0,
'shipping_total' => 0,
'shipping_tax_total' => 0,
'coupon_discount_amounts' => array(),
'coupon_discount_tax_amounts' => array(),
'fee_total' => 0,
'fees' => array(),
);
/**
* Contains an array of coupon usage counts after they have been applied.
*
@ -28,6 +51,179 @@ abstract class WC_Legacy_Cart {
*/
public $coupon_applied_count = array();
/**
* Magic getters.
*
* @param string $name Property name.
* @return mixed
*/
public function __get( $name ) {
switch ( $name ) {
case 'dp' :
return wc_get_price_decimals();
case 'prices_include_tax' :
return wc_prices_include_tax();
case 'round_at_subtotal' :
return 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' );
// map old public props to methods.
case 'cart_contents_total' :
return $this->get_cart_contents_total();
case 'total' :
return $this->get_total( 'edit' );
case 'subtotal' :
return $this->get_subtotal() + $this->get_subtotal_tax();
case 'subtotal_ex_tax' :
return $this->get_subtotal();
case 'tax_total' :
return $this->get_fee_tax() + $this->get_cart_contents_tax();
case 'taxes' :
return $this->get_taxes();
case 'shipping_taxes' :
return $this->get_shipping_taxes();
case 'fee_total' :
return $this->get_fee_total();
case 'discount_cart' :
return $this->get_discount_total();
case 'discount_cart_tax' :
return $this->get_discount_tax();
case 'shipping_total' :
return $this->get_shipping_total();
case 'shipping_tax_total' :
return $this->get_shipping_tax();
case 'coupon_discount_amounts' :
return $this->get_coupon_discount_totals();
case 'coupon_discount_tax_amounts' :
return $this->get_coupon_discount_tax_totals();
case 'display_totals_ex_tax' :
case 'display_cart_ex_tax' :
return 'excl' === $this->tax_display_cart;
case 'cart_contents_weight' :
return $this->get_cart_contents_weight();
case 'cart_contents_count' :
return $this->get_cart_contents_count();
case 'tax' :
wc_deprecated_argument( 'WC_Cart->tax', '2.3', 'Use WC_Tax:: directly' );
$this->tax = new WC_Tax();
return $this->tax;
case 'discount_total':
wc_deprecated_argument( 'WC_Cart->discount_total', '2.3', 'After tax coupons are no longer supported. For more information see: https://woocommerce.wordpress.com/2014/12/upcoming-coupon-changes-in-woocommerce-2-3/' );
return 0;
case 'coupons' :
return $this->get_coupons();
}
}
/**
* Map legacy variables to setters.
*
* @param string $name Property name.
* @param mixed $value Value to set.
*/
public function __set( $name, $value ) {
switch ( $name ) {
case 'cart_contents_total' :
$this->set_cart_contents_total( $value );
break;
case 'total' :
$this->set_total( $value );
break;
case 'subtotal' :
$this->set_subtotal( $value );
break;
case 'subtotal_ex_tax' :
$this->set_subtotal( $value );
break;
case 'tax_total' :
$this->set_cart_contents_tax( $value );
$this->set_fee_tax( 0 );
break;
case 'taxes' :
$this->set_cart_contents_taxes( $value );
break;
case 'shipping_taxes' :
$this->set_shipping_taxes( $value );
break;
case 'fee_total' :
$this->set_fee_total( $value );
break;
case 'discount_cart' :
$this->set_discount_total( $value );
break;
case 'discount_cart_tax' :
$this->set_discount_tax( $value );
break;
case 'shipping_total' :
$this->set_shipping_total( $value );
break;
case 'shipping_tax_total' :
$this->set_shipping_tax( $value );
break;
case 'coupon_discount_amounts' :
$this->set_coupon_discount_totals( $value );
break;
case 'coupon_discount_tax_amounts' :
$this->set_coupon_discount_tax_totals( $value );
break;
default :
$this->$name = $value;
break;
}
}
/**
* Methods moved to session class in 3.2.0.
*/
public function get_cart_from_session() { $this->session->get_cart_from_session(); }
public function maybe_set_cart_cookies() { $this->session->maybe_set_cart_cookies(); }
public function set_session() { $this->session->set_session(); }
public function get_cart_for_session() { $this->session->get_cart_for_session(); }
public function persistent_cart_update() { $this->session->persistent_cart_update(); }
public function persistent_cart_destroy() { $this->session->persistent_cart_destroy(); }
/**
* Get the total of all cart discounts.
*
* @return float
*/
public function get_cart_discount_total() {
return $this->get_discount_total();
}
/**
* Get the total of all cart tax discounts (used for discounts on tax inclusive prices).
*
* @return float
*/
public function get_cart_discount_tax_total() {
return $this->get_discount_tax();
}
/**
* Renamed for consistency.
*
* @param string $coupon_code
* @return bool True if the coupon is applied, false if it does not exist or cannot be applied.
*/
public function add_discount( $coupon_code ) {
return $this->apply_coupon( $coupon_code );
}
/**
* Remove taxes.
*
* @deprecated 3.2.0 Taxes are never calculated if customer is tax except making this function unused.
*/
public function remove_taxes() {
wc_deprecated_function( 'WC_Cart::remove_taxes', '3.2', '' );
}
/**
* Init.
*
* @deprecated 3.2.0 Session is loaded via hooks rather than directly.
*/
public function init() {
wc_deprecated_function( 'WC_Cart::init', '3.2', '' );
$this->get_cart_from_session();
}
/**
* Function to apply discounts to a product and get the discounted price (before tax is applied).
*

View File

@ -163,9 +163,9 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
$total = WC()->cart->get_displayed_subtotal();
if ( 'incl' === WC()->cart->tax_display_cart ) {
$total = round( $total - ( WC()->cart->get_cart_discount_total() + WC()->cart->get_cart_discount_tax_total() ), wc_get_price_decimals() );
$total = round( $total - ( WC()->cart->get_discount_total() + WC()->cart->get_discount_tax() ), wc_get_price_decimals() );
} else {
$total = round( $total - WC()->cart->get_cart_discount_total(), wc_get_price_decimals() );
$total = round( $total - WC()->cart->get_discount_total(), wc_get_price_decimals() );
}
if ( $total >= $this->min_amount ) {
@ -191,7 +191,7 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
break;
}
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package );
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package, $this );
}
/**

View File

@ -174,7 +174,7 @@ class WC_Shipping_Legacy_Free_Shipping extends WC_Shipping_Method {
}
if ( in_array( $this->requires, array( 'min_amount', 'either', 'both' ) ) && isset( WC()->cart->cart_contents_total ) ) {
if ( WC()->cart->prices_include_tax ) {
if ( wc_prices_include_tax() ) {
$total = WC()->cart->cart_contents_total + array_sum( WC()->cart->taxes );
} else {
$total = WC()->cart->cart_contents_total;
@ -211,7 +211,7 @@ class WC_Shipping_Legacy_Free_Shipping extends WC_Shipping_Method {
break;
}
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package );
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package, $this );
}
/**

View File

@ -73,6 +73,6 @@ class WC_Shipping_Legacy_International_Delivery extends WC_Shipping_Legacy_Flat_
return false;
}
}
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true, $package );
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true, $package, $this );
}
}

View File

@ -206,7 +206,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
}
}
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package );
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package, $this );
}
/**

View File

@ -157,35 +157,8 @@ class WC_Shortcode_Checkout {
if ( $order->needs_payment() ) {
?>
<ul class="order_details">
<li class="order">
<?php _e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
</li>
<li class="total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->get_payment_method_title() ) : ?>
<li class="method">
<?php _e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php
echo wp_kses_post( $order->get_payment_method_title() );
?></strong>
</li>
<?php endif; ?>
</ul>
<?php do_action( 'woocommerce_receipt_' . $order->get_payment_method(), $order_id ); ?>
<div class="clear"></div>
<?php
wc_get_template( 'checkout/order-receipt.php', array( 'order' => $order ) );
} else {
wc_add_notice( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
}

View File

@ -27,7 +27,7 @@ abstract class WP_REST_Controller {
* Register the routes for the objects of the controller.
*/
public function register_routes() {
wc_doing_it_wrong( 'WP_REST_Controller::register_routes', __( 'The register_routes() method must be overridden', 'woocommerce' ), 'WPAPI-2.0' );
wc_doing_it_wrong( 'WP_REST_Controller::register_routes', sprintf( __( "Method '%s' must be overridden.", 'woocommerce' ), 'register_routes()' ), 'WPAPI-2.0' );
}
/**

View File

@ -344,12 +344,12 @@ function wc_cart_totals_shipping_method_label( $method ) {
if ( $method->cost > 0 ) {
if ( WC()->cart->tax_display_cart == 'excl' ) {
$label .= ': ' . wc_price( $method->cost );
if ( $method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax ) {
if ( $method->get_shipping_tax() > 0 && wc_prices_include_tax() ) {
$label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
} else {
$label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) {
if ( $method->get_shipping_tax() > 0 && ! wc_prices_include_tax() ) {
$label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
}
}
@ -369,7 +369,19 @@ function wc_cart_round_discount( $value, $precision ) {
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
return round( $value, $precision, WC_DISCOUNT_ROUNDING_MODE );
} else {
return round( $value, $precision );
// Fake it in PHP 5.2.
if ( 2 === WC_DISCOUNT_ROUNDING_MODE && strstr( $value, '.' ) ) {
$value = (string) $value;
$value = explode( '.', $value );
$value[1] = substr( $value[1], 0, $precision + 1 );
$value = implode( '.', $value );
if ( substr( $value, -1 ) === '5' ) {
$value = substr( $value, 0, -1 ) . '4';
}
$value = floatval( $value );
}
return round( $value, $precision );
}
}

View File

@ -37,7 +37,7 @@ include( WC_ABSPATH . 'includes/wc-webhook-functions.php' );
*/
add_filter( 'woocommerce_coupon_code', 'html_entity_decode' );
add_filter( 'woocommerce_coupon_code', 'sanitize_text_field' );
add_filter( 'woocommerce_coupon_code', 'strtolower' ); // Coupons case-insensitive by default
add_filter( 'woocommerce_coupon_code', 'wc_strtolower' );
add_filter( 'woocommerce_stock_amount', 'intval' ); // Stock amounts are integers by default
add_filter( 'woocommerce_shipping_rate_label', 'sanitize_text_field' ); // Shipping rate label
@ -1530,8 +1530,11 @@ function wc_get_logger() {
wc_doing_it_wrong(
__FUNCTION__,
sprintf(
__( 'The class <code>%s</code> provided by woocommerce_logging_class filter must implement <code>WC_Logger_Interface</code>.', 'woocommerce' ),
esc_html( is_object( $class ) ? get_class( $class ) : $class )
/* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */
__( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ),
'<code>' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '</code>',
'<code>woocommerce_logging_class</code>',
'<code>WC_Logger_Interface</code>'
),
'3.0'
);
@ -1650,7 +1653,10 @@ function wc_list_pluck( $list, $callback_or_field, $index_key = null ) {
*/
$newlist = array();
foreach ( $list as $value ) {
if ( isset( $value->$index_key ) ) {
// Get index. @since 3.2.0 this supports a callback.
if ( is_callable( array( $value, $index_key ) ) ) {
$newlist[ $value->{$index_key}() ] = $value->{$callback_or_field}();
} elseif ( isset( $value->$index_key ) ) {
$newlist[ $value->$index_key ] = $value->{$callback_or_field}();
} else {
$newlist[] = $value->{$callback_or_field}();

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