Fixed conflicts
This commit is contained in:
commit
80ee7016f8
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"rules": {
|
||||
"indentation": "tab",
|
||||
"color-hex-case": "lower",
|
||||
"color-no-invalid-hex": true,
|
||||
|
||||
|
@ -19,7 +20,7 @@
|
|||
|
||||
"unit-case": "lower",
|
||||
"unit-no-unknown": true,
|
||||
"unit-whitelist": ["px", "%", "deg", "ms", "em", "vh", "vw", "rem"],
|
||||
"unit-whitelist": ["px", "%", "deg", "ms", "em", "vh", "vw", "rem", "s", "ex", "pt", "cm"],
|
||||
|
||||
"value-list-comma-space-after": "always-single-line",
|
||||
"value-list-comma-space-before": "never",
|
||||
|
@ -28,8 +29,8 @@
|
|||
|
||||
"property-case": "lower",
|
||||
|
||||
"declaration-block-no-duplicate-properties": true,
|
||||
"declaration-block-no-ignored-properties": true,
|
||||
"declaration-block-no-duplicate-properties": [true, { "severity": "warning" } ],
|
||||
"declaration-block-no-ignored-properties": [true, { "severity": "warning" } ],
|
||||
"declaration-block-trailing-semicolon": "always",
|
||||
"declaration-block-single-line-max-declarations": 0,
|
||||
"declaration-block-semicolon-space-before": "never",
|
||||
|
@ -54,6 +55,6 @@
|
|||
"selector-pseudo-element-colon-notation": "double",
|
||||
"selector-pseudo-element-no-unknown": true,
|
||||
"selector-type-case": "lower",
|
||||
"selector-no-id": true
|
||||
"selector-no-id": [true, { "severity": "warning" } ],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ module.exports = function( grunt ) {
|
|||
stylelintrc: '.stylelintrc'
|
||||
},
|
||||
all: [
|
||||
'<%= dirs.css %>/*.scss'
|
||||
'<%= dirs.css %>/*.scss',
|
||||
'!<%= dirs.css %>/select2.scss'
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -254,6 +255,7 @@ module.exports = function( grunt ) {
|
|||
]);
|
||||
|
||||
grunt.registerTask( 'css', [
|
||||
'stylelint',
|
||||
'sass',
|
||||
'cssmin'
|
||||
]);
|
||||
|
|
|
@ -10,7 +10,7 @@ extensions: [php]
|
|||
# directories and files matching this file mask will not be parsed
|
||||
exclude:
|
||||
- includes/libraries/
|
||||
- includes/api/
|
||||
- includes/api/legacy/
|
||||
- i18n/
|
||||
- node_modules/
|
||||
- wc-apidocs/
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
*/
|
||||
@include keyframes( spin ) {
|
||||
100% {
|
||||
@include transform( rotate(360deg) );
|
||||
@include transform( rotate( 360deg ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
@mixin clearfix() {
|
||||
*zoom: 1;
|
||||
|
||||
&:before,
|
||||
&:after {
|
||||
content: " ";
|
||||
&::before,
|
||||
&::after {
|
||||
content: ' ';
|
||||
display: table;
|
||||
}
|
||||
|
||||
&:after {
|
||||
&::after {
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@
|
|||
* Deprecated
|
||||
* Vendor prefix no longer required.
|
||||
*/
|
||||
@mixin transition($selector: all, $animation: ease-in-out, $duration: .2s) {
|
||||
@mixin transition($selector: all, $animation: ease-in-out, $duration: 0.2s) {
|
||||
transition: $selector $animation $duration;
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,11 @@
|
|||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@mixin darkorlighttextshadow($a, $opacity: .8) {
|
||||
@mixin darkorlighttextshadow($a, $opacity: 0.8) {
|
||||
@if lightness($a) >= 65% {
|
||||
@include text_shadow(0, -1px, 0, rgba(0, 0, 0, $opacity));
|
||||
} @else {
|
||||
}
|
||||
@else {
|
||||
@include text_shadow(0, 1px, 0, rgba(255, 255, 255, $opacity));
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +172,7 @@
|
|||
width: 1em;
|
||||
}
|
||||
|
||||
@mixin icon( $glyph: "\e001" ) {
|
||||
@mixin icon( $glyph: '\e001' ) {
|
||||
font-family: 'WooCommerce';
|
||||
speak: none;
|
||||
font-weight: normal;
|
||||
|
@ -190,7 +191,7 @@
|
|||
content: $glyph;
|
||||
}
|
||||
|
||||
@mixin icon_dashicons( $glyph: "\f333" ) {
|
||||
@mixin icon_dashicons( $glyph: '\f333' ) {
|
||||
font-family: 'Dashicons';
|
||||
speak: none;
|
||||
font-weight: normal;
|
||||
|
@ -209,7 +210,7 @@
|
|||
content: $glyph;
|
||||
}
|
||||
|
||||
@mixin iconbefore( $glyph: "\e001" ) {
|
||||
@mixin iconbefore( $glyph: '\e001' ) {
|
||||
font-family: 'WooCommerce';
|
||||
speak: none;
|
||||
font-weight: normal;
|
||||
|
@ -217,12 +218,12 @@
|
|||
text-transform: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin-right: .618em;
|
||||
margin-right: 0.618em;
|
||||
content: $glyph;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@mixin iconbeforedashicons( $glyph: "\f333" ) {
|
||||
@mixin iconbeforedashicons( $glyph: '\f333' ) {
|
||||
font-family: 'Dashicons';
|
||||
speak: none;
|
||||
font-weight: normal;
|
||||
|
@ -230,12 +231,12 @@
|
|||
text-transform: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin-right: .618em;
|
||||
margin-right: 0.618em;
|
||||
content: $glyph;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@mixin iconafter( $glyph: "\e001" ) {
|
||||
@mixin iconafter( $glyph: '\e001' ) {
|
||||
font-family: 'WooCommerce';
|
||||
speak: none;
|
||||
font-weight: normal;
|
||||
|
@ -243,29 +244,28 @@
|
|||
text-transform: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin-left: .618em;
|
||||
margin-left: 0.618em;
|
||||
content: $glyph;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@mixin loader() {
|
||||
&:before {
|
||||
&::before {
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-left: -.5em;
|
||||
margin-top: -.5em;
|
||||
display: block;
|
||||
content: "";
|
||||
margin-left: -0.5em;
|
||||
margin-top: -0.5em;
|
||||
content: '';
|
||||
@include animation( spin 1s ease-in-out infinite );
|
||||
background: url(../images/icons/loader.svg) center center;
|
||||
background: url('../images/icons/loader.svg') center center;
|
||||
background-size: cover;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
font-size: 2em;
|
||||
color: rgba(#000,0.75);
|
||||
color: rgba(#000, 0.75);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#bb77ae;border-color:#A36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597;color:#fff;text-shadow:0 -1px 1px #A36597,1px 0 1px #A36597,0 1px 1px #A36597,-1px 0 1px #A36597}.woocommerce-message a.button-primary:active,.woocommerce-message a.button-primary:focus,.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:active,p.woocommerce-actions a.button-primary:focus,p.woocommerce-actions a.button-primary:hover{background:#A36597;border-color:#A36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close:before,p.woocommerce-actions a.woocommerce-message-close:before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,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 a.button-primary,p.woocommerce-actions a.button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,1px 0 1px #a36597,0 1px 1px #a36597,-1px 0 1px #a36597}.woocommerce-message a.button-primary:active,.woocommerce-message a.button-primary:focus,.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:active,p.woocommerce-actions a.button-primary:focus,p.woocommerce-actions a.button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,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}
|
|
@ -6,7 +6,7 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import 'bourbon';
|
||||
|
||||
/**
|
||||
* Styling begins
|
||||
|
@ -24,17 +24,17 @@ p.woocommerce-actions,
|
|||
.woocommerce-message {
|
||||
a.button-primary {
|
||||
background: #bb77ae;
|
||||
border-color: #A36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
color: #fff;
|
||||
text-shadow: 0px -1px 1px #A36597, 1px 0px 1px #A36597, 0px 1px 1px #A36597, -1px 0px 1px #A36597;
|
||||
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
|
||||
|
||||
&:hover, &:focus, &:active {
|
||||
background: #A36597;
|
||||
border-color: #A36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
background: #a36597;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ p.woocommerce-actions,
|
|||
font-size: 13px;
|
||||
line-height: 1.23076923;
|
||||
text-decoration: none;
|
||||
&:before {
|
||||
&::before {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 0;
|
||||
-webkit-transition: all .1s ease-in-out;
|
||||
transition: all .1s ease-in-out;
|
||||
top: 8px;
|
||||
left: 0;
|
||||
-webkit-transition: all 0.1s ease-in-out;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,12 +87,12 @@ div.woocommerce-no-shipping-methods-notice {
|
|||
font-size: 1.1em;
|
||||
}
|
||||
}
|
||||
&:before {
|
||||
content: "\e01b";
|
||||
font-family: "WooCommerce";
|
||||
&::before {
|
||||
content: '\e01b';
|
||||
font-family: 'WooCommerce';
|
||||
text-align: center;
|
||||
line-height: 1;
|
||||
color: #F7F1F6;
|
||||
color: #f7f1f6;
|
||||
display: block;
|
||||
width: 1em;
|
||||
font-size: 20em;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
|||
body{background:#f1f1f1;box-shadow:none;margin:100px auto 24px;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-auth-content{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13);overflow:hidden;padding:24px 24px 0;zoom:1}.wc-auth-content h1,.wc-auth-content h2,.wc-auth-content h3,.wc-auth-content table{border:0;clear:none;color:#666;margin:0 0 24px;padding:0}.wc-auth-content p,.wc-auth-content ul{color:#666;font-size:1em;line-height:1.75em;margin:0 0 24px}.wc-auth-content p{padding:0}.wc-auth-content a{color:#A16696}.wc-auth-content a:focus,.wc-auth-content a:hover{color:#111}.wc-auth-content .wc-auth-login label{color:#999;display:block;margin-bottom:.5em}.wc-auth-content .wc-auth-login input{box-sizing:border-box;font-size:1.3em;padding:.5em;width:100%}.wc-auth-content .wc-auth-login .wc-auth-actions{padding:0}.wc-auth-content .wc-auth-login .wc-auth-actions .wc-auth-login-button{float:none;width:100%}.wc-auth-permissions{list-style:disc inside;padding:0}.wc-auth-permissions li{font-size:1em}.wc-auth-logged-in-as{background:#f5f5f5;border-bottom:2px solid #eee;line-height:70px;margin:0 0 24px;padding:0 1em 0 0}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:left;height:70px;margin:0 1em 0 0}.wc-auth-logged-in-as .wc-auth-logout{float:right}.wc-auth .wc-auth-actions{overflow:hidden;padding-left:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border:1px solid #d7d7d7;box-sizing:border-box;color:#777;float:right;font-size:1.25em;height:auto;line-height:1em;padding:1em 2em;text-align:center;width:50%}.wc-auth .wc-auth-actions .button:focus,.wc-auth .wc-auth-actions .button:hover{background:#fcfcfc}.wc-auth .wc-auth-actions .button-primary{background:#ad6ea1;border-color:#a16696;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);color:#fff;float:right;opacity:1;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-auth .wc-auth-actions .button-primary:focus,.wc-auth .wc-auth-actions .button-primary:hover{background:#B472A8;color:#fff}.wc-auth .wc-auth-actions .wc-auth-approve{float:right}.wc-auth .wc-auth-actions .wc-auth-deny{float:left;margin-left:-24px}
|
||||
body{background:#f1f1f1;box-shadow:none;margin:100px auto 24px;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-auth-content{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13);overflow:hidden;padding:24px 24px 0;zoom:1}.wc-auth-content h1,.wc-auth-content h2,.wc-auth-content h3,.wc-auth-content table{border:0;clear:none;color:#666;margin:0 0 24px;padding:0}.wc-auth-content p,.wc-auth-content ul{color:#666;font-size:1em;line-height:1.75em;margin:0 0 24px}.wc-auth-content p{padding:0}.wc-auth-content a{color:#a16696}.wc-auth-content a:focus,.wc-auth-content a:hover{color:#111}.wc-auth-content .wc-auth-login label{color:#999;display:block;margin-bottom:.5em}.wc-auth-content .wc-auth-login input{box-sizing:border-box;font-size:1.3em;padding:.5em;width:100%}.wc-auth-content .wc-auth-login .wc-auth-actions{padding:0}.wc-auth-content .wc-auth-login .wc-auth-actions .wc-auth-login-button{float:none;width:100%}.wc-auth-permissions{list-style:disc inside;padding:0}.wc-auth-permissions li{font-size:1em}.wc-auth-logged-in-as{background:#f5f5f5;border-bottom:2px solid #eee;line-height:70px;margin:0 0 24px;padding:0 1em 0 0}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:left;height:70px;margin:0 1em 0 0}.wc-auth-logged-in-as .wc-auth-logout{float:right}.wc-auth .wc-auth-actions{overflow:hidden;padding-left:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border:1px solid #d7d7d7;box-sizing:border-box;color:#777;float:right;font-size:1.25em;height:auto;line-height:1em;padding:1em 2em;text-align:center;width:50%}.wc-auth .wc-auth-actions .button:focus,.wc-auth .wc-auth-actions .button:hover{background:#fcfcfc}.wc-auth .wc-auth-actions .button-primary{background:#ad6ea1;border-color:#a16696;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);color:#fff;float:right;opacity:1;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-auth .wc-auth-actions .button-primary:focus,.wc-auth .wc-auth-actions .button-primary:hover{background:#b472a8;color:#fff}.wc-auth .wc-auth-actions .wc-auth-approve{float:right}.wc-auth .wc-auth-actions .wc-auth-deny{float:left;margin-left:-24px}
|
|
@ -18,7 +18,7 @@ body {
|
|||
|
||||
.wc-auth-content {
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
|
||||
overflow: hidden;
|
||||
padding: 24px 24px 0;
|
||||
zoom: 1;
|
||||
|
@ -43,7 +43,7 @@ body {
|
|||
}
|
||||
|
||||
a {
|
||||
color: #A16696;
|
||||
color: #a16696;
|
||||
&:hover, &:focus {
|
||||
color: #111;
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ body {
|
|||
label {
|
||||
color: #999;
|
||||
display: block;
|
||||
margin-bottom: .5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
input {
|
||||
box-sizing: border-box;
|
||||
font-size: 1.3em;
|
||||
padding: .5em;
|
||||
padding: 0.5em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
@ -133,10 +133,10 @@ body {
|
|||
color: #fff;
|
||||
float: right;
|
||||
opacity: 1;
|
||||
text-shadow: 0px -1px 1px #8a4f7f, 1px 0px 1px #8a4f7f, 0px 1px 1px #8a4f7f, -1px 0px 1px #8a4f7f;
|
||||
text-shadow: 0 -1px 1px #8a4f7f, 1px 0 1px #8a4f7f, 0 1px 1px #8a4f7f, -1px 0 1px #8a4f7f;
|
||||
|
||||
&:hover, &:focus {
|
||||
background: #B472A8;
|
||||
background: #b472a8;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;float:left;font-size:.8em;border-left:1px solid #fff;border-right:1px solid #ececec;text-align:center;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-left:0}ul.woocommerce_stats li:last-child{border-right:0}#woocommerce_dashboard_status .wc_status_list li.low-in-stock,#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}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;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;-webkit-font-smoothing:antialiased;margin:0 12px 12px 0;text-indent:0;top:0;left:0;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month,#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#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 a:before{content:"\e006"}#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 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;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:#b3b3b3;float:left;top:0;left:0;position:absolute;letter-spacing:.1em;letter-spacing:0\9}#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;letter-spacing:0\9;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}#woocommerce_dashboard_status .wc_status_list li.low-in-stock,#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}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;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;-webkit-font-smoothing:antialiased;margin:0 12px 12px 0;text-indent:0;top:0;left:0;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month,#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#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 a::before{content:'\e006'}#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 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;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:#b3b3b3;float:left;top:0;left:0;position:absolute;letter-spacing:.1em;letter-spacing:0\9}#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;letter-spacing:0\9;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}
|
|
@ -6,10 +6,10 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import "mixins";
|
||||
@import "variables";
|
||||
@import "fonts";
|
||||
@import 'bourbon';
|
||||
@import 'mixins';
|
||||
@import 'variables';
|
||||
@import 'fonts';
|
||||
|
||||
/**
|
||||
* Styling begins
|
||||
|
@ -26,7 +26,6 @@ ul.woocommerce_stats {
|
|||
font-size: 0.8em;
|
||||
border-left: 1px solid #fff;
|
||||
border-right: 1px solid #ececec;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
@ -39,7 +38,7 @@ ul.woocommerce_stats {
|
|||
}
|
||||
|
||||
strong {
|
||||
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
|
||||
font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;
|
||||
font-size: 4em;
|
||||
line-height: 1.2em;
|
||||
font-weight: normal;
|
||||
|
@ -71,7 +70,7 @@ ul.woocommerce_stats {
|
|||
display: block;
|
||||
color: #aaa;
|
||||
padding: 9px 12px;
|
||||
-webkit-transition: all ease .5s;
|
||||
-webkit-transition: all ease 0.5s;
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
|
||||
|
@ -84,7 +83,7 @@ ul.woocommerce_stats {
|
|||
right: 0;
|
||||
top: 50%;
|
||||
margin-right: 12px;
|
||||
margin-top: -1.25em
|
||||
margin-top: -1.25em;
|
||||
}
|
||||
|
||||
strong {
|
||||
|
@ -98,13 +97,13 @@ ul.woocommerce_stats {
|
|||
&:hover {
|
||||
color: #2ea2cc;
|
||||
|
||||
&:before,
|
||||
&::before,
|
||||
strong {
|
||||
color: #2ea2cc !important;
|
||||
}
|
||||
}
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
@include icon();
|
||||
font-size: 2em;
|
||||
position: relative;
|
||||
|
@ -125,32 +124,32 @@ ul.woocommerce_stats {
|
|||
li.sales-this-month {
|
||||
width: 100%;
|
||||
|
||||
a:before {
|
||||
font-family: "Dashicons";
|
||||
content: "\f185";
|
||||
a::before {
|
||||
font-family: 'Dashicons';
|
||||
content: '\f185';
|
||||
}
|
||||
}
|
||||
|
||||
li.best-seller-this-month {
|
||||
width: 100%;
|
||||
|
||||
a:before {
|
||||
content: "\e006";
|
||||
a::before {
|
||||
content: '\e006';
|
||||
}
|
||||
}
|
||||
|
||||
li.processing-orders {
|
||||
border-right: 1px solid #ececec;
|
||||
|
||||
a:before {
|
||||
content: "\e011";
|
||||
a::before {
|
||||
content: '\e011';
|
||||
color: $green;
|
||||
}
|
||||
}
|
||||
|
||||
li.on-hold-orders {
|
||||
a:before {
|
||||
content: "\e033";
|
||||
a::before {
|
||||
content: '\e033';
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
@ -158,15 +157,15 @@ ul.woocommerce_stats {
|
|||
li.low-in-stock {
|
||||
border-right: 1px solid #ececec;
|
||||
|
||||
a:before {
|
||||
content: "\e016";
|
||||
a::before {
|
||||
content: '\e016';
|
||||
color: $orange;
|
||||
}
|
||||
}
|
||||
|
||||
li.out-of-stock {
|
||||
a:before {
|
||||
content: "\e013";
|
||||
a::before {
|
||||
content: '\e013';
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +180,7 @@ ul.woocommerce_stats {
|
|||
|
||||
h4.meta {
|
||||
line-height: 1.4;
|
||||
margin: -.2em 0 0 0;
|
||||
margin: -0.2em 0 0 0;
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
}
|
||||
|
@ -202,12 +201,12 @@ ul.woocommerce_stats {
|
|||
position: relative;
|
||||
height: 1.5em;
|
||||
line-height: 1.5;
|
||||
margin-left: .5em;
|
||||
margin-left: 0.5em;
|
||||
width: 5.4em;
|
||||
font-family: 'WooCommerce' !important;
|
||||
|
||||
&:before {
|
||||
content: "\e021\e021\e021\e021\e021";
|
||||
&::before {
|
||||
content: '\e021\e021\e021\e021\e021';
|
||||
color: darken( #ccc, 10% );
|
||||
float: left;
|
||||
top: 0;
|
||||
|
@ -226,8 +225,8 @@ ul.woocommerce_stats {
|
|||
padding-top: 1.5em;
|
||||
}
|
||||
|
||||
span:before {
|
||||
content: "\e020\e020\e020\e020\e020";
|
||||
span::before {
|
||||
content: '\e020\e020\e020\e020\e020';
|
||||
top: 0;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
@ -238,7 +237,7 @@ ul.woocommerce_stats {
|
|||
}
|
||||
}
|
||||
|
||||
#dash-right-now li.product-count a:before {
|
||||
#dash-right-now li.product-count a::before {
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e01d";
|
||||
content: '\e01d';
|
||||
}
|
||||
|
|
|
@ -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}#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image:before{font-family:WooCommerce!important;content:"\e03d"}#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image:before,#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image:before{font-family:WooCommerce!important;content:"\e006"}#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image:before{font-family:WooCommerce!important;content:"\e023";font-size:1.3em!important}span.mce_woocommerce_shortcodes_button{background-image:none!important;display:block;text-indent:-9999px;position:relative;height:1em;width:1em}span.mce_woocommerce_shortcodes_button:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-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:.9em;line-height:1.2}.wc_plugin_upgrade_notice{font-weight:400;color:#fff;background:#d54d21;padding:1em;margin:9px 0}.wc_plugin_upgrade_notice a{color:#fff;text-decoration:underline}.wc_plugin_upgrade_notice:before{content:"\f348";display:inline-block;font:400 18px/1 dashicons;speak:none;margin:0 8px 0 -2px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}
|
||||
@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}#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image::before{font-family:WooCommerce!important;content:'\e03d'}#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image::before,#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image::before{font-family:WooCommerce!important;content:'\e006'}#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image::before{font-family:WooCommerce!important;content:'\e023';font-size:1.3em!important}span.mce_woocommerce_shortcodes_button{background-image:none!important;display:block;text-indent:-9999px;position:relative;height:1em;width:1em}span.mce_woocommerce_shortcodes_button::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-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:.9em;line-height:1.2}.wc_plugin_upgrade_notice{font-weight:400;color:#fff;background:#d54d21;padding:1em;margin:9px 0}.wc_plugin_upgrade_notice a{color:#fff;text-decoration:underline}.wc_plugin_upgrade_notice::before{content:'\f348';display:inline-block;font:400 18px/1 dashicons;speak:none;margin:0 8px 0 -2px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}
|
|
@ -7,28 +7,28 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import "mixins";
|
||||
@import "variables";
|
||||
@import "fonts";
|
||||
@import 'bourbon';
|
||||
@import 'mixins';
|
||||
@import 'variables';
|
||||
@import 'fonts';
|
||||
|
||||
/**
|
||||
* Styling begins
|
||||
*/
|
||||
#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image:before {
|
||||
#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image::before {
|
||||
font-family: 'WooCommerce' !important;
|
||||
content: "\e03d";
|
||||
content: '\e03d';
|
||||
}
|
||||
|
||||
#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image:before,
|
||||
#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image:before {
|
||||
#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image::before,
|
||||
#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image::before {
|
||||
font-family: 'WooCommerce' !important;
|
||||
content: "\e006";
|
||||
content: '\e006';
|
||||
}
|
||||
|
||||
#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image:before {
|
||||
#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image::before {
|
||||
font-family: 'WooCommerce' !important;
|
||||
content: "\e023";
|
||||
content: '\e023';
|
||||
font-size: 1.3em !important;
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ span.mce_woocommerce_shortcodes_button {
|
|||
background-image: none !important;
|
||||
@include ir();
|
||||
|
||||
&:before {
|
||||
@include icon( "\e01d" );
|
||||
font-size: .9em;
|
||||
&::before {
|
||||
@include icon( '\e01d' );
|
||||
font-size: 0.9em;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ span.mce_woocommerce_shortcodes_button {
|
|||
text-decoration: underline;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: "\f348";
|
||||
&::before {
|
||||
content: '\f348';
|
||||
display: inline-block;
|
||||
font: 400 18px/1 dashicons;
|
||||
speak: none;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,10 +7,10 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import "mixins";
|
||||
@import "variables";
|
||||
@import "fonts";
|
||||
@import 'bourbon';
|
||||
@import 'mixins';
|
||||
@import 'variables';
|
||||
@import 'fonts';
|
||||
|
||||
/**
|
||||
* Mixins
|
||||
|
@ -19,7 +19,7 @@
|
|||
border-radius: 100%;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
|
||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
|
||||
background-color: #444;
|
||||
color: #fff !important;
|
||||
font-size: 16px !important;
|
||||
|
@ -38,7 +38,7 @@ div.pp_woocommerce {
|
|||
.pp_content_container {
|
||||
background: #fff;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 30px rgba(0,0,0,0.25);
|
||||
box-shadow: 0 1px 30px rgba(0, 0, 0, 0.25);
|
||||
padding: 20px 0;
|
||||
@include clearfix();
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ div.pp_woocommerce {
|
|||
ul {
|
||||
li {
|
||||
a {
|
||||
border: 1px solid rgba(0,0,0,0.5);
|
||||
border: 1px solid rgba(0, 0, 0, 0.5);
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
||||
border-radius: 2px;
|
||||
display: block;
|
||||
|
||||
|
@ -77,10 +77,10 @@ div.pp_woocommerce {
|
|||
|
||||
.pp_previous,
|
||||
.pp_next {
|
||||
&:before {
|
||||
&::before {
|
||||
@include button();
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e00b";
|
||||
content: '\e00b';
|
||||
text-indent: 0;
|
||||
display: none;
|
||||
position: absolute;
|
||||
|
@ -90,23 +90,23 @@ div.pp_woocommerce {
|
|||
}
|
||||
|
||||
&:hover {
|
||||
&:before {
|
||||
&::before {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pp_previous {
|
||||
&:before {
|
||||
&::before {
|
||||
left: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
.pp_next {
|
||||
&:before {
|
||||
&::before {
|
||||
right: 1em;
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e008";
|
||||
content: '\e008';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,13 +136,13 @@ div.pp_woocommerce {
|
|||
|
||||
.pp_close {
|
||||
@include button();
|
||||
top: -.5em;
|
||||
right: -.5em;
|
||||
top: -0.5em;
|
||||
right: -0.5em;
|
||||
font-size: 1.618em !important;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e013";
|
||||
content: '\e013';
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -160,9 +160,9 @@ div.pp_woocommerce {
|
|||
position: relative;
|
||||
margin-top: -1px;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e00b";
|
||||
content: '\e00b';
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -175,14 +175,14 @@ div.pp_woocommerce {
|
|||
}
|
||||
|
||||
.pp_arrow_previous {
|
||||
margin-right: .5em;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
.pp_arrow_next {
|
||||
margin-left: .5em;
|
||||
margin-left: 0.5em;
|
||||
|
||||
&:before {
|
||||
content: "\e008";
|
||||
&::before {
|
||||
content: '\e008';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,13 +190,13 @@ div.pp_woocommerce {
|
|||
a.pp_contract {
|
||||
@include button();
|
||||
right: auto;
|
||||
left: -.5em;
|
||||
top: -.5em;
|
||||
left: -0.5em;
|
||||
top: -0.5em;
|
||||
font-size: 1.618em !important;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e005";
|
||||
content: '\e005';
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -209,8 +209,8 @@ div.pp_woocommerce {
|
|||
}
|
||||
|
||||
a.pp_contract {
|
||||
&:before {
|
||||
content: "\e004";
|
||||
&::before {
|
||||
content: '\e004';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ div.pp_woocommerce {
|
|||
font-size: 44px;
|
||||
line-height: 44px;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
font-size: 44px;
|
||||
}
|
||||
}
|
||||
|
@ -281,12 +281,12 @@ div.pp_woocommerce {
|
|||
.pp_content {
|
||||
width: 100% !important;
|
||||
|
||||
#pp_full_res{
|
||||
& > img{
|
||||
#pp_full_res {
|
||||
& > img {
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.currentTextHolder {
|
||||
|
@ -385,7 +385,7 @@ div.pp_pic_holder {
|
|||
|
||||
.pp_content_container .pp_details {
|
||||
float: left;
|
||||
margin: 10px 0 2px 0;
|
||||
margin: 10px 0 2px;
|
||||
}
|
||||
|
||||
.pp_description {
|
||||
|
@ -401,7 +401,8 @@ div.pp_pic_holder {
|
|||
.pp_social .facebook {
|
||||
float: left;
|
||||
margin-left: 5px;
|
||||
width: 55px; overflow: hidden;
|
||||
width: 55px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pp_social .twitter {
|
||||
|
@ -469,7 +470,7 @@ a.pp_arrow_next {
|
|||
|
||||
.pp_gallery ul a {
|
||||
border: 1px #000 solid;
|
||||
border: 1px rgba(0,0,0,0.5) solid;
|
||||
border: 1px rgba(0, 0, 0, 0.5) solid;
|
||||
display: block;
|
||||
float: left;
|
||||
height: 33px;
|
||||
|
@ -537,7 +538,9 @@ a.pp_contract {
|
|||
}
|
||||
|
||||
a.pp_close {
|
||||
position: absolute; right: 0; top: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
display: block;
|
||||
text-indent: -10000px;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
}
|
||||
|
||||
@page {
|
||||
margin: .5cm;
|
||||
margin: 0.5cm;
|
||||
}
|
||||
|
||||
#adminmenuwrap,
|
||||
|
@ -67,7 +67,7 @@ h2 .nav-tab {
|
|||
|
||||
.chart-legend li,
|
||||
.chart-legend li {
|
||||
padding: .25em .5em !important;
|
||||
padding: 0.25em 0.5em !important;
|
||||
box-shadow: none !important;
|
||||
border-bottom: 1px solid gray !important;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,7 +14,7 @@ body {
|
|||
}
|
||||
}
|
||||
.wc-setup-content {
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
|
||||
padding: 24px 24px 0;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
|
@ -62,7 +62,7 @@ body {
|
|||
.description {
|
||||
line-height: 1.5em;
|
||||
display: block;
|
||||
margin-top: .25em;
|
||||
margin-top: 0.25em;
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ body {
|
|||
width: auto;
|
||||
box-sizing: inherit;
|
||||
padding: inherit;
|
||||
margin: 0 .5em 0 0;
|
||||
margin: 0 0.5em 0 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ body {
|
|||
}
|
||||
table.tax-rates {
|
||||
width: 100%;
|
||||
font-size: .92em;
|
||||
font-size: 0.92em;
|
||||
th {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
|
@ -116,8 +116,8 @@ body {
|
|||
&.sort {
|
||||
cursor: move;
|
||||
color: #ccc;
|
||||
&:before {
|
||||
content: "\f333";
|
||||
&::before {
|
||||
content: '\f333';
|
||||
font-family: 'dashicons';
|
||||
}
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ body {
|
|||
overflow: hidden;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
&:before {
|
||||
content: "\f502";
|
||||
&::before {
|
||||
content: '\f502';
|
||||
font-family: 'dashicons';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
@ -153,8 +153,8 @@ body {
|
|||
overflow: hidden;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
&:before {
|
||||
content: "\f182";
|
||||
&::before {
|
||||
content: '\f182';
|
||||
font-family: 'dashicons';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
@ -189,7 +189,7 @@ body {
|
|||
line-height: 1.75em;
|
||||
input {
|
||||
vertical-align: middle;
|
||||
margin: 1px 0 0 0;
|
||||
margin: 1px 0 0;
|
||||
height: 1.75em;
|
||||
width: 1.75em;
|
||||
line-height: 1.75em;
|
||||
|
@ -231,35 +231,35 @@ body {
|
|||
ul {
|
||||
padding: 0 2em 0 0;
|
||||
list-style: none outside;
|
||||
margin: 0 0 -.75em;
|
||||
margin: 0 0 -0.75em;
|
||||
li a {
|
||||
display: block;
|
||||
padding: 0 0 .75em;
|
||||
padding: 0 0 0.75em;
|
||||
}
|
||||
.setup-product {
|
||||
a {
|
||||
background-color: #bb77ae;
|
||||
border-color: #A36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
text-shadow: 0px -1px 1px #A36597, 1px 0px 1px #A36597, 0px 1px 1px #A36597, -1px 0px 1px #A36597;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
|
||||
font-size: 1em;
|
||||
height: auto;
|
||||
line-height: 1.75em;
|
||||
margin: 0 0 .75em;
|
||||
margin: 0 0 0.75em;
|
||||
opacity: 1;
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
|
||||
|
||||
&:hover, &:focus, &:active {
|
||||
background: #A36597;
|
||||
border-color: #A36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
background: #a36597;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
}
|
||||
}
|
||||
}
|
||||
li a:before {
|
||||
li a::before {
|
||||
color: #82878c;
|
||||
font: normal 20px/1 'dashicons';
|
||||
speak: none;
|
||||
|
@ -272,20 +272,20 @@ body {
|
|||
text-decoration: none !important;
|
||||
vertical-align: top;
|
||||
}
|
||||
.learn-more a:before {
|
||||
content: "\f105";
|
||||
.learn-more a::before {
|
||||
content: '\f105';
|
||||
}
|
||||
.video-walkthrough a:before {
|
||||
content: "\f126";
|
||||
.video-walkthrough a::before {
|
||||
content: '\f126';
|
||||
}
|
||||
.newsletter a:before {
|
||||
content: "\f465";
|
||||
.newsletter a::before {
|
||||
content: '\f465';
|
||||
}
|
||||
}
|
||||
}
|
||||
.woocommerce-tracker, .updated {
|
||||
padding: 24px 24px 0;
|
||||
margin: 0 0 24px 0;
|
||||
margin: 0 0 24px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
p {
|
||||
|
@ -293,7 +293,7 @@ body {
|
|||
margin: 0 0 12px;
|
||||
}
|
||||
p:last-child {
|
||||
margin: 0 0 24px 0;
|
||||
margin: 0 0 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -317,8 +317,8 @@ body {
|
|||
border-bottom: 4px solid #ccc;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
li:before {
|
||||
content: "";
|
||||
li::before {
|
||||
content: '';
|
||||
border: 4px solid #ccc;
|
||||
border-radius: 100%;
|
||||
width: 4px;
|
||||
|
@ -333,14 +333,14 @@ body {
|
|||
li.active {
|
||||
border-color: #a16696;
|
||||
color: #a16696;
|
||||
&:before {
|
||||
&::before {
|
||||
border-color: #a16696;
|
||||
}
|
||||
}
|
||||
li.done {
|
||||
border-color: #a16696;
|
||||
color: #a16696;
|
||||
&:before {
|
||||
&::before {
|
||||
border-color: #a16696;
|
||||
background: #a16696;
|
||||
}
|
||||
|
@ -351,28 +351,28 @@ body {
|
|||
.button {
|
||||
float: right;
|
||||
font-size: 1.25em;
|
||||
padding: .5em 1em;
|
||||
padding: 0.5em 1em;
|
||||
line-height: 1em;
|
||||
margin-right: .5em;
|
||||
margin-right: 0.5em;
|
||||
margin-bottom: 2px;
|
||||
height: auto;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.button-primary {
|
||||
background-color: #bb77ae;
|
||||
border-color: #A36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
text-shadow: 0px -1px 1px #A36597, 1px 0px 1px #A36597, 0px 1px 1px #A36597, -1px 0px 1px #A36597;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
|
||||
float: right;
|
||||
margin: 0;
|
||||
opacity: 1;
|
||||
|
||||
&:hover, &:focus, &:active {
|
||||
background: #A36597;
|
||||
border-color: #A36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
|
||||
background: #a36597;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ ul.wc-wizard-payment-gateways {
|
|||
}
|
||||
|
||||
&.checked {
|
||||
background: #F7F1F6;
|
||||
background: #f7f1f6;
|
||||
|
||||
.wc-wizard-gateway-settings {
|
||||
display: table;
|
||||
|
@ -435,12 +435,12 @@ ul.wc-wizard-payment-gateways {
|
|||
font-style: italic;
|
||||
|
||||
p {
|
||||
margin: 0 0 .5em;
|
||||
margin: 0 0 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
.wc-wizard-gateway-enable {
|
||||
margin: 0 0 .5em;
|
||||
margin: 0 0 0.5em;
|
||||
|
||||
label {
|
||||
display: block;
|
||||
|
@ -452,7 +452,7 @@ ul.wc-wizard-payment-gateways {
|
|||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
label:before {
|
||||
label::before {
|
||||
content: '';
|
||||
background: #fff;
|
||||
border: 2px solid #eee;
|
||||
|
@ -473,8 +473,8 @@ ul.wc-wizard-payment-gateways {
|
|||
width: 0;
|
||||
position: absolute;
|
||||
|
||||
&:checked + label:before {
|
||||
content: "\f147";
|
||||
&:checked + label::before {
|
||||
content: '\f147';
|
||||
font-family: 'dashicons';
|
||||
color: #fff;
|
||||
border-color: #a46497;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,9 +6,9 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import "mixins";
|
||||
@import "variables";
|
||||
@import 'bourbon';
|
||||
@import 'mixins';
|
||||
@import 'variables';
|
||||
|
||||
/**
|
||||
* Styling begins
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,9 +6,9 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import "mixins";
|
||||
@import "variables";
|
||||
@import 'bourbon';
|
||||
@import 'mixins';
|
||||
@import 'variables';
|
||||
|
||||
/**
|
||||
* Style begins
|
||||
|
@ -44,7 +44,7 @@
|
|||
text-align: left !important; // This must always align left on handheld
|
||||
}
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
content: attr(data-title) ': ';
|
||||
font-weight: 700;
|
||||
float: left;
|
||||
|
@ -52,15 +52,15 @@
|
|||
|
||||
&.product-remove,
|
||||
&.actions {
|
||||
&:before {
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(2n) {
|
||||
&:nth-child( 2n ) {
|
||||
td {
|
||||
background-color: rgba(0,0,0,0.025);
|
||||
background-color: rgba(0, 0, 0, 0.025);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,13 +72,13 @@
|
|||
&.order-actions {
|
||||
text-align: left;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
float: none;
|
||||
margin: .125em .25em .125em 0;
|
||||
margin: 0.125em 0.25em 0.125em 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@
|
|||
/**
|
||||
* Products
|
||||
*/
|
||||
&, &[class*="columns-"] {
|
||||
&, &[class*='columns-'] {
|
||||
ul.products {
|
||||
li.product {
|
||||
width: 48%;
|
||||
|
@ -107,7 +107,7 @@
|
|||
clear: both;
|
||||
margin: 0 0 2.992em;
|
||||
|
||||
&:nth-child(2n) {
|
||||
&:nth-child( 2n ) {
|
||||
float: right;
|
||||
clear: none !important; // This should never clear.
|
||||
}
|
||||
|
@ -142,7 +142,7 @@
|
|||
.coupon {
|
||||
float: none;
|
||||
@include clearfix();
|
||||
padding-bottom: .5em;
|
||||
padding-bottom: 0.5em;
|
||||
|
||||
input,
|
||||
.button,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,11 +7,11 @@
|
|||
/**
|
||||
* Imports
|
||||
*/
|
||||
@import "bourbon";
|
||||
@import "mixins";
|
||||
@import "variables";
|
||||
@import "animation";
|
||||
@import "fonts";
|
||||
@import 'bourbon';
|
||||
@import 'mixins';
|
||||
@import 'variables';
|
||||
@import 'animation';
|
||||
@import 'fonts';
|
||||
|
||||
/**
|
||||
* Global styles
|
||||
|
@ -29,7 +29,7 @@ p.demo_store {
|
|||
background-color: $primary;
|
||||
color: $primarytext;
|
||||
z-index: 99998;
|
||||
box-shadow: 0 1px 1em rgba(0,0,0,0.2);
|
||||
box-shadow: 0 1px 1em rgba(0, 0, 0, 0.2);
|
||||
a {
|
||||
color: $primarytext;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ p.demo_store {
|
|||
small.note {
|
||||
display: block;
|
||||
color: $subtext;
|
||||
font-size: .857em;
|
||||
font-size: 0.857em;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ p.demo_store {
|
|||
|
||||
a {
|
||||
display: inline-block;
|
||||
padding: .5em 0;
|
||||
padding: 0.5em 0;
|
||||
font-weight: 700;
|
||||
color: $secondarytext;
|
||||
text-decoration: none;
|
||||
|
@ -233,26 +233,26 @@ p.demo_store {
|
|||
text-shadow: inherit;
|
||||
}
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
box-shadow: 2px 2px 0 $contentbg;
|
||||
}
|
||||
|
||||
&:after {
|
||||
&::after {
|
||||
box-shadow: -2px 2px 0 $contentbg;
|
||||
}
|
||||
}
|
||||
|
||||
&:before,
|
||||
&:after {
|
||||
&::before,
|
||||
&::after {
|
||||
border: 1px solid darken( $secondary, 10% );
|
||||
position: absolute;
|
||||
bottom: -1px;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
content: " ";
|
||||
content: ' ';
|
||||
}
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
left: -6px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-moz-border-bottom-right-radius: 4px;
|
||||
|
@ -261,7 +261,7 @@ p.demo_store {
|
|||
box-shadow: 2px 2px 0 $secondary;
|
||||
}
|
||||
|
||||
&:after {
|
||||
&::after {
|
||||
right: -6px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-moz-border-bottom-left-radius: 4px;
|
||||
|
@ -271,9 +271,9 @@ p.demo_store {
|
|||
}
|
||||
}
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
position: absolute;
|
||||
content: " ";
|
||||
content: ' ';
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
|
@ -303,7 +303,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
table {
|
||||
border-width: 0 0 1px 0;
|
||||
border-width: 0 0 1px;
|
||||
|
||||
td {
|
||||
padding-left: 0;
|
||||
|
@ -376,7 +376,7 @@ p.demo_store {
|
|||
|
||||
td {
|
||||
vertical-align: top;
|
||||
padding-bottom: .5em;
|
||||
padding-bottom: 0.5em;
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
@ -386,19 +386,19 @@ p.demo_store {
|
|||
span.onsale {
|
||||
min-height: 3.236em;
|
||||
min-width: 3.236em;
|
||||
padding: .202em;
|
||||
padding: 0.202em;
|
||||
font-size: 1em;
|
||||
font-weight: 700;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
line-height: 3.236;
|
||||
top: -.5em;
|
||||
left: -.5em;
|
||||
top: -0.5em;
|
||||
left: -0.5em;
|
||||
margin: 0;
|
||||
border-radius: 100%;
|
||||
background-color: $highlight;
|
||||
color: $highlightext;
|
||||
font-size: .857em;
|
||||
font-size: 0.857em;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
|
@ -424,11 +424,11 @@ p.demo_store {
|
|||
top: 0;
|
||||
right: 0;
|
||||
left: auto;
|
||||
margin: -.5em -.5em 0 0;
|
||||
margin: -0.5em -0.5em 0 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
padding: .5em 0;
|
||||
padding: 0.5em 0;
|
||||
margin: 0;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
.star-rating {
|
||||
font-size: .857em;
|
||||
font-size: 0.857em;
|
||||
}
|
||||
|
||||
.button {
|
||||
|
@ -461,8 +461,8 @@ p.demo_store {
|
|||
color: $highlight;
|
||||
display: block;
|
||||
font-weight: normal;
|
||||
margin-bottom: .5em;
|
||||
font-size: .857em;
|
||||
margin-bottom: 0.5em;
|
||||
font-size: 0.857em;
|
||||
|
||||
del {
|
||||
color: inherit;
|
||||
|
@ -525,7 +525,7 @@ p.demo_store {
|
|||
line-height: 1;
|
||||
font-size: 1em;
|
||||
font-weight: normal;
|
||||
padding: .5em;
|
||||
padding: 0.5em;
|
||||
min-width: 1em;
|
||||
display: block;
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ p.demo_store {
|
|||
position: relative;
|
||||
text-decoration: none;
|
||||
overflow: visible;
|
||||
padding: .618em 1em;
|
||||
padding: 0.618em 1em;
|
||||
font-weight: 700;
|
||||
border-radius: 3px;
|
||||
left: auto;
|
||||
|
@ -572,26 +572,26 @@ p.demo_store {
|
|||
opacity: 0.25;
|
||||
padding-right: 2.618em;
|
||||
|
||||
&:after {
|
||||
font-family: "WooCommerce";
|
||||
content: "\e01c";
|
||||
&::after {
|
||||
font-family: 'WooCommerce';
|
||||
content: '\e01c';
|
||||
vertical-align: top;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-weight: 400;
|
||||
position: absolute;
|
||||
top: .618em;
|
||||
top: 0.618em;
|
||||
right: 1em;
|
||||
-webkit-animation: spin 2s linear infinite;
|
||||
-moz-animation: spin 2s linear infinite;
|
||||
animation: spin 2s linear infinite;
|
||||
-moz-animation: spin 2s linear infinite;
|
||||
animation: spin 2s linear infinite;
|
||||
}
|
||||
}
|
||||
|
||||
&.added {
|
||||
&:after {
|
||||
&::after {
|
||||
font-family: 'WooCommerce';
|
||||
content: "\e017";
|
||||
margin-left: .53em;
|
||||
content: '\e017';
|
||||
margin-left: 0.53em;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ p.demo_store {
|
|||
color: inherit;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
padding: .618em 1em;
|
||||
padding: 0.618em 1em;
|
||||
|
||||
&:hover {
|
||||
color: inherit;
|
||||
|
@ -645,7 +645,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
a.added_to_cart {
|
||||
padding-top: .5em;
|
||||
padding-top: 0.5em;
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ p.demo_store {
|
|||
float: right;
|
||||
color: $subtext;
|
||||
font-size: 15px;
|
||||
margin: 10px 0 0 0;
|
||||
margin: 10px 0 0;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
|
@ -757,8 +757,8 @@ p.demo_store {
|
|||
}
|
||||
}
|
||||
|
||||
.commentlist > li:before {
|
||||
content: "";
|
||||
.commentlist > li::before {
|
||||
content: '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -776,8 +776,8 @@ p.demo_store {
|
|||
width: 5.4em;
|
||||
font-family: 'star';
|
||||
|
||||
&:before {
|
||||
content: "\73\73\73\73\73";
|
||||
&::before {
|
||||
content: '\73\73\73\73\73';
|
||||
color: darken( $secondary, 10% );
|
||||
float: left;
|
||||
top: 0;
|
||||
|
@ -794,8 +794,8 @@ p.demo_store {
|
|||
padding-top: 1.5em;
|
||||
}
|
||||
|
||||
span:before {
|
||||
content: "\53\53\53\53\53";
|
||||
span::before {
|
||||
content: '\53\53\53\53\53';
|
||||
top: 0;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
@ -808,7 +808,7 @@ p.demo_store {
|
|||
display: block;
|
||||
|
||||
.star-rating {
|
||||
margin: .5em 4px 0 0;
|
||||
margin: 0.5em 4px 0 0;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
@ -816,14 +816,14 @@ p.demo_store {
|
|||
.products {
|
||||
.star-rating {
|
||||
display: block;
|
||||
margin: 0 0 .5em;
|
||||
margin: 0 0 0.5em;
|
||||
float: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hreview-aggregate {
|
||||
.star-rating {
|
||||
margin: 10px 0 0 0;
|
||||
margin: 10px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ p.demo_store {
|
|||
position: static;
|
||||
margin: 0;
|
||||
width: auto;
|
||||
padding: 0 0 0;
|
||||
padding: 0;
|
||||
background: transparent none;
|
||||
border: 0;
|
||||
|
||||
|
@ -863,7 +863,7 @@ p.demo_store {
|
|||
display: inline-block;
|
||||
text-decoration: none;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -871,40 +871,40 @@ p.demo_store {
|
|||
width: 1em;
|
||||
height: 1em;
|
||||
line-height: 1;
|
||||
font-family: "WooCommerce";
|
||||
content: "\e021";
|
||||
font-family: 'WooCommerce';
|
||||
content: '\e021';
|
||||
text-indent: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
~ a:before {
|
||||
content: "\e021";
|
||||
~ a::before {
|
||||
content: '\e021';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
a {
|
||||
&:before {
|
||||
content: "\e020";
|
||||
&::before {
|
||||
content: '\e020';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.selected {
|
||||
a.active {
|
||||
&:before {
|
||||
content: "\e020";
|
||||
&::before {
|
||||
content: '\e020';
|
||||
}
|
||||
|
||||
~ a:before {
|
||||
content: "\e021";
|
||||
~ a::before {
|
||||
content: '\e021';
|
||||
}
|
||||
}
|
||||
|
||||
a:not(.active) {
|
||||
&:before {
|
||||
content: "\e020";
|
||||
a:not( .active ) {
|
||||
&::before {
|
||||
content: '\e020';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ p.demo_store {
|
|||
*/
|
||||
table.shop_attributes {
|
||||
border: 0;
|
||||
border-top: 1px dotted rgba(0,0,0,0.1);
|
||||
border-top: 1px dotted rgba(0, 0, 0, 0.1);
|
||||
margin-bottom: 1.618em;
|
||||
width: 100%;
|
||||
|
||||
|
@ -924,7 +924,7 @@ p.demo_store {
|
|||
font-weight: 700;
|
||||
padding: 8px;
|
||||
border-top: 0;
|
||||
border-bottom: 1px dotted rgba(0,0,0,0.1);
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.1);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
@ -933,7 +933,7 @@ p.demo_store {
|
|||
font-style: italic;
|
||||
padding: 0;
|
||||
border-top: 0;
|
||||
border-bottom: 1px dotted rgba(0,0,0,0.1);
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.1);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
|
||||
|
@ -945,13 +945,13 @@ p.demo_store {
|
|||
|
||||
.alt td,
|
||||
.alt th {
|
||||
background: rgba(0,0,0,0.025);
|
||||
background: rgba(0, 0, 0, 0.025);
|
||||
}
|
||||
}
|
||||
|
||||
table.shop_table {
|
||||
border: 1px solid rgba(0,0,0,0.1);
|
||||
margin: 0px -1px 24px 0px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
margin: 0 -1px 24px 0;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
|
@ -963,7 +963,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
td {
|
||||
border-top: 1px solid rgba(0,0,0,0.1);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
padding: 6px 12px;
|
||||
vertical-align: middle;
|
||||
|
||||
|
@ -985,7 +985,7 @@ p.demo_store {
|
|||
tfoot th,
|
||||
tbody th {
|
||||
font-weight: 700;
|
||||
border-top: 1px solid rgba(0,0,0,0.1);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1006,14 +1006,14 @@ p.demo_store {
|
|||
text-align: right;
|
||||
|
||||
.button {
|
||||
margin: .125em 0 .125em .25em;
|
||||
margin: 0.125em 0 0.125em 0.25em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
td.product-name {
|
||||
dl.variation {
|
||||
margin: .25em 0;
|
||||
margin: 0.25em 0;
|
||||
@include clearfix();
|
||||
|
||||
dt,
|
||||
|
@ -1025,13 +1025,13 @@ p.demo_store {
|
|||
|
||||
dt {
|
||||
font-weight: 700;
|
||||
padding: 0 0 .25em 0;
|
||||
padding: 0 0 0.25em;
|
||||
margin: 0 4px 0 0;
|
||||
clear: left;
|
||||
}
|
||||
|
||||
dd {
|
||||
padding: 0 0 .25em 0;
|
||||
padding: 0 0 0.25em;
|
||||
|
||||
p:last-child {
|
||||
margin-bottom: 0;
|
||||
|
@ -1080,7 +1080,7 @@ p.demo_store {
|
|||
dl {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
border-left: 2px solid rgba(0,0,0,0.1);
|
||||
border-left: 2px solid rgba(0, 0, 0, 0.1);
|
||||
@include clearfix();
|
||||
|
||||
dt,
|
||||
|
@ -1092,13 +1092,13 @@ p.demo_store {
|
|||
|
||||
dt {
|
||||
font-weight: 700;
|
||||
padding: 0 0 .25em 0;
|
||||
padding: 0 0 0.25em;
|
||||
margin: 0 4px 0 0;
|
||||
clear: left;
|
||||
}
|
||||
|
||||
dd {
|
||||
padding: 0 0 .25em 0;
|
||||
padding: 0 0 0.25em;
|
||||
|
||||
p:last-child {
|
||||
margin-bottom: 0;
|
||||
|
@ -1253,7 +1253,7 @@ p.demo_store {
|
|||
form.register {
|
||||
border: 1px solid darken( $secondary, 10% );
|
||||
padding: 20px;
|
||||
margin: 2em 0 2em 0px;
|
||||
margin: 2em 0;
|
||||
text-align: left;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ p.demo_store {
|
|||
|
||||
li {
|
||||
margin: 0;
|
||||
padding: .25em 0 .25em 22px;
|
||||
padding: 0.25em 0 0.25em 22px;
|
||||
text-indent: -22px;
|
||||
list-style: none outside;
|
||||
input {
|
||||
|
@ -1341,8 +1341,8 @@ p.demo_store {
|
|||
|
||||
li.chosen {
|
||||
a {
|
||||
&:before {
|
||||
@include iconbefore( "\e013" );
|
||||
&::before {
|
||||
@include iconbefore( '\e013' );
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
|
@ -1367,8 +1367,8 @@ p.demo_store {
|
|||
a {
|
||||
text-decoration: none;
|
||||
|
||||
&:before {
|
||||
@include iconbefore( "\e013" );
|
||||
&::before {
|
||||
@include iconbefore( '\e013' );
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
|
@ -1401,8 +1401,8 @@ p.demo_store {
|
|||
.ui-slider {
|
||||
position: relative;
|
||||
text-align: left;
|
||||
margin-left: .5em;
|
||||
margin-right: .5em;
|
||||
margin-left: 0.5em;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
.ui-slider .ui-slider-handle {
|
||||
|
@ -1414,17 +1414,17 @@ p.demo_store {
|
|||
border-radius: 1em;
|
||||
cursor: ew-resize;
|
||||
outline: none;
|
||||
top: -.3em;
|
||||
top: -0.3em;
|
||||
|
||||
//&:last-child {
|
||||
margin-left: -.5em;
|
||||
margin-left: -0.5em;
|
||||
//}
|
||||
}
|
||||
|
||||
.ui-slider .ui-slider-range {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
font-size: .7em;
|
||||
font-size: 0.7em;
|
||||
display: block;
|
||||
border: 0;
|
||||
border-radius: 1em;
|
||||
|
@ -1438,7 +1438,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
.ui-slider-horizontal {
|
||||
height: .5em;
|
||||
height: 0.5em;
|
||||
}
|
||||
|
||||
.ui-slider-horizontal .ui-slider-range {
|
||||
|
@ -1483,8 +1483,8 @@ p.demo_store {
|
|||
|
||||
li.chosen {
|
||||
a {
|
||||
&:before {
|
||||
@include iconbefore( "\e013" );
|
||||
&::before {
|
||||
@include iconbefore( '\e013' );
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
|
@ -1499,7 +1499,7 @@ p.demo_store {
|
|||
padding: 1em 2em 1em 3.5em;
|
||||
margin: 0 0 2em;
|
||||
position: relative;
|
||||
background-color: lighten($secondary,5%);
|
||||
background-color: lighten($secondary, 5%);
|
||||
color: $secondarytext;
|
||||
border-top: 3px solid $primary;
|
||||
list-style: none outside;
|
||||
|
@ -1507,9 +1507,9 @@ p.demo_store {
|
|||
width: auto;
|
||||
word-wrap: break-word;
|
||||
|
||||
&:before {
|
||||
font-family: "WooCommerce";
|
||||
content: "\e028";
|
||||
&::before {
|
||||
font-family: 'WooCommerce';
|
||||
content: '\e028';
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 1em;
|
||||
|
@ -1530,8 +1530,8 @@ p.demo_store {
|
|||
.woocommerce-message {
|
||||
border-top-color: #8fae1b;
|
||||
|
||||
&:before {
|
||||
content: "\e015";
|
||||
&::before {
|
||||
content: '\e015';
|
||||
color: #8fae1b;
|
||||
}
|
||||
}
|
||||
|
@ -1539,7 +1539,7 @@ p.demo_store {
|
|||
.woocommerce-info {
|
||||
border-top-color: #1e85be;
|
||||
|
||||
&:before {
|
||||
&::before {
|
||||
color: #1e85be;
|
||||
}
|
||||
}
|
||||
|
@ -1547,8 +1547,8 @@ p.demo_store {
|
|||
.woocommerce-error {
|
||||
border-top-color: #b81c23;
|
||||
|
||||
&:before {
|
||||
content: "\e016";
|
||||
&::before {
|
||||
content: '\e016';
|
||||
color: #b81c23;
|
||||
}
|
||||
}
|
||||
|
@ -1599,8 +1599,8 @@ p.demo_store {
|
|||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
|
||||
&:before {
|
||||
@include iconbefore( "\e00a" );
|
||||
&::before {
|
||||
@include iconbefore( '\e00a' );
|
||||
}
|
||||
|
||||
.count {
|
||||
|
@ -1676,8 +1676,8 @@ p.demo_store {
|
|||
}
|
||||
|
||||
.shipping-calculator-button {
|
||||
&:after {
|
||||
@include iconafter( "\e019" );
|
||||
&::after {
|
||||
@include iconafter( '\e019' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1799,7 +1799,7 @@ p.demo_store {
|
|||
|
||||
img {
|
||||
vertical-align: middle;
|
||||
margin: -2px 0 0 .5em;
|
||||
margin: -2px 0 0 0.5em;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
box-shadow: none;
|
||||
|
@ -1820,7 +1820,7 @@ p.demo_store {
|
|||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 1em;
|
||||
margin: 1em 0 1em 0;
|
||||
margin: 1em 0;
|
||||
font-size: 0.92em;
|
||||
border-radius: 2px;
|
||||
line-height: 1.5;
|
||||
|
@ -1849,7 +1849,7 @@ p.demo_store {
|
|||
margin: 0;
|
||||
.woocommerce-SavedPaymentMethods-token,
|
||||
.woocommerce-SavedPaymentMethods-new {
|
||||
margin: 0 0 .5em 0;
|
||||
margin: 0 0 0.5em;
|
||||
label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -1872,43 +1872,43 @@ p.demo_store {
|
|||
font-size: 1.5em;
|
||||
padding: 8px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: right .618em center;
|
||||
background-position: right 0.618em center;
|
||||
background-size: 32px 20px;
|
||||
|
||||
&.visa {
|
||||
background-image: url(../images/icons/credit-cards/visa.svg);
|
||||
background-image: url('../images/icons/credit-cards/visa.svg');
|
||||
}
|
||||
|
||||
&.mastercard {
|
||||
background-image: url(../images/icons/credit-cards/mastercard.svg);
|
||||
background-image: url('../images/icons/credit-cards/mastercard.svg');
|
||||
}
|
||||
|
||||
&.laser {
|
||||
background-image: url(../images/icons/credit-cards/laser.svg);
|
||||
background-image: url('../images/icons/credit-cards/laser.svg');
|
||||
}
|
||||
|
||||
&.dinersclub {
|
||||
background-image: url(../images/icons/credit-cards/diners.svg);
|
||||
background-image: url('../images/icons/credit-cards/diners.svg');
|
||||
}
|
||||
|
||||
&.maestro {
|
||||
background-image: url(../images/icons/credit-cards/maestro.svg);
|
||||
background-image: url('../images/icons/credit-cards/maestro.svg');
|
||||
}
|
||||
|
||||
&.jcb {
|
||||
background-image: url(../images/icons/credit-cards/jcb.svg);
|
||||
background-image: url('../images/icons/credit-cards/jcb.svg');
|
||||
}
|
||||
|
||||
&.amex {
|
||||
background-image: url(../images/icons/credit-cards/amex.svg);
|
||||
background-image: url('../images/icons/credit-cards/amex.svg');
|
||||
}
|
||||
&.discover {
|
||||
background-image: url(../images/icons/credit-cards/discover.svg);
|
||||
background-image: url('../images/icons/credit-cards/discover.svg');
|
||||
}
|
||||
}
|
||||
|
||||
span.help {
|
||||
font-size: .857em;
|
||||
font-size: 0.857em;
|
||||
color: $subtext;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
@ -1921,15 +1921,15 @@ p.demo_store {
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
&::before {
|
||||
content: '';
|
||||
display: block;
|
||||
border: 1em solid darken( $secondary, 5% ); /* arrow size / color */
|
||||
border-right-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-top-color: transparent;
|
||||
position: absolute;
|
||||
top: -.75em;
|
||||
top: -0.75em;
|
||||
left: 0;
|
||||
margin: -1em 0 0 2em;
|
||||
}
|
||||
|
@ -1956,7 +1956,7 @@ p.demo_store {
|
|||
.woocommerce-password-strength {
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
padding: 3px .5em;
|
||||
padding: 3px 0.5em;
|
||||
font-size: 1em;
|
||||
|
||||
&.strong {
|
||||
|
@ -1981,7 +1981,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
.woocommerce-password-hint {
|
||||
margin: .5em 0 0 0;
|
||||
margin: 0.5em 0 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
@ -2041,7 +2041,7 @@ p.demo_store {
|
|||
/**
|
||||
* Twenty Sixteen specific styles
|
||||
*/
|
||||
body:not(.search-results) {
|
||||
body:not( .search-results ) {
|
||||
.twentysixteen {
|
||||
.entry-summary {
|
||||
color: inherit;
|
||||
|
|
|
@ -809,24 +809,16 @@ jQuery( function ( $ ) {
|
|||
add: function() {
|
||||
var $button = $( this );
|
||||
var $item = $button.closest( 'tr.item, tr.shipping' );
|
||||
|
||||
var data = {
|
||||
order_item_id: $item.attr( 'data-order_item_id' ),
|
||||
action: 'woocommerce_add_order_item_meta',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
wc_meta_boxes_order_items.block();
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
$item.find('tbody.meta_items').append( response );
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
}
|
||||
});
|
||||
var $items = $item.find('tbody.meta_items');
|
||||
var index = $items.find('tr').length + 1;
|
||||
var $row = '<tr data-meta_id="0">' +
|
||||
'<td>' +
|
||||
'<input type="text" name="meta_key[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']" />' +
|
||||
'<textarea name="meta_value[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']"></textarea>' +
|
||||
'</td>' +
|
||||
'<td width="1%"><button class="remove_order_item_meta button">×</button></td>' +
|
||||
'</tr>';
|
||||
$items.append( $row );
|
||||
|
||||
return false;
|
||||
},
|
||||
|
@ -834,24 +826,8 @@ jQuery( function ( $ ) {
|
|||
remove: function() {
|
||||
if ( window.confirm( woocommerce_admin_meta_boxes.remove_item_meta ) ) {
|
||||
var $row = $( this ).closest( 'tr' );
|
||||
|
||||
var data = {
|
||||
meta_id: $row.attr( 'data-meta_id' ),
|
||||
action: 'woocommerce_remove_order_item_meta',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
wc_meta_boxes_order_items.block();
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function() {
|
||||
$row.remove();
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
}
|
||||
});
|
||||
$row.find( ':input' ).val( '' );
|
||||
$row.hide();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
/*global wc_add_to_cart_variation_params, wc_cart_fragments_params */
|
||||
/*global wc_add_to_cart_variation_params */
|
||||
/*!
|
||||
* Variations Plugin
|
||||
*/
|
||||
|
@ -129,7 +129,7 @@
|
|||
} );
|
||||
|
||||
$xhr = $.ajax( {
|
||||
url: wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_variation' ),
|
||||
url: wc_add_to_cart_variation_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_variation' ),
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function( variation ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -55,13 +55,6 @@ abstract class WC_Data {
|
|||
*/
|
||||
protected $_internal_meta_keys = array();
|
||||
|
||||
/**
|
||||
* Should meta objects not present in the keys
|
||||
* array be purged when updating/saving meta?
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_delete_extra_meta_data = false;
|
||||
|
||||
/**
|
||||
* Returns the unique ID for this object.
|
||||
* @return int
|
||||
|
@ -232,6 +225,16 @@ abstract class WC_Data {
|
|||
$this->_meta_data = array_diff_key( $this->_meta_data, array_fill_keys( $array_keys, '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete meta data.
|
||||
* @since 2.6.0
|
||||
* @param int $mid Meta ID
|
||||
*/
|
||||
public function delete_meta_data_by_mid( $mid ) {
|
||||
$array_keys = array_keys( wp_list_pluck( $this->_meta_data, 'meta_id' ), $mid );
|
||||
$this->_meta_data = array_diff_key( $this->_meta_data, array_fill_keys( $array_keys, '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Meta Data from the database. Ignore any internal properties.
|
||||
* @since 2.6.0
|
||||
|
@ -244,7 +247,7 @@ abstract class WC_Data {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! empty ( $this->_cache_group ) ) {
|
||||
if ( ! empty( $this->_cache_group ) ) {
|
||||
$cache_key = WC_Cache_Helper::get_cache_prefix( $this->_cache_group ) . $this->get_id();
|
||||
$cached_meta = wp_cache_get( $cache_key, $this->_cache_group );
|
||||
|
||||
|
@ -260,21 +263,23 @@ abstract class WC_Data {
|
|||
$raw_meta_data = $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT " . $db_info['meta_id_field'] . ", meta_key, meta_value
|
||||
FROM " . $db_info['table'] . "
|
||||
WHERE " . $db_info['object_id_field'] . " = %d ORDER BY " . $db_info['meta_id_field'] . "
|
||||
WHERE " . $db_info['object_id_field'] . "=%d AND meta_key NOT LIKE 'wp\_%%' ORDER BY " . $db_info['meta_id_field'] . "
|
||||
", $this->get_id() ) );
|
||||
|
||||
foreach ( $raw_meta_data as $meta ) {
|
||||
if ( in_array( $meta->meta_key, $this->get_internal_meta_keys() ) ) {
|
||||
continue;
|
||||
if ( $raw_meta_data ) {
|
||||
foreach ( $raw_meta_data as $meta ) {
|
||||
if ( in_array( $meta->meta_key, $this->get_internal_meta_keys() ) ) {
|
||||
continue;
|
||||
}
|
||||
$this->_meta_data[] = (object) array(
|
||||
'key' => $meta->meta_key,
|
||||
'value' => maybe_unserialize( $meta->meta_value ),
|
||||
'meta_id' => $meta->{ $db_info['meta_id_field'] },
|
||||
);
|
||||
}
|
||||
$this->_meta_data[] = (object) array(
|
||||
'key' => $meta->meta_key,
|
||||
'value' => $meta->meta_value,
|
||||
'meta_id' => $meta->{ $db_info['meta_id_field'] },
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty ( $this->_cache_group ) ) {
|
||||
if ( ! empty( $this->_cache_group ) ) {
|
||||
wp_cache_set( $cache_key, $this->_meta_data, $this->_cache_group );
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +295,8 @@ abstract class WC_Data {
|
|||
$all_meta_ids = array_map( 'absint', $wpdb->get_col( $wpdb->prepare( "
|
||||
SELECT " . $db_info['meta_id_field'] . " FROM " . $db_info['table'] . "
|
||||
WHERE " . $db_info['object_id_field'] . " = %d", $this->get_id() ) . "
|
||||
AND meta_key NOT IN ('" . implode( "','", array_map( 'esc_sql', $this->get_internal_meta_keys() ) ) . "');
|
||||
AND meta_key NOT IN ('" . implode( "','", array_map( 'esc_sql', $this->get_internal_meta_keys() ) ) . "')
|
||||
AND meta_key NOT LIKE 'wp\_%%';
|
||||
" ) );
|
||||
$set_meta_ids = array();
|
||||
|
||||
|
@ -306,14 +312,12 @@ abstract class WC_Data {
|
|||
}
|
||||
|
||||
// Delete no longer set meta data
|
||||
if ( $this->_delete_extra_meta_data ) {
|
||||
$delete_meta_ids = array_diff( $all_meta_ids, $set_meta_ids );
|
||||
foreach ( $delete_meta_ids as $meta_id ) {
|
||||
delete_metadata_by_mid( $this->_meta_type, $meta_id );
|
||||
}
|
||||
$delete_meta_ids = array_diff( $all_meta_ids, $set_meta_ids );
|
||||
foreach ( $delete_meta_ids as $meta_id ) {
|
||||
delete_metadata_by_mid( $this->_meta_type, $meta_id );
|
||||
}
|
||||
|
||||
if ( ! empty ( $this->_cache_group ) ) {
|
||||
if ( ! empty( $this->_cache_group ) ) {
|
||||
WC_Cache_Helper::incr_cache_prefix( $this->_cache_group );
|
||||
}
|
||||
$this->read_meta_data();
|
||||
|
@ -354,4 +358,10 @@ abstract class WC_Data {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception due to invalid data.
|
||||
*/
|
||||
protected function throw_exception( $id, $message = '', $code = 400 ) {
|
||||
throw new WC_Data_Exception( $id, $message, $code );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
'id' => 0,
|
||||
'parent_id' => 0,
|
||||
'status' => '',
|
||||
'type' => 'shop_order',
|
||||
'order_key' => '',
|
||||
'currency' => '',
|
||||
'version' => '',
|
||||
|
@ -76,6 +75,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
'tax_lines' => null,
|
||||
);
|
||||
|
||||
/**
|
||||
* Order items that need deleting are stored here.
|
||||
* @since 2.7.0
|
||||
* @var array
|
||||
*/
|
||||
protected $_items_to_delete = array();
|
||||
|
||||
/**
|
||||
* Internal meta type used to store order data.
|
||||
* @var string
|
||||
|
@ -195,7 +201,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$this->set_date_created( $post_object->post_date );
|
||||
$this->set_date_modified( $post_object->post_modified );
|
||||
$this->set_status( $post_object->post_status );
|
||||
$this->set_order_type( $post_object->post_type );
|
||||
$this->set_customer_id( get_post_meta( $this->get_id(), '_customer_user', true ) );
|
||||
$this->set_order_key( get_post_meta( $this->get_id(), '_order_key', true ) );
|
||||
$this->set_currency( get_post_meta( $this->get_id(), '_order_currency', true ) );
|
||||
|
@ -295,6 +300,14 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Save all order items which are part of this order.
|
||||
*/
|
||||
protected function save_items() {
|
||||
// remove items
|
||||
foreach ( $this->_items_to_delete as $item ) {
|
||||
$item->delete();
|
||||
}
|
||||
|
||||
$this->_items_to_delete = array();
|
||||
|
||||
// Add/save items
|
||||
foreach ( $this->_items as $item_group => $items ) {
|
||||
if ( is_array( $items ) ) {
|
||||
foreach ( $items as $item_key => $item ) {
|
||||
|
@ -309,21 +322,18 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
// Legacy action handler
|
||||
switch ( $item_group ) {
|
||||
case 'fee_lines' :
|
||||
if ( has_action( 'woocommerce_add_order_fee_meta' ) && isset( $item->legacy_fee, $item->legacy_fee_key ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_add_order_fee_meta', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_add_order_fee_meta', $this->get_id(), $item_id, $item->legacy_fee, $item->legacy_fee_key );
|
||||
if ( isset( $item->legacy_fee, $item->legacy_fee_key ) ) {
|
||||
wc_do_deprecated_action( 'woocommerce_add_order_fee_meta', array( $this->get_id(), $item_id, $item->legacy_fee, $item->legacy_fee_key ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
}
|
||||
break;
|
||||
case 'shipping_lines' :
|
||||
if ( has_action( 'woocommerce_add_shipping_order_item' ) && isset( $item->legacy_package_key ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_add_shipping_order_item', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_add_shipping_order_item', $item_id, $item->legacy_package_key );
|
||||
if ( isset( $item->legacy_package_key ) ) {
|
||||
wc_do_deprecated_action( 'woocommerce_add_shipping_order_item', array( $item_id, $item->legacy_package_key ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
}
|
||||
break;
|
||||
case 'line_items' :
|
||||
if ( has_action( 'woocommerce_add_order_item_meta' ) && isset( $item->legacy_values, $item->legacy_cart_item_key ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_add_order_item_meta', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_add_order_item_meta', $item_id, $item->legacy_values, $item->legacy_cart_item_key );
|
||||
if ( isset( $item->legacy_values, $item->legacy_cart_item_key ) ) {
|
||||
wc_do_deprecated_action( 'woocommerce_add_order_item_meta', array( $item_id, $item->legacy_values, $item->legacy_cart_item_key ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -351,6 +361,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
return array_merge(
|
||||
$this->_data,
|
||||
array(
|
||||
'number' => $this->get_order_number(),
|
||||
'meta_data' => $this->get_meta_data(),
|
||||
'line_items' => $this->get_items( 'line_item' ),
|
||||
'tax_lines' => $this->get_items( 'tax' ),
|
||||
|
@ -423,14 +434,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
return $this->_data['prices_include_tax'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Order Type
|
||||
* @return string
|
||||
*/
|
||||
public function get_order_type() {
|
||||
return $this->_data['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date_created
|
||||
* @return int
|
||||
|
@ -675,14 +678,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Order Type
|
||||
* @param string $value
|
||||
*/
|
||||
public function set_order_type( $value ) {
|
||||
$this->_data['type'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order_key.
|
||||
* @param string $value Max length 20 chars.
|
||||
|
@ -704,6 +699,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* @param string $value
|
||||
*/
|
||||
public function set_currency( $value ) {
|
||||
if ( $value && ! in_array( $value, array_keys( get_woocommerce_currencies() ) ) ) {
|
||||
//$this->throw_exception( 'invalid_currency', 'Invalid currency code' );
|
||||
}
|
||||
$this->_data['currency'] = $value;
|
||||
}
|
||||
|
||||
|
@ -821,36 +819,54 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
if ( ! empty( $type ) ) {
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM itemmeta USING {$wpdb->prefix}woocommerce_order_itemmeta itemmeta INNER JOIN {$wpdb->prefix}woocommerce_order_items items WHERE itemmeta.order_item_id = items.order_item_id AND items.order_id = %d AND items.order_item_type = %s", $this->get_id(), $type ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s", $this->get_id(), $type ) );
|
||||
if ( $group = $this->type_to_group( $type ) ) {
|
||||
$this->_items[ $group ] = null;
|
||||
}
|
||||
} else {
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM itemmeta USING {$wpdb->prefix}woocommerce_order_itemmeta itemmeta INNER JOIN {$wpdb->prefix}woocommerce_order_items items WHERE itemmeta.order_item_id = items.order_item_id and items.order_id = %d", $this->get_id() ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d", $this->get_id() ) );
|
||||
$this->_items = array(
|
||||
'line_items' => null,
|
||||
'coupon_lines' => null,
|
||||
'shipping_lines' => null,
|
||||
'fee_lines' => null,
|
||||
'tax_lines' => null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a type to a types group.
|
||||
* @param string $type
|
||||
* @return string group
|
||||
*/
|
||||
protected function type_to_group( $type ) {
|
||||
$type_to_group = array(
|
||||
'line_item' => 'line_items',
|
||||
'tax' => 'tax_lines',
|
||||
'shipping' => 'shipping_lines',
|
||||
'fee' => 'fee_lines',
|
||||
'coupon' => 'coupon_lines',
|
||||
);
|
||||
return isset( $type_to_group[ $type ] ) ? $type_to_group[ $type ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of items/products within this order.
|
||||
* @param string|array $types Types of line items to get (array or string).
|
||||
* @return Array of WC_Order_item
|
||||
*/
|
||||
public function get_items( $types = 'line_item' ) {
|
||||
$type_to_group = array(
|
||||
'line_item' => 'line_items',
|
||||
'tax' => 'tax_lines',
|
||||
'shipping' => 'shipping_lines',
|
||||
'fee' => 'fee_lines',
|
||||
'coupon' => 'coupon_lines',
|
||||
);
|
||||
|
||||
$items = array();
|
||||
$types = array_filter( (array) $types );
|
||||
|
||||
foreach ( $types as $type ) {
|
||||
if ( isset( $type_to_group[ $type ] ) ) {
|
||||
if ( is_null( $this->_items[ $type_to_group[ $type ] ] ) ) {
|
||||
$this->_items[ $type_to_group[ $type ] ] = $this->get_items_from_db( $type );
|
||||
if ( $group = $this->type_to_group( $type ) ) {
|
||||
if ( is_null( $this->_items[ $group ] ) ) {
|
||||
$this->_items[ $group ] = $this->get_items_from_db( $type );
|
||||
}
|
||||
|
||||
$items = array_merge( $items, $this->_items[ $type_to_group[ $type ] ] );
|
||||
// Don't use array_merge here because keys are numeric
|
||||
$items = $items + $this->_items[ $group ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -938,7 +954,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$count = 0;
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$count += $item->get_qty();
|
||||
$count += $item->get_quantity();
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_get_item_count', $count, $item_type, $this );
|
||||
|
@ -954,68 +970,83 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
return WC_Order_Factory::get_order_item( $item_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key for where a certain item type is stored in _items.
|
||||
* @since 2.7.0
|
||||
* @param $item object Order item (product, shipping, fee, coupon, tax)
|
||||
* @return string
|
||||
*/
|
||||
protected function get_items_key( $item ) {
|
||||
if ( is_a( $item, 'WC_Order_Item_Product' ) ) {
|
||||
return 'line_items';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Fee' ) ) {
|
||||
return 'fee_lines';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Shipping' ) ) {
|
||||
return 'shipping_lines';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Tax' ) ) {
|
||||
return 'tax_lines';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Coupon' ) ) {
|
||||
return 'coupon_lines';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove item from the order.
|
||||
* @param int $item_id
|
||||
*/
|
||||
public function remove_item( $item_id ) {
|
||||
$item = $this->get_item( $item_id );
|
||||
|
||||
if ( ! $item || ! ( $items_key = $this->get_items_key( $item ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unset and remove later
|
||||
$this->_items_to_delete[] = $item;
|
||||
unset( $this->_items[ $items_key ][ $item->get_id() ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an order item to this order. The order item will not persist until save.
|
||||
* @param object Order item (product, shipping, fee, coupon, tax)
|
||||
*/
|
||||
public function add_item( $item ) {
|
||||
if ( is_a( $item, 'WC_Order_Item_Product' ) ) {
|
||||
$item_type = 'line_item';
|
||||
$items_key = 'line_items';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Fee' ) ) {
|
||||
$item_type = 'fee';
|
||||
$items_key = 'fee_lines';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Shipping' ) ) {
|
||||
$item_type = 'shipping';
|
||||
$items_key = 'shipping_lines';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Tax' ) ) {
|
||||
$item_type = 'tax';
|
||||
$items_key = 'tax_lines';
|
||||
} elseif ( is_a( $item, 'WC_Order_Item_Coupon' ) ) {
|
||||
$item_type = 'coupon';
|
||||
$items_key = 'coupon_lines';
|
||||
} else {
|
||||
if ( ! $items_key = $this->get_items_key( $item ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure existing items are loaded so we can append this new one.
|
||||
if ( is_null( $this->_items[ $items_key ] ) ) {
|
||||
$this->_items[ $items_key ] = $this->get_items( $item_type );
|
||||
$this->_items[ $items_key ] = $this->get_items( $item->get_type() );
|
||||
}
|
||||
|
||||
// Append new row with generated temporary ID
|
||||
$this->_items[ $items_key ][ 'new:' . md5( json_encode( $item ) ) ] = $item;
|
||||
if ( $item->get_id() ) {
|
||||
$this->_items[ $items_key ][ $item->get_id() ] = $item;
|
||||
} else {
|
||||
$this->_items[ $items_key ][ 'new:' . md5( json_encode( $item ) ) ] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a product line item to the order.
|
||||
* Order must be saved prior to adding items.
|
||||
* @param \WC_Product $product
|
||||
* @param array $args
|
||||
* @param array $deprecated qty was passed as arg 2 prior to 2.7.0
|
||||
* @param \WC_Product $product
|
||||
* @param int $qty
|
||||
* @param array $args
|
||||
* @return int order item ID
|
||||
*/
|
||||
public function add_product( $product, $args = array(), $deprecated = array() ) {
|
||||
if ( ! is_array( $args ) ) {
|
||||
_deprecated_argument( 'qty', '2.7', 'Pass only product and args' );
|
||||
$qty = $args;
|
||||
$args = $deprecated;
|
||||
$args['qty'] = $qty;
|
||||
}
|
||||
|
||||
if ( empty( $args['qty'] ) ) {
|
||||
$args['qty'] = 1;
|
||||
}
|
||||
|
||||
public function add_product( $product, $qty = 1, $args = array() ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'qty' => 1,
|
||||
'quantity' => $qty,
|
||||
'name' => $product ? $product->get_title() : '',
|
||||
'tax_class' => $product ? $product->get_tax_class() : '',
|
||||
'product_id' => $product ? $product->get_id() : '',
|
||||
'variation_id' => $product && isset( $product->variation_id ) ? $product->variation_id : 0,
|
||||
'variation' => $product && isset( $product->variation_id ) ? $product->get_variation_attributes() : array(),
|
||||
'subtotal' => $product ? $product->get_price_excluding_tax( $args['qty'] ) : '',
|
||||
'total' => $product ? $product->get_price_excluding_tax( $args['qty'] ) : '',
|
||||
'subtotal' => $product ? $product->get_price_excluding_tax( $qty ) : '',
|
||||
'total' => $product ? $product->get_price_excluding_tax( $qty ) : '',
|
||||
'subtotal_tax' => 0,
|
||||
'total_tax' => 0,
|
||||
'taxes' => array(
|
||||
|
@ -1038,63 +1069,36 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
}
|
||||
|
||||
$item = new WC_Order_Item_Product( $args );
|
||||
|
||||
// Handle backorders
|
||||
if ( $product->backorders_require_notification() && $product->is_on_backorder( $args['qty'] ) ) {
|
||||
$item->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ) ), $args['qty'] - max( 0, $product->get_total_stock() ), true );
|
||||
}
|
||||
|
||||
$item->set_order_id( $this->get_id() ? $this->get_id() : $this->save() );
|
||||
$item->set_backorder_meta();
|
||||
$item->set_order_id( $this->get_id() );
|
||||
$item->save();
|
||||
|
||||
if ( has_action( 'woocommerce_order_add_product' ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_order_add_product', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_order_add_product', $this->get_id(), $item->get_id(), $product, $qty, $args );
|
||||
}
|
||||
|
||||
$this->add_item( $item );
|
||||
wc_do_deprecated_action( 'woocommerce_order_add_product', array( $this->get_id(), $item->get_id(), $product, $qty, $args ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
return $item->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add coupon code to the order.
|
||||
* Order must be saved prior to adding items.
|
||||
* @param array $args
|
||||
* @param int $deprecated1 2.7.0 code, discount, tax were passed.
|
||||
* @param int $deprecated2 2.7.0 code, discount, tax were passed.
|
||||
* @param string $code
|
||||
* @param int $discount tax amount.
|
||||
* @param int $discount_tax amount.
|
||||
* @return int order item ID
|
||||
*/
|
||||
public function add_coupon( $args = array(), $deprecated1 = 0, $deprecated2 = 0 ) {
|
||||
if ( ! is_array( $args ) ) {
|
||||
_deprecated_argument( 'code', '2.7', 'Pass only an array of args' );
|
||||
$args = array(
|
||||
'code' => $args,
|
||||
'discount' => $deprecated1,
|
||||
'discount_tax' => $deprecated2,
|
||||
);
|
||||
}
|
||||
|
||||
$args = wp_parse_args( $args, array(
|
||||
'code' => '',
|
||||
'discount' => 0,
|
||||
'discount_tax' => 0,
|
||||
public function add_coupon( $code = array(), $discount = 0, $discount_tax = 0 ) {
|
||||
$item = new WC_Order_Item_Coupon( array(
|
||||
'code' => $code,
|
||||
'discount' => $discount,
|
||||
'discount_tax' => $discount_tax,
|
||||
) );
|
||||
|
||||
$item = new WC_Order_Item_Coupon( $args );
|
||||
$item->set_order_id( $this->get_id() ? $this->get_id() : $this->save() );
|
||||
$item->set_order_id( $this->get_id() );
|
||||
$item->save();
|
||||
|
||||
if ( has_action( 'woocommerce_order_add_coupon' ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_order_add_coupon', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_order_add_coupon', $this->get_id(), $item->get_id(), $args['code'], $args['discount'], $args['discount_tax'] );
|
||||
}
|
||||
|
||||
$this->add_item( $item );
|
||||
wc_do_deprecated_action( 'woocommerce_order_add_coupon', array( $this->get_id(), $item->get_id(), $code, $discount, $discount_tax ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
return $item->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a tax row to the order.
|
||||
* Order must be saved prior to adding items.
|
||||
* @since 2.2
|
||||
* @param array $args
|
||||
* @param int $deprecated1 2.7.0 tax_rate_id, amount, shipping amount.
|
||||
* @param int $deprecated2 2.7.0 tax_rate_id, amount, shipping amount.
|
||||
|
@ -1109,7 +1113,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
'shipping_tax_total' => $deprecated2,
|
||||
);
|
||||
}
|
||||
|
||||
$args = wp_parse_args( $args, array(
|
||||
'rate_id' => '',
|
||||
'tax_total' => 0,
|
||||
|
@ -1118,22 +1121,16 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
'label' => isset( $args['rate_id'] ) ? WC_Tax::get_rate_label( $args['rate_id'] ) : '',
|
||||
'compound' => isset( $args['rate_id'] ) ? WC_Tax::is_compound( $args['rate_id'] ) : '',
|
||||
) );
|
||||
|
||||
$item = new WC_Order_Item_Tax( $args );
|
||||
$item->set_order_id( $this->get_id() ? $this->get_id() : $this->save() );
|
||||
$item->set_order_id( $this->get_id() );
|
||||
$item->save();
|
||||
|
||||
if ( has_action( 'woocommerce_order_add_tax' ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_order_add_tax', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_order_add_tax', $this->get_id(), $item->get_id(), $args['rate_id'], $args['tax_total'], $args['shipping_tax_total'] );
|
||||
}
|
||||
|
||||
$this->add_item( $item );
|
||||
wc_do_deprecated_action( 'woocommerce_order_add_tax', array( $this->get_id(), $item->get_id(), $args['rate_id'], $args['tax_total'], $args['shipping_tax_total'] ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
return $item->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a shipping row to the order.
|
||||
* Order must be saved prior to adding items.
|
||||
* @param WC_Shipping_Rate shipping_rate
|
||||
* @return int order item ID
|
||||
*/
|
||||
|
@ -1145,14 +1142,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
'taxes' => $shipping_rate->taxes,
|
||||
'meta_data' => $shipping_rate->get_meta_data(),
|
||||
) );
|
||||
$item->set_order_id( $this->get_id() ? $this->get_id() : $this->save() );
|
||||
$item->set_order_id( $this->get_id() );
|
||||
$item->save();
|
||||
|
||||
if ( has_action( 'woocommerce_order_add_shipping' ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_order_add_shipping', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_order_add_shipping', $this->get_id(), $item->get_id(), $shipping_rate );
|
||||
}
|
||||
|
||||
$this->add_item( $item );
|
||||
wc_do_deprecated_action( 'woocommerce_order_add_shipping', array( $this->get_id(), $item->get_id(), $shipping_rate ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
return $item->get_id();
|
||||
}
|
||||
|
||||
|
@ -1172,18 +1165,22 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
'total' => $fee->tax_data,
|
||||
),
|
||||
) );
|
||||
|
||||
$item->set_order_id( $this->get_id() ? $this->get_id() : $this->save() );
|
||||
$item->set_order_id( $this->get_id() );
|
||||
$item->save();
|
||||
|
||||
if ( has_action( 'woocommerce_order_add_fee' ) ) {
|
||||
_deprecated_function( 'Action: woocommerce_order_add_fee', '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
do_action( 'woocommerce_order_add_fee', $this->get_id(), $item->get_id(), $fee );
|
||||
}
|
||||
|
||||
$this->add_item( $item );
|
||||
wc_do_deprecated_action( 'woocommerce_order_add_fee', array( $this->get_id(), $item->get_id(), $fee ), '2.7', 'Use woocommerce_new_order_item action instead.' );
|
||||
return $item->get_id();
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Payment Token Handling
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Payment tokens are hashes used to take payments by certain gateways.
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add a payment token to an order
|
||||
*
|
||||
|
@ -1416,10 +1413,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
// line items
|
||||
foreach ( $this->get_items() as $item ) {
|
||||
$cart_subtotal += wc_format_decimal( $item->get_subtotal() );
|
||||
$cart_total += wc_format_decimal( $item->get_total() );
|
||||
$cart_subtotal_tax += wc_format_decimal( $item->get_subtotal_tax() );
|
||||
$cart_total_tax += wc_format_decimal( $item->get_total_tax() );
|
||||
$cart_subtotal += $item->get_subtotal();
|
||||
$cart_total += $item->get_total();
|
||||
$cart_subtotal_tax += $item->get_subtotal_tax();
|
||||
$cart_total_tax += $item->get_total_tax();
|
||||
}
|
||||
|
||||
$this->calculate_shipping();
|
||||
|
@ -1451,9 +1448,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
if ( is_callable( array( $item, 'get_subtotal' ) ) ) {
|
||||
if ( $inc_tax ) {
|
||||
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_qty() );
|
||||
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_quantity() );
|
||||
} else {
|
||||
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_qty() ) );
|
||||
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_quantity() ) );
|
||||
}
|
||||
|
||||
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal;
|
||||
|
@ -1499,9 +1496,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
if ( is_callable( array( $item, 'get_total' ) ) ) {
|
||||
if ( $inc_tax ) {
|
||||
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_qty() );
|
||||
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_quantity() );
|
||||
} else {
|
||||
$total = $item->get_total() / max( 1, $item->get_qty() );
|
||||
$total = $item->get_total() / max( 1, $item->get_quantity() );
|
||||
}
|
||||
|
||||
$total = $round ? round( $total, wc_get_price_decimals() ) : $total;
|
||||
|
@ -1543,7 +1540,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$tax = 0;
|
||||
|
||||
if ( is_callable( array( $item, 'get_total_tax' ) ) ) {
|
||||
$tax = $item->get_total_tax() / max( 1, $item->get_qty() );
|
||||
$tax = $item->get_total_tax() / max( 1, $item->get_quantity() );
|
||||
$tax = $round ? wc_round_tax_total( $tax ) : $tax;
|
||||
}
|
||||
|
||||
|
|
|
@ -651,12 +651,12 @@ class WC_Admin_Post_Types {
|
|||
$item_meta_html = $item_meta->display( true, true );
|
||||
?>
|
||||
<tr class="<?php echo apply_filters( 'woocommerce_admin_order_item_class', '', $item, $the_order ); ?>">
|
||||
<td class="qty"><?php echo absint( $item['qty'] ); ?></td>
|
||||
<td class="qty"><?php echo esc_html( $item->get_quantity() ); ?></td>
|
||||
<td class="name">
|
||||
<?php if ( $product ) : ?>
|
||||
<?php echo ( wc_product_sku_enabled() && $product->get_sku() ) ? $product->get_sku() . ' - ' : ''; ?><a href="<?php echo get_edit_post_link( $product->id ); ?>" title="<?php echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false ); ?>"><?php echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false ); ?></a>
|
||||
<?php echo ( wc_product_sku_enabled() && $product->get_sku() ) ? $product->get_sku() . ' - ' : ''; ?><a href="<?php echo get_edit_post_link( $product->id ); ?>" title="<?php echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); ?>"><?php echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); ?></a>
|
||||
<?php else : ?>
|
||||
<?php echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false ); ?>
|
||||
<?php echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty( $item_meta_html ) ) : ?>
|
||||
<?php echo wc_help_tip( $item_meta_html ); ?>
|
||||
|
@ -2203,7 +2203,7 @@ class WC_Admin_Post_Types {
|
|||
foreach ( $existing_permissions as $existing_permission ) {
|
||||
$order = wc_get_order( $existing_permission->order_id );
|
||||
|
||||
if ( ! empty( $order->get_id() ) ) {
|
||||
if ( $order->get_id() ) {
|
||||
// Remove permissions
|
||||
if ( ! empty( $removed_download_ids ) ) {
|
||||
foreach ( $removed_download_ids as $download_id ) {
|
||||
|
|
|
@ -153,7 +153,7 @@ class WC_Meta_Box_Order_Data {
|
|||
$payment_gateways = array();
|
||||
}
|
||||
|
||||
$payment_method = ! empty( $order->get_payment_method() ) ? $order->get_payment_method() : '';
|
||||
$payment_method = $order->get_payment_method() ? $order->get_payment_method() : '';
|
||||
|
||||
$order_type_object = get_post_type_object( $post->post_type );
|
||||
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
|
||||
|
@ -219,7 +219,7 @@ class WC_Meta_Box_Order_Data {
|
|||
|
||||
<p class="form-field form-field-wide wc-customer-user">
|
||||
<label for="customer_user"><?php _e( 'Customer:', 'woocommerce' ) ?> <?php
|
||||
if ( ! empty( $order->get_user_id() ) ) {
|
||||
if ( $order->get_user_id() ) {
|
||||
$args = array( 'post_status' => 'all',
|
||||
'post_type' => 'shop_order',
|
||||
'_customer_user' => absint( $order->get_user_id() )
|
||||
|
@ -233,7 +233,7 @@ class WC_Meta_Box_Order_Data {
|
|||
<?php
|
||||
$user_string = '';
|
||||
$user_id = '';
|
||||
if ( ! empty( $order->get_user_id() ) ) {
|
||||
if ( $order->get_user_id() ) {
|
||||
$user_id = absint( $order->get_user_id() );
|
||||
$user = get_user_by( 'id', $user_id );
|
||||
$user_string = esc_html( $user->display_name ) . ' (#' . absint( $user->ID ) . ' – ' . esc_html( $user->user_email ) . ')';
|
||||
|
|
|
@ -10,17 +10,17 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
exit;
|
||||
}
|
||||
?>
|
||||
<tr class="fee <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<tr class="fee <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
|
||||
<td class="thumb"><div></div></td>
|
||||
|
||||
<td class="name">
|
||||
<div class="view">
|
||||
<?php echo ! empty( $item['name'] ) ? esc_html( $item['name'] ) : __( 'Fee', 'woocommerce' ); ?>
|
||||
<?php echo esc_html( $item->get_name() ? $item->get_name() : __( 'Fee', 'woocommerce' ) ); ?>
|
||||
</div>
|
||||
<div class="edit" style="display: none;">
|
||||
<input type="text" placeholder="<?php esc_attr_e( 'Fee Name', 'woocommerce' ); ?>" name="order_item_name[<?php echo absint( $item_id ); ?>]" value="<?php echo ( isset( $item['name'] ) ) ? esc_attr( $item['name'] ) : ''; ?>" />
|
||||
<input type="text" placeholder="<?php esc_attr_e( 'Fee Name', 'woocommerce' ); ?>" name="order_item_name[<?php echo absint( $item_id ); ?>]" value="<?php echo ( $item->get_name() ) ? esc_attr( $item->get_name() ) : ''; ?>" />
|
||||
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo isset( $item['tax_class'] ) ? esc_attr( $item['tax_class'] ) : ''; ?>" />
|
||||
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" />
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
@ -32,15 +32,15 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<td class="line_cost" width="1%">
|
||||
<div class="view">
|
||||
<?php
|
||||
echo ( isset( $item['line_total'] ) ) ? wc_price( wc_round_tax_total( $item['line_total'] ) ) : '';
|
||||
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
|
||||
|
||||
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'fee' ) ) {
|
||||
echo '<small class="refunded">-' . wc_price( $refunded ) . '</small>';
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="edit" style="display: none;">
|
||||
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $item['line_total'] ) ) ? esc_attr( wc_format_localized_price( $item['line_total'] ) ) : ''; ?>" class="line_total wc_input_price" />
|
||||
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
|
||||
</div>
|
||||
<div class="refund" style="display: none;">
|
||||
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_total wc_input_price" />
|
||||
|
@ -48,21 +48,18 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
</td>
|
||||
|
||||
<?php
|
||||
if ( empty( $legacy_order ) && wc_tax_enabled() ) :
|
||||
$line_tax_data = isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '';
|
||||
$tax_data = maybe_unserialize( $line_tax_data );
|
||||
|
||||
foreach ( $order_taxes as $tax_item ) :
|
||||
$tax_item_id = $tax_item['rate_id'];
|
||||
$tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
|
||||
if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) {
|
||||
foreach ( $order_taxes as $tax_item ) {
|
||||
$tax_item_id = $tax_item->get_rate_id();
|
||||
$tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
|
||||
?>
|
||||
<td class="line_tax" width="1%">
|
||||
<div class="view">
|
||||
<?php
|
||||
echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ) ) : '–';
|
||||
echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '–';
|
||||
|
||||
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) {
|
||||
echo '<small class="refunded">-' . wc_price( $refunded ) . '</small>';
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -75,10 +72,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
</td>
|
||||
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<td class="wc-order-edit-line-item">
|
||||
<?php if ( $order->is_editable() ) : ?>
|
||||
<div class="wc-order-edit-line-item-actions">
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
?>
|
||||
<tr data-meta_id="<?php echo esc_attr( $meta_id ); ?>">
|
||||
<td>
|
||||
<input type="text" name="meta_key[<?php echo esc_attr( $meta_id ); ?>]" value="<?php echo esc_attr( $meta->key ); ?>" />
|
||||
<textarea name="meta_value[<?php echo esc_attr( $meta_id ); ?>]"><?php echo esc_textarea( rawurldecode( $meta->value ) ); ?></textarea>
|
||||
<input type="text" name="meta_key[<?php echo esc_attr( $item_id ); ?>][<?php echo esc_attr( $meta_id ); ?>]" value="<?php echo esc_attr( $meta->key ); ?>" />
|
||||
<textarea name="meta_value[<?php echo esc_attr( $item_id ); ?>][<?php echo esc_attr( $meta_id ); ?>]"><?php echo esc_textarea( rawurldecode( $meta->value ) ); ?></textarea>
|
||||
</td>
|
||||
<td width="1%"><button class="remove_order_item_meta button">×</button></td>
|
||||
</tr>
|
||||
|
|
|
@ -5,60 +5,52 @@
|
|||
* @var object $item The item being displayed
|
||||
* @var int $item_id The id of the item being displayed
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$_product = $order->get_product_from_item( $item );
|
||||
$product_link = $_product ? admin_url( 'post.php?post=' . absint( $_product->id ) . '&action=edit' ) : '';
|
||||
$thumbnail = $_product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $_product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : '';
|
||||
$tax_data = empty( $legacy_order ) && wc_tax_enabled() ? maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' ) : false;
|
||||
$item_total = ( isset( $item['line_total'] ) ) ? esc_attr( wc_format_localized_price( $item['line_total'] ) ) : '';
|
||||
$item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_localized_price( $item['line_subtotal'] ) ) : '';
|
||||
$product = $item->get_product();
|
||||
$product_link = $product ? admin_url( 'post.php?post=' . $product->get_id() . '&action=edit' ) : '';
|
||||
$thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : '';
|
||||
?>
|
||||
<tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item, $order ); ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item, $order ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
|
||||
<td class="thumb">
|
||||
<?php
|
||||
echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>';
|
||||
?>
|
||||
<?php echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>'; ?>
|
||||
</td>
|
||||
<td class="name" data-sort-value="<?php echo esc_attr( $item['name'] ); ?>">
|
||||
<td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>">
|
||||
<?php
|
||||
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item['name'] ) . '</a>' : '<div class="class="wc-order-item-name"">' . esc_html( $item['name'] ) . '</div>';
|
||||
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class="class="wc-order-item-name"">' . esc_html( $item->get_name() ) . '</div>';
|
||||
|
||||
if ( $_product && $_product->get_sku() ) {
|
||||
echo '<div class="wc-order-item-sku"><strong>' . __( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $_product->get_sku() ) . '</div>';
|
||||
if ( $product && $product->get_sku() ) {
|
||||
echo '<div class="wc-order-item-sku"><strong>' . __( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>';
|
||||
}
|
||||
|
||||
if ( ! empty( $item['variation_id'] ) ) {
|
||||
if ( $item->get_variation_id() ) {
|
||||
echo '<div class="wc-order-item-variation"><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ';
|
||||
if ( ! empty( $item['variation_id'] ) && 'product_variation' === get_post_type( $item['variation_id'] ) ) {
|
||||
echo esc_html( $item['variation_id'] );
|
||||
} elseif ( ! empty( $item['variation_id'] ) ) {
|
||||
echo esc_html( $item['variation_id'] ) . ' (' . __( 'No longer exists', 'woocommerce' ) . ')';
|
||||
if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) {
|
||||
echo esc_html( $item->get_variation_id() );
|
||||
} else {
|
||||
echo esc_html( $item->get_variation_id() ) . ' (' . __( 'No longer exists', 'woocommerce' ) . ')';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo isset( $item['tax_class'] ) ? esc_attr( $item['tax_class'] ) : ''; ?>" />
|
||||
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" />
|
||||
|
||||
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $_product ) ?>
|
||||
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ) ?>
|
||||
<?php include( 'html-order-item-meta.php' ); ?>
|
||||
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $_product ) ?>
|
||||
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ) ?>
|
||||
</td>
|
||||
|
||||
<?php do_action( 'woocommerce_admin_order_item_values', $_product, $item, absint( $item_id ) ); ?>
|
||||
<?php do_action( 'woocommerce_admin_order_item_values', $product, $item, absint( $item_id ) ); ?>
|
||||
|
||||
<td class="item_cost" width="1%" data-sort-value="<?php echo esc_attr( $order->get_item_subtotal( $item, false, true ) ); ?>">
|
||||
<div class="view">
|
||||
<?php
|
||||
if ( isset( $item['line_total'] ) ) {
|
||||
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) );
|
||||
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) );
|
||||
|
||||
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] != $item['line_total'] ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
if ( $item->get_subtotal() !== $item->get_total() ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -66,7 +58,7 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
<td class="quantity" width="1%">
|
||||
<div class="view">
|
||||
<?php
|
||||
echo '<small class="times">×</small> ' . ( isset( $item['qty'] ) ? esc_html( $item['qty'] ) : '1' );
|
||||
echo '<small class="times">×</small> ' . esc_html( $item->get_quantity() );
|
||||
|
||||
if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) {
|
||||
echo '<small class="refunded">' . ( $refunded_qty * -1 ) . '</small>';
|
||||
|
@ -74,22 +66,19 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
?>
|
||||
</div>
|
||||
<div class="edit" style="display: none;">
|
||||
<?php $item_qty = esc_attr( $item['qty'] ); ?>
|
||||
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $_product ); ?>" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo $item_qty; ?>" data-qty="<?php echo $item_qty; ?>" size="4" class="quantity" />
|
||||
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $product ); ?>" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo esc_attr( $item->get_quantity() ); ?>" data-qty="<?php echo esc_attr( $item->get_quantity() ); ?>" size="4" class="quantity" />
|
||||
</div>
|
||||
<div class="refund" style="display: none;">
|
||||
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $_product ); ?>" min="0" max="<?php echo $item['qty']; ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" />
|
||||
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $product ); ?>" min="0" max="<?php echo $item->get_quantity(); ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" />
|
||||
</div>
|
||||
</td>
|
||||
<td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( isset( $item['line_total'] ) ? $item['line_total'] : '' ); ?>">
|
||||
<td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>">
|
||||
<div class="view">
|
||||
<?php
|
||||
if ( isset( $item['line_total'] ) ) {
|
||||
echo wc_price( $item['line_total'], array( 'currency' => $order->get_currency() ) );
|
||||
}
|
||||
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
|
||||
|
||||
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] !== $item['line_total'] ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item['line_subtotal'] - $item['line_total'], '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
if ( $item->get_subtotal() !== $item->get_total() ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) {
|
||||
|
@ -101,11 +90,11 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
<div class="split-input">
|
||||
<div class="input">
|
||||
<label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label>
|
||||
<input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo $item_subtotal; ?>" class="line_subtotal wc_input_price" data-subtotal="<?php echo $item_subtotal; ?>" />
|
||||
<input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( $item->get_subtotal() ); ?>" class="line_subtotal wc_input_price" data-subtotal="<?php echo esc_attr( $item->get_subtotal() ); ?>" />
|
||||
</div>
|
||||
<div class="input">
|
||||
<label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label>
|
||||
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo $item_total; ?>" class="line_total wc_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo $item_total; ?>" />
|
||||
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( $item->get_total() ); ?>" class="line_total wc_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo esc_attr( $item->get_total() ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -115,9 +104,9 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
</td>
|
||||
|
||||
<?php
|
||||
if ( ! empty( $tax_data ) ) {
|
||||
if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) {
|
||||
foreach ( $order_taxes as $tax_item ) {
|
||||
$tax_item_id = $tax_item['rate_id'];
|
||||
$tax_item_id = $tax_item->get_rate_id();
|
||||
$tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
|
||||
$tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : '';
|
||||
?>
|
||||
|
@ -130,7 +119,7 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
echo '–';
|
||||
}
|
||||
|
||||
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] !== $item['line_total'] ) {
|
||||
if ( $item->get_subtotal() !== $item->get_total() ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
|
||||
|
@ -159,7 +148,6 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<td class="wc-order-edit-line-item" width="1%">
|
||||
<div class="wc-order-edit-line-item-actions">
|
||||
<?php if ( $order->is_editable() ) : ?>
|
||||
|
|
|
@ -26,21 +26,7 @@ if ( wc_tax_enabled() ) {
|
|||
}
|
||||
}
|
||||
|
||||
// Older orders won't have line taxes so we need to handle them differently :(
|
||||
$tax_data = '';
|
||||
if ( $line_items ) {
|
||||
$check_item = current( $line_items );
|
||||
$tax_data = maybe_unserialize( isset( $check_item['line_tax_data'] ) ? $check_item['line_tax_data'] : '' );
|
||||
} elseif ( $line_items_shipping ) {
|
||||
$check_item = current( $line_items_shipping );
|
||||
$tax_data = maybe_unserialize( isset( $check_item['taxes'] ) ? $check_item['taxes'] : '' );
|
||||
} elseif ( $line_items_fee ) {
|
||||
$check_item = current( $line_items_fee );
|
||||
$tax_data = maybe_unserialize( isset( $check_item['line_tax_data'] ) ? $check_item['line_tax_data'] : '' );
|
||||
}
|
||||
|
||||
$legacy_order = ! empty( $order_taxes ) && empty( $tax_data ) && ! is_array( $tax_data );
|
||||
$show_tax_columns = ! $legacy_order || sizeof( $order_taxes ) === 1;
|
||||
$show_tax_columns = sizeof( $order_taxes ) === 1;
|
||||
}
|
||||
?>
|
||||
<div class="woocommerce_order_items_wrapper wc-order-items-editable">
|
||||
|
@ -53,7 +39,7 @@ if ( wc_tax_enabled() ) {
|
|||
<th class="quantity sortable" data-sort="int"><?php _e( 'Qty', 'woocommerce' ); ?></th>
|
||||
<th class="line_cost sortable" data-sort="float"><?php _e( 'Total', 'woocommerce' ); ?></th>
|
||||
<?php
|
||||
if ( empty( $legacy_order ) && ! empty( $order_taxes ) ) :
|
||||
if ( ! empty( $order_taxes ) ) :
|
||||
foreach ( $order_taxes as $tax_id => $tax_item ) :
|
||||
$tax_class = wc_get_tax_class_by_tax_id( $tax_item['rate_id'] );
|
||||
$tax_class_name = isset( $classes_options[ $tax_class ] ) ? $classes_options[ $tax_class ] : __( 'Tax', 'woocommerce' );
|
||||
|
|
|
@ -36,7 +36,7 @@ $who_refunded = new WP_User( $refund->post->post_author );
|
|||
</div>
|
||||
</td>
|
||||
|
||||
<?php if ( ( ! isset( $legacy_order ) || ! $legacy_order ) && wc_tax_enabled() ) : for ( $i = 0; $i < count( $order_taxes ); $i++ ) : ?>
|
||||
<?php if ( wc_tax_enabled() ) : for ( $i = 0; $i < count( $order_taxes ); $i++ ) : ?>
|
||||
<td class="line_tax" width="1%"></td>
|
||||
<?php endfor; endif; ?>
|
||||
|
||||
|
|
|
@ -5,21 +5,20 @@
|
|||
* @var object $item The item being displayed
|
||||
* @var int $item_id The id of the item being displayed
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<tr class="shipping <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<tr class="shipping <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
|
||||
<td class="thumb"><div></div></td>
|
||||
|
||||
<td class="name">
|
||||
<div class="view">
|
||||
<?php echo ! empty( $item['name'] ) ? wc_clean( $item['name'] ) : __( 'Shipping', 'woocommerce' ); ?>
|
||||
<?php echo esc_html( $item->get_name() ? $item->get_name() : __( 'Shipping', 'woocommerce' ) ); ?>
|
||||
</div>
|
||||
<div class="edit" style="display: none;">
|
||||
<input type="hidden" name="shipping_method_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
<input type="text" class="shipping_method_name" placeholder="<?php esc_attr_e( 'Shipping Name', 'woocommerce' ); ?>" name="shipping_method_title[<?php echo $item_id; ?>]" value="<?php echo ( isset( $item['name'] ) ) ? wc_clean( $item['name'] ) : ''; ?>" />
|
||||
<input type="text" class="shipping_method_name" placeholder="<?php esc_attr_e( 'Shipping Name', 'woocommerce' ); ?>" name="shipping_method_title[<?php echo esc_attr( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_name() ); ?>" />
|
||||
<select class="shipping_method" name="shipping_method[<?php echo esc_attr( $item_id ); ?>]">
|
||||
<optgroup label="<?php esc_attr_e( 'Shipping Method', 'woocommerce' ); ?>">
|
||||
<option value=""><?php _e( 'N/A', 'woocommerce' ); ?></option>
|
||||
|
@ -27,18 +26,17 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
$found_method = false;
|
||||
|
||||
foreach ( $shipping_methods as $method ) {
|
||||
$method_id = isset( $item['method_id'] ) ? $item['method_id'] : '';
|
||||
$current_method = ( 0 === strpos( $method_id, $method->id ) ) ? $method_id : $method->id;
|
||||
$current_method = ( 0 === strpos( $item->get_method_id(), $method->id ) ) ? $item->get_method_id() : $method->id;
|
||||
|
||||
echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $method_id == $current_method, true, false ) . '>' . esc_html( $method->get_title() ) . '</option>';
|
||||
echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $item->get_method_id() === $current_method, true, false ) . '>' . esc_html( $method->get_method_title() ) . '</option>';
|
||||
|
||||
if ( $method_id == $current_method ) {
|
||||
if ( $item->get_method_id() === $current_method ) {
|
||||
$found_method = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $found_method && ! empty( $method_id ) ) {
|
||||
echo '<option value="' . esc_attr( $method_id ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
if ( ! $found_method && $item->get_method_id() ) {
|
||||
echo '<option value="' . esc_attr( $item->get_method_id() ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
} else {
|
||||
echo '<option value="other">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
}
|
||||
|
@ -60,7 +58,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<td class="line_cost" width="1%">
|
||||
<div class="view">
|
||||
<?php
|
||||
echo ( isset( $item['cost'] ) ) ? wc_price( wc_round_tax_total( $item['cost'] ), array( 'currency' => $order->get_currency() ) ) : '';
|
||||
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
|
||||
|
||||
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' ) ) {
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
|
@ -68,7 +66,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
?>
|
||||
</div>
|
||||
<div class="edit" style="display: none;">
|
||||
<input type="text" name="shipping_cost[<?php echo $item_id; ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $item['cost'] ) ) ? esc_attr( wc_format_localized_price( $item['cost'] ) ) : ''; ?>" class="line_total wc_input_price" />
|
||||
<input type="text" name="shipping_cost[<?php echo esc_attr( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
|
||||
</div>
|
||||
<div class="refund" style="display: none;">
|
||||
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_total wc_input_price" />
|
||||
|
@ -76,13 +74,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
</td>
|
||||
|
||||
<?php
|
||||
if ( empty( $legacy_order ) && wc_tax_enabled() ) :
|
||||
$shipping_taxes = isset( $item['taxes'] ) ? $item['taxes'] : '';
|
||||
$tax_data = maybe_unserialize( $shipping_taxes );
|
||||
|
||||
foreach ( $order_taxes as $tax_item ) :
|
||||
$tax_item_id = $tax_item['rate_id'];
|
||||
$tax_item_total = isset( $tax_data[ $tax_item_id ] ) ? $tax_data[ $tax_item_id ] : '';
|
||||
if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) {
|
||||
foreach ( $order_taxes as $tax_item ) {
|
||||
$tax_item_id = $tax_item->get_rate_id();
|
||||
$tax_item_total = isset( $tax_data[ $tax_item_id ] ) ? $tax_data[ $tax_item_id ] : '';
|
||||
?>
|
||||
<td class="line_tax" width="1%">
|
||||
<div class="view">
|
||||
|
@ -101,12 +96,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<td class="wc-order-edit-line-item">
|
||||
<?php if ( $order->is_editable() ) : ?>
|
||||
<div class="wc-order-edit-line-item-actions">
|
||||
|
|
|
@ -175,7 +175,7 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
array(
|
||||
'title' => __( 'Product Images', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'desc' => sprintf( __( 'These settings affect the display and dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a href="%s">regenerate your thumbnails</a>.', 'woocommerce' ), 'https://wordpress.org/extend/plugins/regenerate-thumbnails/' ),
|
||||
'desc' => sprintf( __( 'These settings affect the display and dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a target="_blank" href="%s">regenerate your thumbnails</a>.', 'woocommerce' ), 'https://wordpress.org/extend/plugins/regenerate-thumbnails/' ),
|
||||
'id' => 'image_options'
|
||||
),
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
}
|
||||
?>
|
||||
<input type="hidden" name="range" value="custom" />
|
||||
<input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['start_date'] ) ) echo esc_attr( $_GET['start_date'] ); ?>" name="start_date" class="range_datepicker from" />
|
||||
<input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['end_date'] ) ) echo esc_attr( $_GET['end_date'] ); ?>" name="end_date" class="range_datepicker to" />
|
||||
<input type="text" size="11" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['start_date'] ) ) echo esc_attr( $_GET['start_date'] ); ?>" name="start_date" class="range_datepicker from" />
|
||||
<span>–</span>
|
||||
<input type="text" size="11" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['end_date'] ) ) echo esc_attr( $_GET['end_date'] ); ?>" name="end_date" class="range_datepicker to" />
|
||||
<input type="submit" class="button" value="<?php esc_attr_e( 'Go', 'woocommerce' ); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -171,7 +171,7 @@ function woocommerce_settings_get_option( $option_name, $default = '' ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Save order items.
|
||||
* Save order items. Uses the CRUD.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param int $order_id Order ID
|
||||
|
@ -181,200 +181,74 @@ function wc_save_order_items( $order_id, $items ) {
|
|||
// Allow other plugins to check change in order items before they are saved
|
||||
do_action( 'woocommerce_before_save_order_items', $order_id, $items );
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Order items + fees
|
||||
$subtotal = 0;
|
||||
$total = 0;
|
||||
$subtotal_tax = 0;
|
||||
$total_tax = 0;
|
||||
$taxes = array( 'items' => array(), 'shipping' => array() );
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
// Line items and fees
|
||||
if ( isset( $items['order_item_id'] ) ) {
|
||||
$line_total = $line_subtotal = $line_tax = $line_subtotal_tax = array();
|
||||
|
||||
foreach ( $items['order_item_id'] as $item_id ) {
|
||||
|
||||
$item_id = absint( $item_id );
|
||||
|
||||
if ( isset( $items['order_item_name'][ $item_id ] ) ) {
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . 'woocommerce_order_items',
|
||||
array( 'order_item_name' => wc_clean( wp_unslash( $items['order_item_name'][ $item_id ] ) ) ),
|
||||
array( 'order_item_id' => $item_id ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
if ( ! $item = $order->get_item( absint( $item_id ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $items['order_item_qty'][ $item_id ] ) ) {
|
||||
wc_update_order_item_meta( $item_id, '_qty', wc_stock_amount( $items['order_item_qty'][ $item_id ] ) );
|
||||
if ( isset( $items['order_item_name'][ $item_id ] ) ) {
|
||||
$item->set_name( wc_clean( wp_unslash( $items['order_item_name'][ $item_id ] ) ) );
|
||||
}
|
||||
|
||||
if ( isset( $items['order_item_qty'][ $item_id ] ) && is_callable( array( $item, 'set_quantity' ) ) ) {
|
||||
$item->set_quantity( $items['order_item_qty'][ $item_id ] );
|
||||
}
|
||||
|
||||
if ( isset( $items['order_item_tax_class'][ $item_id ] ) ) {
|
||||
wc_update_order_item_meta( $item_id, '_tax_class', wc_clean( $items['order_item_tax_class'][ $item_id ] ) );
|
||||
$item->set_tax_class( wc_clean( $items['order_item_tax_class'][ $item_id ] ) );
|
||||
}
|
||||
|
||||
// Get values. Subtotals might not exist, in which case copy value from total field
|
||||
$line_total[ $item_id ] = isset( $items['line_total'][ $item_id ] ) ? $items['line_total'][ $item_id ] : 0;
|
||||
$line_subtotal[ $item_id ] = isset( $items['line_subtotal'][ $item_id ] ) ? $items['line_subtotal'][ $item_id ] : $line_total[ $item_id ];
|
||||
$line_tax[ $item_id ] = isset( $items['line_tax'][ $item_id ] ) ? $items['line_tax'][ $item_id ] : array();
|
||||
$line_subtotal_tax[ $item_id ] = isset( $items['line_subtotal_tax'][ $item_id ] ) ? $items['line_subtotal_tax'][ $item_id ] : $line_tax[ $item_id ];
|
||||
if ( isset( $items['meta_key'][ $item_id ], $items['meta_value'][ $item_id ] ) ) {
|
||||
foreach ( $items['meta_key'][ $item_id ] as $meta_id => $meta_key ) {
|
||||
$meta_value = isset( $items['meta_value'][ $item_id ][ $meta_id ] ) ? $items['meta_value'][ $item_id ][ $meta_id ] : '';
|
||||
|
||||
// Format taxes
|
||||
$line_taxes = array_map( 'wc_format_decimal', $line_tax[ $item_id ] );
|
||||
$line_subtotal_taxes = array_map( 'wc_format_decimal', $line_subtotal_tax[ $item_id ] );
|
||||
if ( strstr( $meta_id, 'new-' ) ) {
|
||||
if ( $meta_key === '' && $meta_value === '' ) {
|
||||
continue;
|
||||
}
|
||||
$item->add_meta_data( $meta_key, $meta_value, false );
|
||||
} elseif ( $meta_key === '' && $meta_value === '' ) {
|
||||
$item->delete_meta_data_by_mid( $meta_id );
|
||||
} else {
|
||||
$item->update_meta_data( $meta_key, $meta_value, $meta_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update values
|
||||
wc_update_order_item_meta( $item_id, '_line_subtotal', wc_format_decimal( $line_subtotal[ $item_id ] ) );
|
||||
wc_update_order_item_meta( $item_id, '_line_total', wc_format_decimal( $line_total[ $item_id ] ) );
|
||||
wc_update_order_item_meta( $item_id, '_line_subtotal_tax', array_sum( $line_subtotal_taxes ) );
|
||||
wc_update_order_item_meta( $item_id, '_line_tax', array_sum( $line_taxes ) );
|
||||
|
||||
// Save line tax data - Since 2.2
|
||||
wc_update_order_item_meta( $item_id, '_line_tax_data', array( 'total' => $line_taxes, 'subtotal' => $line_subtotal_taxes ) );
|
||||
$taxes['items'][] = $line_taxes;
|
||||
|
||||
// Total up
|
||||
$subtotal += wc_format_decimal( $line_subtotal[ $item_id ] );
|
||||
$total += wc_format_decimal( $line_total[ $item_id ] );
|
||||
$subtotal_tax += array_sum( $line_subtotal_taxes );
|
||||
$total_tax += array_sum( $line_taxes );
|
||||
|
||||
// Clear meta cache
|
||||
wp_cache_delete( $item_id, 'order_item_meta' );
|
||||
}
|
||||
}
|
||||
|
||||
// Save meta
|
||||
$meta_keys = isset( $items['meta_key'] ) ? $items['meta_key'] : array();
|
||||
$meta_values = isset( $items['meta_value'] ) ? $items['meta_value'] : array();
|
||||
|
||||
foreach ( $meta_keys as $id => $meta_key ) {
|
||||
$meta_value = ( empty( $meta_values[ $id ] ) && ! is_numeric( $meta_values[ $id ] ) ) ? '' : $meta_values[ $id ];
|
||||
|
||||
// Delele blank item meta entries
|
||||
if ( $meta_key === '' && $meta_value === '' ) {
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_id = %d", $id ) );
|
||||
} else {
|
||||
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . 'woocommerce_order_itemmeta',
|
||||
array(
|
||||
'meta_key' => wp_unslash( $meta_key ),
|
||||
'meta_value' => wp_unslash( $meta_value )
|
||||
),
|
||||
array( 'meta_id' => $id ),
|
||||
array( '%s', '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
$line_tax = isset( $items['line_tax'][ $item_id ] ) ? $items['line_tax'][ $item_id ]: array();
|
||||
$line_subtotal_tax = isset( $items['line_subtotal_tax'][ $item_id ] ) ? $items['line_subtotal_tax'][ $item_id ]: $line_tax;
|
||||
$item->set_total( isset( $items['line_total'][ $item_id ] ) ? $items['line_total'][ $item_id ] : 0 );
|
||||
$item->set_subtotal( isset( $items['line_subtotal'][ $item_id ] ) ? $items['line_subtotal'][ $item_id ] : $item->get_total() );
|
||||
$item->set_total_tax( array_sum( $line_tax ) );
|
||||
$item->set_subtotal_tax( array_sum( $line_subtotal_tax ) );
|
||||
$item->set_taxes( array( 'total' => $line_tax, 'subtotal' => $line_subtotal_tax ) );
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Shipping Rows
|
||||
$order_shipping = 0;
|
||||
|
||||
if ( isset( $items['shipping_method_id'] ) ) {
|
||||
|
||||
foreach ( $items['shipping_method_id'] as $item_id ) {
|
||||
$item_id = absint( $item_id );
|
||||
$method_id = isset( $items['shipping_method'][ $item_id ] ) ? wc_clean( $items['shipping_method'][ $item_id ] ) : '';
|
||||
$method_title = isset( $items['shipping_method_title'][ $item_id ] ) ? wc_clean( wp_unslash( $items['shipping_method_title'][ $item_id ] ) ) : '';
|
||||
$cost = isset( $items['shipping_cost'][ $item_id ] ) ? wc_format_decimal( $items['shipping_cost'][ $item_id ] ) : '';
|
||||
$ship_taxes = isset( $items['shipping_taxes'][ $item_id ] ) ? array_map( 'wc_format_decimal', $items['shipping_taxes'][ $item_id ] ) : array();
|
||||
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . 'woocommerce_order_items',
|
||||
array( 'order_item_name' => $method_title ),
|
||||
array( 'order_item_id' => $item_id ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
|
||||
wc_update_order_item_meta( $item_id, 'method_id', $method_id );
|
||||
wc_update_order_item_meta( $item_id, 'cost', $cost );
|
||||
wc_update_order_item_meta( $item_id, 'taxes', $ship_taxes );
|
||||
|
||||
$taxes['shipping'][] = $ship_taxes;
|
||||
|
||||
$order_shipping += $cost;
|
||||
}
|
||||
}
|
||||
|
||||
// Taxes
|
||||
$order_taxes = isset( $items['order_taxes'] ) ? $items['order_taxes'] : array();
|
||||
$taxes_items = array();
|
||||
$taxes_shipping = array();
|
||||
$total_tax = 0;
|
||||
$total_shipping_tax = 0;
|
||||
|
||||
// Sum items taxes
|
||||
foreach ( $taxes['items'] as $rates ) {
|
||||
|
||||
foreach ( $rates as $id => $value ) {
|
||||
|
||||
if ( isset( $taxes_items[ $id ] ) ) {
|
||||
$taxes_items[ $id ] += $value;
|
||||
} else {
|
||||
$taxes_items[ $id ] = $value;
|
||||
if ( ! $item = $order->get_item( absint( $item_id ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$item->set_method_id( isset( $items['shipping_method'][ $item_id ] ) ? wc_clean( $items['shipping_method'][ $item_id ] ) : '' );
|
||||
$item->set_method_title( isset( $items['shipping_method_title'][ $item_id ] ) ? wc_clean( wp_unslash( $items['shipping_method_title'][ $item_id ] ) ) : '' );
|
||||
$item->set_total( isset( $items['shipping_cost'][ $item_id ] ) ? $items['shipping_cost'][ $item_id ] : '' );
|
||||
$item->set_taxes( isset( $items['shipping_taxes'][ $item_id ] ) ? $items['shipping_taxes'][ $item_id ] : array() );
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Sum shipping taxes
|
||||
foreach ( $taxes['shipping'] as $rates ) {
|
||||
// Updates tax totals
|
||||
$order->update_taxes();
|
||||
|
||||
foreach ( $rates as $id => $value ) {
|
||||
|
||||
if ( isset( $taxes_shipping[ $id ] ) ) {
|
||||
$taxes_shipping[ $id ] += $value;
|
||||
} else {
|
||||
$taxes_shipping[ $id ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update order taxes
|
||||
foreach ( $order_taxes as $item_id => $rate_id ) {
|
||||
|
||||
if ( isset( $taxes_items[ $rate_id ] ) ) {
|
||||
$_total = wc_format_decimal( $taxes_items[ $rate_id ] );
|
||||
wc_update_order_item_meta( $item_id, 'tax_amount', $_total );
|
||||
|
||||
$total_tax += $_total;
|
||||
}
|
||||
|
||||
if ( isset( $taxes_shipping[ $rate_id ] ) ) {
|
||||
$_total = wc_format_decimal( $taxes_shipping[ $rate_id ] );
|
||||
wc_update_order_item_meta( $item_id, 'shipping_tax_amount', $_total );
|
||||
|
||||
$total_shipping_tax += $_total;
|
||||
}
|
||||
}
|
||||
|
||||
// Update order shipping total
|
||||
update_post_meta( $order_id, '_order_shipping', $order_shipping );
|
||||
|
||||
// Update cart discount from item totals
|
||||
update_post_meta( $order_id, '_cart_discount', $subtotal - $total );
|
||||
update_post_meta( $order_id, '_cart_discount_tax', $subtotal_tax - $total_tax );
|
||||
|
||||
// Update totals
|
||||
update_post_meta( $order_id, '_order_total', wc_format_decimal( $items['_order_total'] ) );
|
||||
|
||||
// Update tax
|
||||
update_post_meta( $order_id, '_order_tax', wc_format_decimal( $total_tax ) );
|
||||
update_post_meta( $order_id, '_order_shipping_tax', wc_format_decimal( $total_shipping_tax ) );
|
||||
|
||||
// Remove old values
|
||||
delete_post_meta( $order_id, '_shipping_method' );
|
||||
delete_post_meta( $order_id, '_shipping_method_title' );
|
||||
|
||||
// Set the currency
|
||||
add_post_meta( $order_id, '_order_currency', get_woocommerce_currency(), true );
|
||||
|
||||
// Update version after saving
|
||||
update_post_meta( $order_id, '_order_version', WC_VERSION );
|
||||
// Calc totals - this also triggers save
|
||||
$order->calculate_totals( false );
|
||||
|
||||
// Inform other plugins that the items have been saved
|
||||
do_action( 'woocommerce_saved_order_items', $order_id, $items );
|
||||
|
|
|
@ -130,45 +130,29 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
// Add line items.
|
||||
foreach ( $refund->get_items() as $item_id => $item ) {
|
||||
$product = $refund->get_product_from_item( $item );
|
||||
$product_id = 0;
|
||||
$variation_id = 0;
|
||||
$product_sku = null;
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
// Check if the product exists.
|
||||
if ( is_object( $product ) ) {
|
||||
$product_id = $product->id;
|
||||
$variation_id = $product->variation_id;
|
||||
$product_sku = $product->get_sku();
|
||||
}
|
||||
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
|
||||
$item_meta = array();
|
||||
|
||||
$hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
|
||||
|
||||
foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $formatted_meta['key'],
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_item = array(
|
||||
'id' => $item_id,
|
||||
'name' => $item['name'],
|
||||
'name' => $item->get_name(),
|
||||
'sku' => $product_sku,
|
||||
'product_id' => (int) $product_id,
|
||||
'variation_id' => (int) $variation_id,
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ! empty( $item['tax_class'] ) ? $item['tax_class'] : '',
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'price' => wc_format_decimal( $refund->get_item_total( $item, false, false ), $dp ),
|
||||
'subtotal' => wc_format_decimal( $refund->get_line_subtotal( $item, false, false ), $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
|
||||
'total' => wc_format_decimal( $refund->get_line_total( $item, false, false ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $item['line_tax'], $dp ),
|
||||
'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ),
|
||||
'taxes' => array(),
|
||||
'meta' => $item_meta,
|
||||
);
|
||||
|
@ -281,6 +265,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
$data = array(
|
||||
'order_id' => $order_data->ID,
|
||||
'amount' => $request['amount'],
|
||||
'reason' => empty( $request['reason'] ) ? null : $request['reason'],
|
||||
'line_items' => $request['line_items'],
|
||||
);
|
||||
|
||||
|
@ -300,7 +285,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
$order = wc_get_order( $order_data );
|
||||
|
||||
if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) {
|
||||
$result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
|
||||
$result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order->id, $refund->get_refund_amount(), $refund->get_refund_reason() );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $result;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -122,8 +122,8 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
'individual_use' => $coupon->get_individual_use(),
|
||||
'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ),
|
||||
'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ),
|
||||
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
|
||||
'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
|
||||
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
|
||||
'usage_count' => (int) $coupon->get_usage_count(),
|
||||
'expiry_date' => $this->server->format_datetime( $coupon->get_expiry_date() ),
|
||||
|
|
|
@ -116,11 +116,11 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
$order_data = array(
|
||||
'id' => $order->get_id(),
|
||||
'order_number' => $order->get_order_number(),
|
||||
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
|
||||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
|
||||
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
|
||||
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->order_currency,
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), 2 ),
|
||||
'subtotal' => wc_format_decimal( $this->get_order_subtotal( $order ), 2 ),
|
||||
'total_line_items_quantity' => $order->get_item_count(),
|
||||
|
@ -163,7 +163,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
),
|
||||
'note' => $order->get_customer_note(),
|
||||
'customer_ip' => $order->get_customer_ip_address(),
|
||||
'customer_user_agent' => $order->get_user_agent(),
|
||||
'customer_user_agent' => $order->get_customer_user_agent(),
|
||||
'customer_id' => $order->get_user_id(),
|
||||
'view_order_url' => $order->get_view_order_url(),
|
||||
'line_items' => array(),
|
||||
|
@ -175,37 +175,33 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add line items
|
||||
foreach( $order->get_items() as $item_id => $item ) {
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
|
||||
$product = $item->get_product();
|
||||
$order_data['line_items'][] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ),
|
||||
'quantity' => (int) $item['qty'],
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'name' => $item['name'],
|
||||
'product_id' => ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id,
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
);
|
||||
}
|
||||
|
||||
// add shipping
|
||||
foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
|
||||
|
||||
$order_data['shipping_lines'][] = array(
|
||||
'id' => $shipping_item_id,
|
||||
'method_id' => $shipping_item['method_id'],
|
||||
'method_title' => $shipping_item['name'],
|
||||
'total' => wc_format_decimal( $shipping_item['cost'], 2 ),
|
||||
'method_id' => $shipping_item->get_method_id(),
|
||||
'method_title' => $shipping_item->get_name(),
|
||||
'total' => wc_format_decimal( $shipping_item->get_total(), 2 ),
|
||||
);
|
||||
}
|
||||
|
||||
// add taxes
|
||||
foreach ( $order->get_tax_totals() as $tax_code => $tax ) {
|
||||
|
||||
$order_data['tax_lines'][] = array(
|
||||
'code' => $tax_code,
|
||||
'title' => $tax->label,
|
||||
|
@ -216,11 +212,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add fees
|
||||
foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
|
||||
|
||||
$order_data['fee_lines'][] = array(
|
||||
'id' => $fee_item_id,
|
||||
'title' => $fee_item['name'],
|
||||
'tax_class' => ( ! empty( $fee_item['tax_class'] ) ) ? $fee_item['tax_class'] : null,
|
||||
'title' => $fee_item->get_name(),
|
||||
'tax_class' => $fee_item->get_tax_class(),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $fee_item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), 2 ),
|
||||
);
|
||||
|
@ -228,11 +223,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add coupons
|
||||
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
|
||||
|
||||
$order_data['coupon_lines'][] = array(
|
||||
'id' => $coupon_item_id,
|
||||
'code' => $coupon_item['name'],
|
||||
'amount' => wc_format_decimal( $coupon_item['discount_amount'], 2 ),
|
||||
'code' => $coupon_item->get_code(),
|
||||
'amount' => wc_format_decimal( $coupon_item->get_discount_total(), 2 ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -385,13 +379,11 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
* @return float
|
||||
*/
|
||||
private function get_order_subtotal( $order ) {
|
||||
|
||||
$subtotal = 0;
|
||||
|
||||
// subtotal
|
||||
foreach ( $order->get_items() as $item ) {
|
||||
|
||||
$subtotal += ( isset( $item['line_subtotal'] ) ) ? $item['line_subtotal'] : 0;
|
||||
$subtotal += $item->get_subtotal();
|
||||
}
|
||||
|
||||
return $subtotal;
|
||||
|
|
|
@ -132,11 +132,11 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
'individual_use' => $coupon->get_individual_use(),
|
||||
'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ),
|
||||
'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ),
|
||||
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
|
||||
'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
|
||||
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
|
||||
'usage_count' => (int) $coupon->get_usage_count(),
|
||||
'expiry_date' => ( ! empty( $coupon->get_expiry_date() ) ) ? $this->server->format_datetime( $coupon->get_expiry_date() ) : null,
|
||||
'expiry_date' => $coupon->get_expiry_date() ? $this->server->format_datetime( $coupon->get_expiry_date() ) : null,
|
||||
'enable_free_shipping' => $coupon->get_free_shipping(),
|
||||
'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ),
|
||||
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ),
|
||||
|
|
|
@ -156,9 +156,9 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
$order_data = array(
|
||||
'id' => $order->get_id(),
|
||||
'order_number' => $order->get_order_number(),
|
||||
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
|
||||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
|
||||
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
|
||||
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
|
@ -201,7 +201,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
),
|
||||
'note' => $order->get_customer_note(),
|
||||
'customer_ip' => $order->get_customer_ip_address(),
|
||||
'customer_user_agent' => $order->get_user_agent(),
|
||||
'customer_user_agent' => $order->get_customer_user_agent(),
|
||||
'customer_id' => $order->get_user_id(),
|
||||
'view_order_url' => $order->get_view_order_url(),
|
||||
'line_items' => array(),
|
||||
|
@ -213,61 +213,44 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add line items
|
||||
foreach ( $order->get_items() as $item_id => $item ) {
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$product_id = null;
|
||||
$product_sku = null;
|
||||
|
||||
// Check if the product exists.
|
||||
if ( is_object( $product ) ) {
|
||||
$product_id = ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id;
|
||||
$product_sku = $product->get_sku();
|
||||
}
|
||||
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
|
||||
$item_meta = array();
|
||||
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $formatted_meta['key'],
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$order_data['line_items'][] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $item['line_tax'], $dp ),
|
||||
'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ),
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'name' => $item['name'],
|
||||
'product_id' => $product_id,
|
||||
'sku' => $product_sku,
|
||||
'quantity' => $item->get_qty(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
);
|
||||
}
|
||||
|
||||
// add shipping
|
||||
foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
|
||||
|
||||
$order_data['shipping_lines'][] = array(
|
||||
'id' => $shipping_item_id,
|
||||
'method_id' => $shipping_item['method_id'],
|
||||
'method_title' => $shipping_item['name'],
|
||||
'total' => wc_format_decimal( $shipping_item['cost'], $dp ),
|
||||
'method_id' => $shipping_item->get_method_id(),
|
||||
'method_title' => $shipping_item->get_name(),
|
||||
'total' => wc_format_decimal( $shipping_item->get_total(), $dp ),
|
||||
);
|
||||
}
|
||||
|
||||
// add taxes
|
||||
foreach ( $order->get_tax_totals() as $tax_code => $tax ) {
|
||||
|
||||
$order_data['tax_lines'][] = array(
|
||||
'id' => $tax->id,
|
||||
'rate_id' => $tax->rate_id,
|
||||
|
@ -280,11 +263,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add fees
|
||||
foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
|
||||
|
||||
$order_data['fee_lines'][] = array(
|
||||
'id' => $fee_item_id,
|
||||
'title' => $fee_item['name'],
|
||||
'tax_class' => ( ! empty( $fee_item['tax_class'] ) ) ? $fee_item['tax_class'] : null,
|
||||
'title' => $fee_item->get_name(),
|
||||
'tax_class' => $fee_item->get_tax_class(),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ),
|
||||
);
|
||||
|
@ -292,11 +274,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add coupons
|
||||
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
|
||||
|
||||
$order_data['coupon_lines'][] = array(
|
||||
'id' => $coupon_item_id,
|
||||
'code' => $coupon_item['name'],
|
||||
'amount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ),
|
||||
'code' => $coupon_item->get_code(),
|
||||
'amount' => wc_format_decimal( $coupon_item->get_discount_total(), $dp ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1515,39 +1496,36 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// Add line items
|
||||
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
$item_meta = array();
|
||||
|
||||
foreach ( $meta->get_formatted() as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $meta_key,
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_items[] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), 2 ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ),
|
||||
'quantity' => (int) $item['qty'],
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'name' => $item['name'],
|
||||
'product_id' => ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id,
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
'refunded_item_id' => (int) $item['refunded_item_id'],
|
||||
'refunded_item_id' => (int) $item->get_meta( 'refunded_item_id' ),
|
||||
);
|
||||
}
|
||||
|
||||
$order_refund = array(
|
||||
'id' => $refund->id,
|
||||
'created_at' => $this->server->format_datetime( $refund->date ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $refund->get_date_created() ) ) ),
|
||||
'amount' => wc_format_decimal( $refund->get_refund_amount(), 2 ),
|
||||
'reason' => $refund->get_refund_reason(),
|
||||
'line_items' => $line_items
|
||||
|
|
|
@ -132,11 +132,11 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
'individual_use' => $coupon->get_individual_use(),
|
||||
'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ),
|
||||
'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ),
|
||||
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
|
||||
'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
|
||||
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
|
||||
'usage_count' => (int) $coupon->get_usage_count(),
|
||||
'expiry_date' => ( ! empty( $coupon->get_expiry_date() ) ) ? $this->server->format_datetime( $coupon->get_expiry_date() ) : null,
|
||||
'expiry_date' => $coupon->get_expiry_date() ? $this->server->format_datetime( $coupon->get_expiry_date() ) : null,
|
||||
'enable_free_shipping' => $coupon->get_free_shipping(),
|
||||
'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ),
|
||||
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ),
|
||||
|
|
|
@ -162,9 +162,9 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
'id' => $order->get_id(),
|
||||
'order_number' => $order->get_order_number(),
|
||||
'order_key' => $order->get_order_key(),
|
||||
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
|
||||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
|
||||
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
|
||||
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
|
@ -207,7 +207,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
),
|
||||
'note' => $order->get_customer_note(),
|
||||
'customer_ip' => $order->get_customer_ip_address(),
|
||||
'customer_user_agent' => $order->get_user_agent(),
|
||||
'customer_user_agent' => $order->get_customer_user_agent(),
|
||||
'customer_id' => $order->get_user_id(),
|
||||
'view_order_url' => $order->get_view_order_url(),
|
||||
'line_items' => array(),
|
||||
|
@ -215,47 +215,32 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
'tax_lines' => array(),
|
||||
'fee_lines' => array(),
|
||||
'coupon_lines' => array(),
|
||||
'is_vat_exempt' => $order->is_vat_exempt === 'yes' ? true : false,
|
||||
);
|
||||
|
||||
// Add line items.
|
||||
foreach ( $order->get_items() as $item_id => $item ) {
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$product_id = null;
|
||||
$product_sku = null;
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
// Check if the product exists.
|
||||
if ( is_object( $product ) ) {
|
||||
$product_id = ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id;
|
||||
$product_sku = $product->get_sku();
|
||||
}
|
||||
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
|
||||
$item_meta = array();
|
||||
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
|
||||
|
||||
foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $formatted_meta['key'],
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_item = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $item['line_tax'], $dp ),
|
||||
'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ),
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'name' => $item['name'],
|
||||
'product_id' => $product_id,
|
||||
'sku' => $product_sku,
|
||||
'quantity' => $item->get_qty(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
);
|
||||
|
||||
|
@ -274,9 +259,9 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
|
||||
$order_data['shipping_lines'][] = array(
|
||||
'id' => $shipping_item_id,
|
||||
'method_id' => $shipping_item['method_id'],
|
||||
'method_title' => $shipping_item['name'],
|
||||
'total' => wc_format_decimal( $shipping_item['cost'], $dp ),
|
||||
'method_id' => $shipping_item->get_method_id(),
|
||||
'method_title' => $shipping_item->get_name(),
|
||||
'total' => wc_format_decimal( $shipping_item->get_total(), $dp ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -306,8 +291,8 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
|
||||
$order_data['fee_lines'][] = array(
|
||||
'id' => $fee_item_id,
|
||||
'title' => $fee_item['name'],
|
||||
'tax_class' => ( ! empty( $fee_item['tax_class'] ) ) ? $fee_item['tax_class'] : null,
|
||||
'title' => $fee_item->get_name(),
|
||||
'tax_class' => $fee_item->get_tax_class(),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ),
|
||||
);
|
||||
|
@ -317,12 +302,12 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
|
||||
$coupon_line = array(
|
||||
'id' => $coupon_item_id,
|
||||
'code' => $coupon_item['name'],
|
||||
'amount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ),
|
||||
'code' => $coupon_item->get_code(),
|
||||
'amount' => wc_format_decimal( $coupon_item->get_discount_total(), $dp ),
|
||||
);
|
||||
|
||||
if ( in_array( 'coupons', $expand ) ) {
|
||||
$_coupon_data = WC()->api->WC_API_Coupons->get_coupon_by_code( $coupon_item['name'] );
|
||||
$_coupon_data = WC()->api->WC_API_Coupons->get_coupon_by_code( $coupon_item->get_code() );
|
||||
|
||||
if ( ! is_wp_error( $_coupon_data ) && isset( $_coupon_data['coupon'] ) ) {
|
||||
$coupon_line['coupon_data'] = $_coupon_data['coupon'];
|
||||
|
@ -1560,39 +1545,36 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// Add line items
|
||||
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
$item_meta = array();
|
||||
|
||||
foreach ( $meta->get_formatted() as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $meta_key,
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_items[] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), 2 ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ),
|
||||
'quantity' => (int) $item['qty'],
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'name' => $item['name'],
|
||||
'product_id' => ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id,
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
'refunded_item_id' => (int) $item['refunded_item_id'],
|
||||
'refunded_item_id' => (int) $item->get_meta( 'refunded_item_id' ),
|
||||
);
|
||||
}
|
||||
|
||||
$order_refund = array(
|
||||
'id' => $refund->id,
|
||||
'created_at' => $this->server->format_datetime( $refund->date ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $refund->get_date_created() ) ) ),
|
||||
'amount' => wc_format_decimal( $refund->get_refund_amount(), 2 ),
|
||||
'reason' => $refund->get_refund_reason(),
|
||||
'line_items' => $line_items
|
||||
|
|
|
@ -1319,8 +1319,14 @@ class WC_AJAX {
|
|||
if ( $_product->exists() && $_product->managing_stock() && isset( $order_item_qty[ $item_id ] ) && $order_item_qty[ $item_id ] > 0 ) {
|
||||
$stock_change = apply_filters( 'woocommerce_reduce_order_stock_quantity', $order_item_qty[ $item_id ], $item_id );
|
||||
$new_stock = $_product->reduce_stock( $stock_change );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku() : $order_item['product_id'];
|
||||
$note = sprintf( __( 'Item %s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $new_stock + $stock_change, $new_stock );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku() : $_product->id;
|
||||
|
||||
if ( ! empty( $_product->variation_id ) ) {
|
||||
$note = sprintf( __( 'Item %s variation #%s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $_product->variation_id, $new_stock + $stock_change, $new_stock );
|
||||
} else {
|
||||
$note = sprintf( __( 'Item %s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $new_stock + $stock_change, $new_stock );
|
||||
}
|
||||
|
||||
$return[] = $note;
|
||||
$order->add_order_note( $note );
|
||||
$order->send_stock_notifications( $_product, $new_stock, $order_item_qty[ $item_id ] );
|
||||
|
@ -1360,8 +1366,14 @@ class WC_AJAX {
|
|||
$old_stock = $_product->get_stock_quantity();
|
||||
$stock_change = apply_filters( 'woocommerce_restore_order_stock_quantity', $order_item_qty[ $item_id ], $item_id );
|
||||
$new_quantity = $_product->increase_stock( $stock_change );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku(): $order_item['product_id'];
|
||||
$note = sprintf( __( 'Item %s stock increased from %s to %s.', 'woocommerce' ), $item_name, $old_stock, $new_quantity );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku() : $_product->id;
|
||||
|
||||
if ( ! empty( $_product->variation_id ) ) {
|
||||
$note = sprintf( __( 'Item %s variation #%s stock increased from %s to %s.', 'woocommerce' ), $item_name, $_product->variation_id, $old_stock, $new_quantity );
|
||||
} else {
|
||||
$note = sprintf( __( 'Item %s stock increased from %s to %s.', 'woocommerce' ), $item_name, $old_stock, $new_quantity );
|
||||
}
|
||||
|
||||
$return[] = $note;
|
||||
$order->add_order_note( $note );
|
||||
}
|
||||
|
@ -1375,44 +1387,6 @@ class WC_AJAX {
|
|||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some meta to a line item.
|
||||
*/
|
||||
public static function add_order_item_meta() {
|
||||
check_ajax_referer( 'order-item', 'security' );
|
||||
|
||||
if ( ! current_user_can( 'edit_shop_orders' ) ) {
|
||||
die(-1);
|
||||
}
|
||||
|
||||
$meta_id = wc_add_order_item_meta( absint( $_POST['order_item_id'] ), __( 'Name', 'woocommerce' ), __( 'Value', 'woocommerce' ) );
|
||||
|
||||
if ( $meta_id ) {
|
||||
echo '<tr data-meta_id="' . esc_attr( $meta_id ) . '"><td><input type="text" name="meta_key[' . $meta_id . ']" /><textarea name="meta_value[' . $meta_id . ']"></textarea></td><td width="1%"><button class="remove_order_item_meta button">×</button></td></tr>';
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta from a line item.
|
||||
*/
|
||||
public static function remove_order_item_meta() {
|
||||
check_ajax_referer( 'order-item', 'security' );
|
||||
|
||||
if ( ! current_user_can( 'edit_shop_orders' ) ) {
|
||||
die(-1);
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->delete( "{$wpdb->prefix}woocommerce_order_itemmeta", array(
|
||||
'meta_id' => absint( $_POST['meta_id'] ),
|
||||
) );
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calc line tax.
|
||||
*/
|
||||
|
|
|
@ -118,7 +118,7 @@ class WC_API extends WC_Legacy_API {
|
|||
$this->rest_api_includes();
|
||||
|
||||
// Init REST API routes.
|
||||
add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
|
||||
add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,8 +174,6 @@ class WC_API extends WC_Legacy_API {
|
|||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhooks-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-tools-controller.php' );
|
||||
|
||||
do_action( 'woocommerce_api_includes' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,7 +184,7 @@ class WC_API extends WC_Legacy_API {
|
|||
// Register settings to the REST API.
|
||||
$this->register_wp_admin_settings();
|
||||
|
||||
$controllers = apply_filters( 'woocommerce_api_controllers', array(
|
||||
$controllers = array(
|
||||
'WC_REST_Coupons_Controller',
|
||||
'WC_REST_Customer_Downloads_Controller',
|
||||
'WC_REST_Customers_Controller',
|
||||
|
@ -214,7 +212,7 @@ class WC_API extends WC_Legacy_API {
|
|||
'WC_REST_Webhooks_Controller',
|
||||
'WC_REST_System_Status_Controller',
|
||||
'WC_REST_System_Status_Tools_Controller',
|
||||
) );
|
||||
);
|
||||
|
||||
foreach ( $controllers as $controller ) {
|
||||
$this->$controller = new $controller();
|
||||
|
|
|
@ -231,7 +231,7 @@ class WC_Checkout {
|
|||
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
||||
$product = $values['data'];
|
||||
$item = new WC_Order_Item_Product( array(
|
||||
'qty' => $values['quantity'],
|
||||
'quantity' => $values['quantity'],
|
||||
'name' => $product ? $product->get_title() : '',
|
||||
'tax_class' => $product ? $product->get_tax_class() : '',
|
||||
'product_id' => $product ? $product->get_id() : '',
|
||||
|
@ -244,11 +244,7 @@ class WC_Checkout {
|
|||
'taxes' => $values['line_tax_data'],
|
||||
) );
|
||||
|
||||
// Handle backorders @todo improve how these are handled/stored
|
||||
if ( $product->backorders_require_notification() && $product->is_on_backorder( $args['qty'] ) ) {
|
||||
$item->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ) ), $values['quantity'] - max( 0, $product->get_total_stock() ), true );
|
||||
}
|
||||
|
||||
$item->set_backorder_meta();
|
||||
// Set this to pass to legacy actions @todo remove in future release
|
||||
$item->legacy_values = $values;
|
||||
$item->legacy_cart_item_key = $cart_item_key;
|
||||
|
@ -321,8 +317,6 @@ class WC_Checkout {
|
|||
// Save the order
|
||||
$order_id = $order->save();
|
||||
|
||||
$customer = new WC_Customer( $this->customer_id );
|
||||
|
||||
// Update user meta
|
||||
$this->update_customer_data();
|
||||
|
||||
|
@ -822,7 +816,6 @@ class WC_Checkout {
|
|||
return $current_user->user_email;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch ( $input ) {
|
||||
|
|
|
@ -239,6 +239,7 @@ class WC_Comments {
|
|||
delete_post_meta( $post_id, '_wc_average_rating' );
|
||||
delete_post_meta( $post_id, '_wc_rating_count' );
|
||||
delete_post_meta( $post_id, '_wc_review_count' );
|
||||
WC_Product::sync_average_rating( $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -434,6 +434,7 @@ class WC_Countries {
|
|||
'NZ' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {postcode}\n{country}",
|
||||
'NO' => $postcode_before_city,
|
||||
'PL' => $postcode_before_city,
|
||||
'PT' => $postcode_before_city,
|
||||
'SK' => $postcode_before_city,
|
||||
'SI' => $postcode_before_city,
|
||||
'ES' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{state}\n{country}",
|
||||
|
|
|
@ -21,42 +21,42 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
* @var array
|
||||
*/
|
||||
protected $_data = array(
|
||||
'id' => 0,
|
||||
'email' => '',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'role' => 'customer',
|
||||
'last_order_id' => null, // read only
|
||||
'last_order_date' => null, // read only
|
||||
'orders_count' => 0, // read only
|
||||
'total_spent' => 0, // read only
|
||||
'username' => '', // read only on existing users
|
||||
'password' => '', // write only
|
||||
'date_created' => '', // read only
|
||||
'date_modified' => '', // read only
|
||||
'billing_first_name' => '',
|
||||
'billing_last_name' => '',
|
||||
'billing_company' => '',
|
||||
'billing_phone' => '',
|
||||
'billing_email' => '',
|
||||
'billing_postcode' => '',
|
||||
'billing_city' => '',
|
||||
'billing_address_1' => '',
|
||||
'billing_address_2' => '',
|
||||
'billing_state' => '',
|
||||
'billing_country' => '',
|
||||
'shipping_first_name' => '',
|
||||
'shipping_last_name' => '',
|
||||
'shipping_company' => '',
|
||||
'shipping_postcode' => '',
|
||||
'shipping_city' => '',
|
||||
'shipping_address_1' => '',
|
||||
'shipping_address_2' => '',
|
||||
'shipping_state' => '',
|
||||
'shipping_country' => '',
|
||||
'is_paying_customer' => false,
|
||||
'is_vat_exempt' => false, // session only.
|
||||
'calculated_shipping' => false, // session only
|
||||
'id' => 0,
|
||||
'email' => '',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'role' => 'customer',
|
||||
'last_order_id' => null, // read only
|
||||
'last_order_date' => null, // read only
|
||||
'orders_count' => 0, // read only
|
||||
'total_spent' => 0, // read only
|
||||
'username' => '', // read only on existing users
|
||||
'password' => '', // write only
|
||||
'date_created' => '', // read only
|
||||
'date_modified' => '', // read only
|
||||
'billing_first_name' => '',
|
||||
'billing_last_name' => '',
|
||||
'billing_company' => '',
|
||||
'billing_phone' => '',
|
||||
'billing_email' => '',
|
||||
'billing_postcode' => '',
|
||||
'billing_city' => '',
|
||||
'billing_address_1' => '',
|
||||
'billing_address_2' => '',
|
||||
'billing_state' => '',
|
||||
'billing_country' => '',
|
||||
'shipping_first_name' => '',
|
||||
'shipping_last_name' => '',
|
||||
'shipping_company' => '',
|
||||
'shipping_postcode' => '',
|
||||
'shipping_city' => '',
|
||||
'shipping_address_1' => '',
|
||||
'shipping_address_2' => '',
|
||||
'shipping_state' => '',
|
||||
'shipping_country' => '',
|
||||
'is_paying_customer' => false,
|
||||
'is_vat_exempt' => false, // session only.
|
||||
'calculated_shipping' => false, // session only
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -99,37 +99,27 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
protected $_changed = false;
|
||||
|
||||
/**
|
||||
* If some of the customer information is loaded by session (instead of just from the DB).
|
||||
* If this is the customer session, this is true. When true, guest accounts will not be saved to the DB.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_from_session = false;
|
||||
|
||||
/**
|
||||
* WC_Customer can also return an object for a logged out user (session).
|
||||
* $_is_user will be false in this case. It will be true for all other cases
|
||||
* (logged in users or getting a WC_Customer for another object)
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_is_user = false;
|
||||
protected $_is_session = false;
|
||||
|
||||
/**
|
||||
* Load customer data based on how WC_Customer is called.
|
||||
* @param mixed $customer WC_Customer object or customer ID is accepted.
|
||||
* if $customer is 'new', you can build a new WC_Customer object. If it's empty, some
|
||||
*
|
||||
* If $customer is 'new', you can build a new WC_Customer object. If it's empty, some
|
||||
* data will be pulled from the session for the current user/customer.
|
||||
*
|
||||
* @param int $customer_id Customer ID
|
||||
* @param bool $is_session True if this is the customer session
|
||||
*/
|
||||
public function __construct( $customer = '' ) {
|
||||
if ( $customer instanceof WC_Customer ) {
|
||||
$this->_is_user = true;
|
||||
$this->read( absint( $customer->get_id() ) );
|
||||
} elseif ( is_numeric( $customer ) ) {
|
||||
$this->_is_user = true;
|
||||
$this->read( $customer );
|
||||
} elseif ( empty( $customer ) ) {
|
||||
$this->_is_user = true; // unless load_session gets called after.
|
||||
public function __construct( $customer_id = 0, $is_session = false ) {
|
||||
if ( $customer_id > 0 ) {
|
||||
$this->read( $customer_id );
|
||||
}
|
||||
|
||||
if ( $this->_from_session ) {
|
||||
if ( $is_session ) {
|
||||
$this->_is_session = true;
|
||||
$this->load_session();
|
||||
add_action( 'shutdown', array( $this, 'save_session_if_changed' ), 10 );
|
||||
}
|
||||
}
|
||||
|
@ -148,14 +138,131 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
* Loads a WC session into the customer class.
|
||||
*/
|
||||
public function load_session() {
|
||||
$this->_from_session = true;
|
||||
if ( is_user_logged_in() ) {
|
||||
$this->_is_user = true;
|
||||
$this->read( get_current_user_id() );
|
||||
} else {
|
||||
$this->_is_user = false;
|
||||
$this->read( WC()->session->get_customer_id() );
|
||||
$data = (array) WC()->session->get( 'customer' );
|
||||
if ( ! empty( $data ) ) {
|
||||
foreach ( $this->_session_keys as $session_key ) {
|
||||
$function_key = $session_key;
|
||||
if ( 'billing_' === substr( $session_key, 0, 8 ) ) {
|
||||
$session_key = str_replace( 'billing_', '', $session_key );
|
||||
}
|
||||
if ( ! empty( $data[ $session_key ] ) && is_callable( array( $this, "set_{$function_key}" ) ) ) {
|
||||
$this->{"set_{$function_key}"}( $data[ $session_key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->load_defaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load default values if props are unset.
|
||||
*/
|
||||
protected function load_defaults() {
|
||||
$default = wc_get_customer_default_location();
|
||||
|
||||
// Set some defaults if some of our values are still not set.
|
||||
if ( ! $this->get_billing_country() ) {
|
||||
$this->set_billing_country( $default['country'] );
|
||||
}
|
||||
|
||||
if ( ! $this->get_shipping_country() ) {
|
||||
$this->set_shipping_country( $this->get_billing_country() );
|
||||
}
|
||||
|
||||
if ( ! $this->get_billing_state() ) {
|
||||
$this->set_billing_state( $default['state'] );
|
||||
}
|
||||
|
||||
if ( ! $this->get_shipping_state() ) {
|
||||
$this->set_shipping_state( $this->get_billing_state() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the customers last order.
|
||||
* @return WC_Order|false
|
||||
*/
|
||||
public function get_last_order() {
|
||||
global $wpdb;
|
||||
|
||||
$last_order = $wpdb->get_var( "SELECT posts.ID
|
||||
FROM $wpdb->posts AS posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
|
||||
ORDER BY posts.ID DESC
|
||||
" );
|
||||
|
||||
if ( $last_order ) {
|
||||
return wc_get_order( absint( $last_order ) );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of orders this customer has.
|
||||
* @since 2.7.0
|
||||
* @return integer
|
||||
*/
|
||||
public function get_order_count() {
|
||||
global $wpdb;
|
||||
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*)
|
||||
FROM $wpdb->posts as posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
|
||||
AND meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
" );
|
||||
|
||||
return absint( $count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how much money this customer has spent.
|
||||
* @since 2.7.0
|
||||
* @return float
|
||||
*/
|
||||
public function get_total_spent() {
|
||||
global $wpdb;
|
||||
|
||||
$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
|
||||
FROM $wpdb->posts as posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( 'wc-completed', 'wc-processing' )
|
||||
AND meta2.meta_key = '_order_total'
|
||||
" );
|
||||
|
||||
if ( ! $spent ) {
|
||||
$spent = 0;
|
||||
}
|
||||
|
||||
return wc_format_decimal( $spent );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is customer outside base country (for tax purposes)?
|
||||
* @return bool
|
||||
*/
|
||||
public function is_customer_outside_base() {
|
||||
list( $country, $state ) = $this->get_taxable_address();
|
||||
if ( $country ) {
|
||||
$default = wc_get_base_location();
|
||||
if ( $default['country'] !== $country ) {
|
||||
return true;
|
||||
}
|
||||
if ( $default['state'] && $default['state'] !== $state ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -166,9 +273,9 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Return a customer's user ID. If the current customer is logged out, this will be a session key.
|
||||
* Return a customer's user ID. Logged out users have ID 0.
|
||||
* @since 2.7.0
|
||||
* @return mixed
|
||||
* @return int
|
||||
*/
|
||||
public function get_id() {
|
||||
return $this->_data['id'];
|
||||
|
@ -219,42 +326,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
return $this->_data['role'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return customer's last order ID.
|
||||
* @since 2.7.0
|
||||
* @return integer|null
|
||||
*/
|
||||
public function get_last_order_id() {
|
||||
return ( is_null( $this->_data['last_order_id'] ) ? null : intval( $this->_data['last_order_id'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the date of the customer's last order.
|
||||
* @since 2.7.0
|
||||
* @return integer|null
|
||||
*/
|
||||
public function get_last_order_date() {
|
||||
return ( is_null( $this->_data['last_order_date'] ) ? null : intval( $this->_data['last_order_date'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of orders this customer has.
|
||||
* @since 2.7.0
|
||||
* @return integer
|
||||
*/
|
||||
public function get_orders_count() {
|
||||
return intval( $this->_data['orders_count'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how much money this customer has spent.
|
||||
* @since 2.7.0
|
||||
* @return float
|
||||
*/
|
||||
public function get_total_spent() {
|
||||
return wc_format_decimal( $this->_data['total_spent'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this customer's avatar.
|
||||
* @since 2.7.0
|
||||
|
@ -315,6 +386,22 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
return $this->_data['billing_company'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets billing phone.
|
||||
* @return string
|
||||
*/
|
||||
public function get_billing_phone() {
|
||||
return $this->_data['billing_phone'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets billing email.
|
||||
* @return string
|
||||
*/
|
||||
public function get_billing_email() {
|
||||
return $this->_data['billing_email'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets customer postcode.
|
||||
* @return string
|
||||
|
@ -371,22 +458,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
return $this->_data['billing_country'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets customer billing phone.
|
||||
* @return string
|
||||
*/
|
||||
public function get_billing_phone() {
|
||||
return $this->_data['billing_phone'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets customer billing email.
|
||||
* @return string
|
||||
*/
|
||||
public function get_billing_email() {
|
||||
return $this->_data['billing_email'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets customer shipping first name.
|
||||
* @return string
|
||||
|
@ -522,7 +593,7 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
*/
|
||||
public function get_downloadable_products() {
|
||||
$downloads = array();
|
||||
if ( $this->_is_user ) {
|
||||
if ( $this->get_id() ) {
|
||||
$downloads = wc_get_customer_available_downloads( $this->get_id() );
|
||||
}
|
||||
return apply_filters( 'woocommerce_customer_get_downloadable_products', $downloads );
|
||||
|
@ -546,6 +617,15 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
| object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set customer ID.
|
||||
* @since 2.7.0
|
||||
* @param int $value
|
||||
*/
|
||||
protected function set_id( $value ) {
|
||||
$this->_data['id'] = absint( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer's username.
|
||||
* @since 2.7.0
|
||||
|
@ -591,42 +671,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
$this->_data['role'] = $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer's last order ID.
|
||||
* @since 2.7.0
|
||||
* @param integer|null $last_order_id
|
||||
*/
|
||||
public function set_last_order_id( $last_order_id ) {
|
||||
$this->_data['last_order_id'] = $last_order_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the date of the customer's last order.
|
||||
* @since 2.7.0
|
||||
* @param string|null $last_order_date
|
||||
*/
|
||||
public function set_last_order_date( $last_order_date ) {
|
||||
$this->_data['last_order_date'] = $last_order_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of orders this customer has.
|
||||
* @since 2.7.0
|
||||
* @param integer $order_count
|
||||
*/
|
||||
public function set_orders_count( $orders_count ) {
|
||||
$this->_data['orders_count'] = $orders_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how much money this customer has spent.
|
||||
* @since 2.7.0
|
||||
* @param float $total_spent
|
||||
*/
|
||||
public function set_total_spent( $total_spent ) {
|
||||
$this->_data['total_spent'] = $total_spent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer's password.
|
||||
* @since 2.7.0
|
||||
|
@ -706,6 +750,46 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
$this->_data['billing_city'] = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set billing first name.
|
||||
* @return string
|
||||
*/
|
||||
public function set_billing_first_name( $value ) {
|
||||
$this->_data['billing_first_name'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set billing last name.
|
||||
* @return string
|
||||
*/
|
||||
public function set_billing_last_name( $value ) {
|
||||
$this->_data['billing_last_name'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set billing company.
|
||||
* @return string
|
||||
*/
|
||||
public function set_billing_company( $value ) {
|
||||
$this->_data['billing_company'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set billing phone.
|
||||
* @return string
|
||||
*/
|
||||
public function set_billing_phone( $value ) {
|
||||
$this->_data['billing_phone'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set billing email.
|
||||
* @return string
|
||||
*/
|
||||
public function set_billing_email( $email ) {
|
||||
$this->_data['billing_email'] = sanitize_email( $email );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer country.
|
||||
* @param mixed $country
|
||||
|
@ -722,46 +806,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
$this->_data['billing_state'] = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets customer billing first name.
|
||||
* @param string $first_name
|
||||
*/
|
||||
public function set_billing_first_name( $first_name ) {
|
||||
$this->_data['billing_first_name'] = $first_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets customer billing last name.
|
||||
* @param string $last_name
|
||||
*/
|
||||
public function set_billing_last_name( $last_name ) {
|
||||
$this->_data['billing_last_name'] = $last_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets customer billing company.
|
||||
* @param string $company.
|
||||
*/
|
||||
public function set_billing_company( $company ) {
|
||||
$this->_data['billing_company'] = $company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets customer billing phone.
|
||||
* @param string $phone
|
||||
*/
|
||||
public function set_billing_phone( $phone ) {
|
||||
$this->_data['billing_phone'] = $phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets customer billing email.
|
||||
* @param string $email
|
||||
*/
|
||||
public function set_billing_email( $email ) {
|
||||
$this->_data['billing_email'] = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets customer postcode.
|
||||
* @param mixed $postcode
|
||||
|
@ -907,31 +951,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
$this->_data['is_paying_customer'] = (bool) $is_paying_customer;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Other methods
|
||||
|--------------------------------------------------------------------------
|
||||
| Other functions for interacting with customers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Is customer outside base country (for tax purposes)?
|
||||
* @return bool
|
||||
*/
|
||||
public function is_customer_outside_base() {
|
||||
list( $country, $state ) = $this->get_taxable_address();
|
||||
if ( $country ) {
|
||||
$default = wc_get_base_location();
|
||||
if ( $default['country'] !== $country ) {
|
||||
return true;
|
||||
}
|
||||
if ( $default['state'] && $default['state'] !== $state ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CRUD methods
|
||||
|
@ -948,8 +967,8 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
*/
|
||||
public function create() {
|
||||
$customer_id = wc_create_new_customer( $this->get_email(), $this->get_username(), $this->_data['password'] );
|
||||
unset( $this->_data['password'] );
|
||||
if ( $customer_id ) {
|
||||
|
||||
if ( ! is_wp_error( $customer_id ) ) {
|
||||
$this->_data['id'] = $customer_id;
|
||||
update_user_meta( $this->get_id(), 'billing_first_name', $this->get_billing_first_name() );
|
||||
update_user_meta( $this->get_id(), 'billing_last_name', $this->get_billing_last_name() );
|
||||
|
@ -972,14 +991,14 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
update_user_meta( $this->get_id(), 'shipping_state', $this->get_shipping_state() );
|
||||
update_user_meta( $this->get_id(), 'shipping_country', $this->get_shipping_country() );
|
||||
update_user_meta( $this->get_id(), 'paying_customer', $this->get_is_paying_customer() );
|
||||
$this->set_date_modified( time() );
|
||||
update_user_meta( $this->get_id(), 'last_update', $this->get_date_modified() );
|
||||
update_user_meta( $this->get_id(), 'first_name', $this->get_first_name() );
|
||||
update_user_meta( $this->get_id(), 'last_name', $this->get_last_name() );
|
||||
wp_update_user( array( 'ID' => $this->get_id(), 'role' => $this->get_role() ) );
|
||||
$wp_user = new WP_User( $this->get_id() );
|
||||
$this->set_date_created( strtotime( $wp_user->user_registered ) );
|
||||
$this->save_meta_data();
|
||||
$this->set_date_modified( get_user_meta( $this->get_id(), 'last_update', true ) );
|
||||
$this->read_meta_data();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -990,124 +1009,35 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
*/
|
||||
public function read( $id ) {
|
||||
global $wpdb;
|
||||
$pull_from_db = true;
|
||||
$data = array();
|
||||
if ( $this->_from_session ) {
|
||||
$data = (array) WC()->session->get( 'customer' );
|
||||
if ( ! empty( $data ) ) {
|
||||
$pull_from_db = false;
|
||||
foreach ( $this->_session_keys as $session_key ) {
|
||||
$function_key = $session_key;
|
||||
if ( 'billing_' === substr( $session_key, 0, 8 ) ) {
|
||||
$session_key = str_replace( 'billing_', '', $session_key );
|
||||
}
|
||||
if ( ! empty( $data[ $session_key ] ) && is_callable( array( $this, "set_{$function_key}" ) ) ) {
|
||||
$this->{"set_{$function_key}"}( $data[ $session_key ] );
|
||||
}
|
||||
}
|
||||
|
||||
// User object is required.
|
||||
if ( ! $id || ! ( $user_object = get_user_by( 'id', $id ) ) || empty( $user_object->ID ) ) {
|
||||
$this->set_id( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
// Only users on this site should be read.
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
|
||||
$this->set_id( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set_id( $user_object->ID );
|
||||
|
||||
foreach ( array_keys( $this->_data ) as $key ) {
|
||||
$meta_value = get_user_meta( $id, $key, true );
|
||||
if ( $meta_value && is_callable( array( $this, "set_{$key}" ) ) ) {
|
||||
$this->{"set_{$key}"}( $meta_value );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->_is_user ) {
|
||||
|
||||
// Only continue reading if the customer exists.
|
||||
$user_object = get_userdata( $id );
|
||||
if ( empty( $user_object ) || empty ( $user_object->ID ) ) {
|
||||
$this->_data['id'] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( array_keys( $this->_data ) as $key ) {
|
||||
if ( 'billing_' === substr( $key, 0, 8 ) ) {
|
||||
$session_key = str_replace( 'billing_', '', $key );
|
||||
}
|
||||
if ( ! $pull_from_db && ! empty( $data[ $session_key ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta_value = get_user_meta( $id, $key, true );
|
||||
if ( $meta_value && is_callable( array( $this, "set_{$key}" ) ) ) {
|
||||
$this->{"set_{$key}"}( $meta_value );
|
||||
}
|
||||
}
|
||||
|
||||
$this->set_is_paying_customer( get_user_meta( $id, 'paying_customer', true ) );
|
||||
$wp_user = new WP_User( $id );
|
||||
$this->set_email( $wp_user->user_email );
|
||||
$this->set_username( $wp_user->user_login );
|
||||
$this->set_date_created( strtotime( $wp_user->user_registered ) );
|
||||
$this->set_date_modified( get_user_meta( $id, 'last_update', true ) );
|
||||
$this->set_role( ( ! empty ( $wp_user->roles[0] ) ? $wp_user->roles[0] : 'customer' ) );
|
||||
|
||||
// Get info about user's last order
|
||||
$last_order = $wpdb->get_row( "SELECT id, post_date_gmt
|
||||
FROM $wpdb->posts AS posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = {$id}
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( '" . implode( "','", array_keys( wc_get_order_statuses() ) ) . "' )
|
||||
ORDER BY posts.ID DESC
|
||||
" );
|
||||
|
||||
$this->set_last_order_id( is_object( $last_order ) ? $last_order->id : null );
|
||||
$this->set_last_order_date( is_object( $last_order ) ? strtotime( $last_order->post_date_gmt ) : null );
|
||||
|
||||
// WC_Customer can't use wc_get_customer_order_count because get_order_types might not be loaded by the time a customer/session is
|
||||
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*)
|
||||
FROM $wpdb->posts as posts
|
||||
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ('" . implode( "','", array_keys( wc_get_order_statuses() ) ) . "')
|
||||
AND meta_value = $id
|
||||
" );
|
||||
|
||||
$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
|
||||
FROM $wpdb->posts as posts
|
||||
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id
|
||||
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = $id
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( 'wc-completed', 'wc-processing' )
|
||||
AND meta2.meta_key = '_order_total'
|
||||
" );
|
||||
if ( ! $spent ) {
|
||||
$spent = 0;
|
||||
}
|
||||
|
||||
$this->set_orders_count( $count );
|
||||
$this->set_total_spent( $spent );
|
||||
|
||||
$this->read_meta_data();
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
$default = wc_get_customer_default_location();
|
||||
|
||||
// Set some defaults if some of our values are still not set.
|
||||
if ( empty( $this->get_billing_country() ) ) {
|
||||
$this->set_billing_country( $default['country'] );
|
||||
}
|
||||
|
||||
if ( empty( $this->get_shipping_country() ) ) {
|
||||
$this->set_shipping_country( $this->get_billing_country() );
|
||||
}
|
||||
|
||||
if ( empty( $this->get_billing_state() ) ) {
|
||||
$this->set_billing_state( $default['state'] );
|
||||
}
|
||||
|
||||
if ( empty( $this->get_shipping_state() ) ) {
|
||||
$this->set_shipping_state( $this->get_billing_state() );
|
||||
}
|
||||
$this->set_is_paying_customer( get_user_meta( $id, 'paying_customer', true ) );
|
||||
$this->set_email( $user_object->user_email );
|
||||
$this->set_username( $user_object->user_login );
|
||||
$this->set_date_created( strtotime( $user_object->user_registered ) );
|
||||
$this->set_date_modified( get_user_meta( $id, 'last_update', true ) );
|
||||
$this->set_role( ( ! empty ( $user_object->roles[0] ) ? $user_object->roles[0] : 'customer' ) );
|
||||
$this->read_meta_data();
|
||||
|
||||
unset( $this->_data['password'] ); // password is write only, never ever read it
|
||||
}
|
||||
|
@ -1136,6 +1066,9 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
update_user_meta( $this->get_id(), 'billing_address_1', $this->get_billing_address() );
|
||||
update_user_meta( $this->get_id(), 'billing_address_2', $this->get_billing_address_2() );
|
||||
update_user_meta( $this->get_id(), 'billing_state', $this->get_billing_state() );
|
||||
update_user_meta( $this->get_id(), 'shipping_first_name', $this->get_shipping_first_name() );
|
||||
update_user_meta( $this->get_id(), 'shipping_last_name', $this->get_shipping_last_name() );
|
||||
update_user_meta( $this->get_id(), 'shipping_company', $this->get_shipping_company() );
|
||||
update_user_meta( $this->get_id(), 'billing_country', $this->get_billing_country() );
|
||||
update_user_meta( $this->get_id(), 'shipping_first_name', $this->get_shipping_first_name() );
|
||||
update_user_meta( $this->get_id(), 'shipping_last_name', $this->get_shipping_last_name() );
|
||||
|
@ -1147,11 +1080,10 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
update_user_meta( $this->get_id(), 'shipping_state', $this->get_shipping_state() );
|
||||
update_user_meta( $this->get_id(), 'shipping_country', $this->get_shipping_country() );
|
||||
update_user_meta( $this->get_id(), 'paying_customer', $this->get_is_paying_customer() );
|
||||
$this->set_date_modified( time() );
|
||||
update_user_meta( $this->get_id(), 'last_update', $this->get_date_modified() );
|
||||
update_user_meta( $this->get_id(), 'first_name', $this->get_first_name() );
|
||||
update_user_meta( $this->get_id(), 'last_name', $this->get_last_name() );
|
||||
wp_update_user( array( 'ID' => $this->get_id(), 'role' => $this->get_role() ) );
|
||||
$this->set_date_modified( get_user_meta( $this->get_id(), 'last_update', true ) );
|
||||
$this->save_meta_data();
|
||||
}
|
||||
|
||||
|
@ -1186,18 +1118,12 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function save() {
|
||||
if ( $this->_from_session && ! $this->_is_user ) {
|
||||
if ( $this->_is_session ) {
|
||||
$this->save_session_if_changed();
|
||||
return;
|
||||
}
|
||||
if ( ! $this->_is_user ) {
|
||||
} elseif ( ! $this->get_id() ) {
|
||||
$this->create();
|
||||
} else {
|
||||
if ( ! $this->get_id() ) {
|
||||
$this->create();
|
||||
} else {
|
||||
$this->update();
|
||||
}
|
||||
$this->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1206,9 +1132,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function save_to_session() {
|
||||
if ( ! $this->_from_session ) {
|
||||
return;
|
||||
}
|
||||
$data = array();
|
||||
foreach ( $this->_session_keys as $session_key ) {
|
||||
$function_key = $session_key;
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Data Exception Class
|
||||
*
|
||||
* Extends Exception to provide additional data.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Core
|
||||
* @package WooCommerce
|
||||
* @since 2.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WC_Data_Exception class
|
||||
*/
|
||||
class WC_Data_Exception extends Exception {
|
||||
|
||||
/** @var string sanitized error code */
|
||||
protected $error_code;
|
||||
|
||||
/**
|
||||
* Setup exception.
|
||||
*
|
||||
* error code - machine-readable, e.g. `woocommerce_invalid_product_id`
|
||||
* error message - friendly message, e.g. 'Product ID is invalid'
|
||||
* http status code - proper HTTP status code to respond with, e.g. 400
|
||||
*
|
||||
* @param string $error_code
|
||||
* @param string $error_message user-friendly translated error message
|
||||
* @param int $http_status_code HTTP status code to respond with
|
||||
*/
|
||||
public function __construct( $error_code, $error_message, $http_status_code = 400 ) {
|
||||
$this->error_code = $error_code;
|
||||
parent::__construct( $error_message, $http_status_code );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error code
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorCode() {
|
||||
return $this->error_code;
|
||||
}
|
||||
}
|
|
@ -289,13 +289,13 @@ class WC_Emails {
|
|||
continue;
|
||||
}
|
||||
|
||||
$product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
|
||||
$product = apply_filters( 'woocommerce_order_item_product', $item->get_product(), $item );
|
||||
$product_exists = is_object( $product );
|
||||
$is_visible = $product_exists && $product->is_visible();
|
||||
|
||||
$item_offered = array(
|
||||
'@type' => 'Product',
|
||||
'name' => apply_filters( 'woocommerce_order_item_name', $item['name'], $item, $is_visible ),
|
||||
'name' => apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, $is_visible ),
|
||||
);
|
||||
|
||||
if ( $product_exists ) {
|
||||
|
@ -321,7 +321,7 @@ class WC_Emails {
|
|||
'priceCurrency' => $order->get_currency(),
|
||||
'eligibleQuantity' => (object) array(
|
||||
'@type' => 'QuantitativeValue',
|
||||
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item )
|
||||
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item )
|
||||
),
|
||||
'url' => get_home_url(),
|
||||
);
|
||||
|
|
|
@ -598,7 +598,7 @@ class WC_Form_Handler {
|
|||
// Load the previous order - Stop if the order does not exist
|
||||
$order = wc_get_order( absint( $_GET['order_again'] ) );
|
||||
|
||||
if ( empty( $order->get_id() ) ) {
|
||||
if ( ! $order->get_id() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -615,17 +615,17 @@ class WC_Form_Handler {
|
|||
// Copy products from the order to the cart
|
||||
foreach ( $order->get_items() as $item ) {
|
||||
// Load all product info including variation data
|
||||
$product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $item['product_id'] );
|
||||
$quantity = (int) $item['qty'];
|
||||
$variation_id = (int) $item['variation_id'];
|
||||
$product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $item->get_product_id() );
|
||||
$quantity = $item->get_quantity();
|
||||
$variation_id = $item->get_variation_id();
|
||||
$variations = array();
|
||||
$cart_item_data = apply_filters( 'woocommerce_order_again_cart_item_data', array(), $item, $order );
|
||||
|
||||
foreach ( $item['item_meta'] as $meta_name => $meta_value ) {
|
||||
if ( taxonomy_is_product_attribute( $meta_name ) ) {
|
||||
$variations[ $meta_name ] = $meta_value[0];
|
||||
} elseif ( meta_is_product_attribute( $meta_name, $meta_value[0], $product_id ) ) {
|
||||
$variations[ $meta_name ] = $meta_value[0];
|
||||
foreach ( $item->get_meta_data() as $meta ) {
|
||||
if ( taxonomy_is_product_attribute( $meta->meta_key ) ) {
|
||||
$variations[ $meta->meta_key ] = $meta->meta_value;
|
||||
} elseif ( meta_is_product_attribute( $meta->meta_key, $meta->meta_value, $product_id ) ) {
|
||||
$variations[ $meta->meta_key ] = $meta->meta_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,6 +320,7 @@ class WC_Frontend_Scripts {
|
|||
wc_get_template( 'single-product/add-to-cart/variation.php' );
|
||||
|
||||
return array(
|
||||
'wc_ajax_url' => WC_AJAX::get_endpoint( "%%endpoint%%" ),
|
||||
'i18n_no_matching_variations_text' => esc_attr__( 'Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce' ),
|
||||
'i18n_make_a_selection_text' => esc_attr__( 'Please select some product options before adding this product to your cart.', 'woocommerce' ),
|
||||
'i18n_unavailable_text' => esc_attr__( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' )
|
||||
|
|
|
@ -60,7 +60,7 @@ class WC_Order_Factory {
|
|||
/**
|
||||
* Get order item.
|
||||
* @param int
|
||||
* @return WC_Order_Item
|
||||
* @return WC_Order_Item|false if not found
|
||||
*/
|
||||
public static function get_order_item( $item_id = 0 ) {
|
||||
global $wpdb;
|
||||
|
@ -99,6 +99,6 @@ class WC_Order_Factory {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return new WC_Order_Item();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ class WC_Order_Item_Coupon extends WC_Order_Item {
|
|||
* @var array
|
||||
*/
|
||||
protected $_data = array(
|
||||
'order_id' => 0,
|
||||
'order_item_id' => 0,
|
||||
'code' => '',
|
||||
'discount' => 0,
|
||||
'discount_tax' => 0,
|
||||
'order_id' => 0,
|
||||
'id' => 0,
|
||||
'code' => '',
|
||||
'discount' => 0,
|
||||
'discount_tax' => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,14 +19,14 @@ class WC_Order_Item_Fee extends WC_Order_Item {
|
|||
* @var array
|
||||
*/
|
||||
protected $_data = array(
|
||||
'order_id' => 0,
|
||||
'order_item_id' => 0,
|
||||
'name' => '',
|
||||
'tax_class' => '',
|
||||
'tax_status' => 'taxable',
|
||||
'total' => '',
|
||||
'total_tax' => '',
|
||||
'taxes' => array(
|
||||
'order_id' => 0,
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'tax_class' => '',
|
||||
'tax_status' => 'taxable',
|
||||
'total' => '',
|
||||
'total_tax' => '',
|
||||
'taxes' => array(
|
||||
'total' => array()
|
||||
)
|
||||
);
|
||||
|
@ -108,6 +108,14 @@ class WC_Order_Item_Fee extends WC_Order_Item {
|
|||
return $this->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal meta keys we don't want exposed as part of meta_data.
|
||||
* @return array()
|
||||
*/
|
||||
protected function get_internal_meta_keys() {
|
||||
return array( '_tax_class', '_tax_status', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', '_line_tax_data' );
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setters
|
||||
|
@ -119,6 +127,9 @@ class WC_Order_Item_Fee extends WC_Order_Item {
|
|||
* @param string $value
|
||||
*/
|
||||
public function set_tax_class( $value ) {
|
||||
if ( $value && ! in_array( $value, WC_Tax::get_tax_classes() ) ) {
|
||||
//$this->throw_exception( __METHOD__, 'Invalid tax class' );
|
||||
}
|
||||
$this->_data['tax_class'] = $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,18 +19,18 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
* @var array
|
||||
*/
|
||||
protected $_data = array(
|
||||
'order_id' => 0,
|
||||
'order_item_id' => 0,
|
||||
'name' => '',
|
||||
'product_id' => 0,
|
||||
'variation_id' => 0,
|
||||
'qty' => 0,
|
||||
'tax_class' => '',
|
||||
'subtotal' => 0,
|
||||
'subtotal_tax' => 0,
|
||||
'total' => 0,
|
||||
'total_tax' => 0,
|
||||
'taxes' => array(
|
||||
'order_id' => 0,
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'product_id' => 0,
|
||||
'variation_id' => 0,
|
||||
'quantity' => 0,
|
||||
'tax_class' => '',
|
||||
'subtotal' => 0,
|
||||
'subtotal_tax' => 0,
|
||||
'total' => 0,
|
||||
'total_tax' => 0,
|
||||
'taxes' => array(
|
||||
'subtotal' => array(),
|
||||
'total' => array()
|
||||
),
|
||||
|
@ -98,7 +98,7 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
if ( $this->get_id() ) {
|
||||
$this->set_product_id( get_metadata( 'order_item', $this->get_id(), '_product_id', true ) );
|
||||
$this->set_variation_id( get_metadata( 'order_item', $this->get_id(), '_variation_id', true ) );
|
||||
$this->set_qty( get_metadata( 'order_item', $this->get_id(), '_qty', true ) );
|
||||
$this->set_quantity( get_metadata( 'order_item', $this->get_id(), '_qty', true ) );
|
||||
$this->set_tax_class( get_metadata( 'order_item', $this->get_id(), '_tax_class', true ) );
|
||||
$this->set_subtotal( get_metadata( 'order_item', $this->get_id(), '_line_subtotal', true ) );
|
||||
$this->set_subtotal_tax( get_metadata( 'order_item', $this->get_id(), '_line_subtotal_tax', true ) );
|
||||
|
@ -117,7 +117,7 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
if ( $this->get_id() ) {
|
||||
wc_update_order_item_meta( $this->get_id(), '_product_id', $this->get_product_id() );
|
||||
wc_update_order_item_meta( $this->get_id(), '_variation_id', $this->get_variation_id() );
|
||||
wc_update_order_item_meta( $this->get_id(), '_qty', $this->get_qty() );
|
||||
wc_update_order_item_meta( $this->get_id(), '_qty', $this->get_quantity() );
|
||||
wc_update_order_item_meta( $this->get_id(), '_tax_class', $this->get_tax_class() );
|
||||
wc_update_order_item_meta( $this->get_id(), '_line_subtotal', $this->get_subtotal() );
|
||||
wc_update_order_item_meta( $this->get_id(), '_line_subtotal_tax', $this->get_subtotal_tax() );
|
||||
|
@ -213,6 +213,15 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
return $product ? $product->get_tax_status() : 'taxable';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set meta data for backordered products.
|
||||
*/
|
||||
public function set_backorder_meta() {
|
||||
if ( $this->get_product()->backorders_require_notification() && $this->get_product()->is_on_backorder( $this->get_quantity() ) ) {
|
||||
$this->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ) ), $this->get_quantity() - max( 0, $this->get_product()->get_total_stock() ), true );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setters
|
||||
|
@ -220,11 +229,14 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Set qty.
|
||||
* Set quantity.
|
||||
* @param int $value
|
||||
*/
|
||||
public function set_qty( $value ) {
|
||||
$this->_data['qty'] = wc_stock_amount( $value );
|
||||
public function set_quantity( $value ) {
|
||||
if ( 0 >= $value ) {
|
||||
//$this->throw_exception( __METHOD__, 'Quantity must be positive' );
|
||||
}
|
||||
$this->_data['quantity'] = wc_stock_amount( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,6 +244,9 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
* @param string $value
|
||||
*/
|
||||
public function set_tax_class( $value ) {
|
||||
if ( $value && ! in_array( $value, WC_Tax::get_tax_classes() ) ) {
|
||||
//$this->throw_exception( __METHOD__, 'Invalid tax class' );
|
||||
}
|
||||
$this->_data['tax_class'] = $value;
|
||||
}
|
||||
|
||||
|
@ -315,13 +330,14 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
* @param WC_Product $product
|
||||
*/
|
||||
public function set_product( $product ) {
|
||||
if ( $product ) {
|
||||
$this->set_product_id( $product->get_id() );
|
||||
$this->set_name( $product->get_title() );
|
||||
$this->set_tax_class( $product->get_tax_class() );
|
||||
$this->set_variation_id( is_callable( array( $product, 'get_variation_id' ) ) ? $product->get_variation_id() : 0 );
|
||||
$this->set_variation( is_callable( array( $product, 'get_variation_attributes' ) ) ? $product->get_variation_attributes() : array() );
|
||||
if ( ! is_a( $product, 'WC_Product' ) ) {
|
||||
//$this->throw_exception( __METHOD__, 'Invalid product' );
|
||||
}
|
||||
$this->set_product_id( $product->get_id() );
|
||||
$this->set_name( $product->get_title() );
|
||||
$this->set_tax_class( $product->get_tax_class() );
|
||||
$this->set_variation_id( is_callable( array( $product, 'get_variation_id' ) ) ? $product->get_variation_id() : 0 );
|
||||
$this->set_variation( is_callable( array( $product, 'get_variation_attributes' ) ) ? $product->get_variation_attributes() : array() );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -355,11 +371,11 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get qty.
|
||||
* Get quantity.
|
||||
* @return int
|
||||
*/
|
||||
public function get_qty() {
|
||||
return wc_stock_amount( $this->_data['qty'] );
|
||||
public function get_quantity() {
|
||||
return wc_stock_amount( $this->_data['quantity'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,13 +19,13 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
|
|||
* @var array
|
||||
*/
|
||||
protected $_data = array(
|
||||
'order_id' => 0,
|
||||
'order_item_id' => 0,
|
||||
'method_title' => '',
|
||||
'method_id' => '',
|
||||
'total' => 0,
|
||||
'total_tax' => 0,
|
||||
'taxes' => array(
|
||||
'order_id' => 0,
|
||||
'id' => 0,
|
||||
'method_title' => '',
|
||||
'method_id' => '',
|
||||
'total' => 0,
|
||||
'total_tax' => 0,
|
||||
'taxes' => array(
|
||||
'total' => array()
|
||||
),
|
||||
);
|
||||
|
|
|
@ -20,7 +20,7 @@ class WC_Order_Item_Tax extends WC_Order_Item {
|
|||
*/
|
||||
protected $_data = array(
|
||||
'order_id' => 0,
|
||||
'order_item_id' => 0,
|
||||
'id' => 0,
|
||||
'rate_code' => '',
|
||||
'rate_id' => 0,
|
||||
'label' => '',
|
||||
|
|
|
@ -22,10 +22,10 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
* @var array
|
||||
*/
|
||||
protected $_data = array(
|
||||
'order_id' => 0,
|
||||
'order_item_id' => 0,
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
'order_id' => 0,
|
||||
'id' => 0, // order_item_id
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -73,8 +73,6 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
foreach ( $data as $key => $value ) {
|
||||
if ( is_callable( array( $this, "set_$key" ) ) ) {
|
||||
$this->{"set_$key"}( $value );
|
||||
} else {
|
||||
$this->_data[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,10 +87,10 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get qty.
|
||||
* Get quantity.
|
||||
* @return int
|
||||
*/
|
||||
public function get_qty() {
|
||||
public function get_quantity() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -118,7 +116,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
* @return int
|
||||
*/
|
||||
public function get_id() {
|
||||
return $this->get_order_item_id();
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,15 +124,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
* @return int
|
||||
*/
|
||||
public function get_order_id() {
|
||||
return absint( $this->_data['order_id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order item ID this meta belongs to.
|
||||
* @return int
|
||||
*/
|
||||
protected function get_order_item_id() {
|
||||
return absint( $this->_data['order_item_id'] );
|
||||
return $this->_data['order_id'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,7 +154,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
* @param int $value
|
||||
*/
|
||||
public function set_id( $value ) {
|
||||
$this->set_order_item_id( $value );
|
||||
$this->_data['id'] = absint( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,14 +165,6 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
$this->_data['order_id'] = absint( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order item ID.
|
||||
* @param int $value
|
||||
*/
|
||||
protected function set_order_item_id( $value ) {
|
||||
$this->_data['order_item_id'] = absint( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order item name.
|
||||
* @param string $value
|
||||
|
|
|
@ -1365,7 +1365,7 @@ class WC_Order extends WC_Abstract_Order {
|
|||
|
||||
foreach ( $this->get_refunds() as $refund ) {
|
||||
foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
|
||||
$count += $refunded_item->get_qty();
|
||||
$count += $refunded_item->get_quantity();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1383,7 +1383,7 @@ class WC_Order extends WC_Abstract_Order {
|
|||
$qty = 0;
|
||||
foreach ( $this->get_refunds() as $refund ) {
|
||||
foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
|
||||
$qty += $refunded_item->get_qty();
|
||||
$qty += $refunded_item->get_quantity();
|
||||
}
|
||||
}
|
||||
return $qty;
|
||||
|
@ -1401,7 +1401,7 @@ class WC_Order extends WC_Abstract_Order {
|
|||
foreach ( $this->get_refunds() as $refund ) {
|
||||
foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
|
||||
if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
|
||||
$qty += $refunded_item->get_qty();
|
||||
$qty += $refunded_item->get_quantity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -468,8 +468,11 @@ class WC_Query {
|
|||
add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
|
||||
break;
|
||||
case 'rating' :
|
||||
// Sorting handled later though a hook
|
||||
add_filter( 'posts_clauses', array( $this, 'order_by_rating_post_clauses' ) );
|
||||
$args['meta_key'] = '_wc_average_rating';
|
||||
$args['orderby'] = array(
|
||||
'meta_value_num' => 'DESC',
|
||||
'ID' => 'ASC',
|
||||
);
|
||||
break;
|
||||
case 'title' :
|
||||
$args['orderby'] = 'title';
|
||||
|
@ -498,13 +501,15 @@ class WC_Query {
|
|||
/**
|
||||
* Order by rating post clauses.
|
||||
*
|
||||
* @access public
|
||||
* @deprecated 2.7.0
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public function order_by_rating_post_clauses( $args ) {
|
||||
global $wpdb;
|
||||
|
||||
_deprecated_function( 'order_by_rating_post_clauses', '2.7', '' );
|
||||
|
||||
$args['fields'] .= ", AVG( $wpdb->commentmeta.meta_value ) as average_rating ";
|
||||
$args['where'] .= " AND ( $wpdb->commentmeta.meta_key = 'rating' OR $wpdb->commentmeta.meta_key IS null ) ";
|
||||
$args['join'] .= "
|
||||
|
|
|
@ -84,10 +84,16 @@ class WC_Shortcodes {
|
|||
private static function product_loop( $query_args, $atts, $loop_name ) {
|
||||
global $woocommerce_loop;
|
||||
|
||||
$products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $query_args, $atts, $loop_name ) );
|
||||
$columns = absint( $atts['columns'] );
|
||||
$woocommerce_loop['columns'] = $columns;
|
||||
$woocommerce_loop['name'] = $loop_name;
|
||||
$transient_name = 'wc_loop_' . $loop_name . '_' . WC_Cache_Helper::get_transient_version( 'product_query' );
|
||||
$products = get_transient( $transient_name );
|
||||
|
||||
if ( false === $products || ! is_a( $products, 'WP_Query' ) ) {
|
||||
$products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $query_args, $atts, $loop_name ) );
|
||||
set_transient( $transient_name, $products, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
|
|
|
@ -160,8 +160,11 @@ class WC_Webhook {
|
|||
// creation date to determine the actual event
|
||||
$resource = get_post( absint( $arg ) );
|
||||
|
||||
// Drafts don't have post_date_gmt so calculate it here
|
||||
$gmt_date = get_gmt_from_date( $resource->post_date );
|
||||
|
||||
// a resource is considered created when the hook is executed within 10 seconds of the post creation date
|
||||
$resource_created = ( ( time() - 10 ) <= strtotime( $resource->post_date_gmt ) );
|
||||
$resource_created = ( ( time() - 10 ) <= strtotime( $gmt_date ) );
|
||||
|
||||
if ( 'created' == $this->get_event() && ! $resource_created ) {
|
||||
$should_deliver = false;
|
||||
|
@ -266,7 +269,7 @@ class WC_Webhook {
|
|||
break;
|
||||
|
||||
case 'order':
|
||||
$payload = WC()->api->WC_API_Orders->get_order( $resource_id );
|
||||
$payload = WC()->api->WC_API_Orders->get_order( $resource_id, null, apply_filters( 'woocommerce_webhook_order_payload_filters', array() ) );
|
||||
break;
|
||||
|
||||
case 'product':
|
||||
|
|
|
@ -676,7 +676,7 @@ class WC_CLI_Order extends WC_CLI_Command {
|
|||
),
|
||||
'note' => $order->get_customer_note(),
|
||||
'customer_ip' => $order->get_customer_ip_address(),
|
||||
'customer_user_agent' => $order->get_user_agent(),
|
||||
'customer_user_agent' => $order->get_customer_user_agent(),
|
||||
'customer_id' => $order->get_user_id(),
|
||||
'view_order_url' => $order->get_view_order_url(),
|
||||
'line_items' => array(),
|
||||
|
@ -718,7 +718,7 @@ class WC_CLI_Order extends WC_CLI_Command {
|
|||
'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ),
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'name' => $item['name'],
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $product_id,
|
||||
'sku' => $product_sku,
|
||||
'meta' => $item_meta,
|
||||
|
|
|
@ -218,7 +218,7 @@ class WC_Gateway_Paypal_Request {
|
|||
$item_names = array();
|
||||
|
||||
foreach ( $order->get_items() as $item ) {
|
||||
$item_names[] = $item['name'] . ' x ' . $item['qty'];
|
||||
$item_names[] = $item->get_name() . ' x ' . $item['qty'];
|
||||
}
|
||||
|
||||
return implode( ', ', $item_names );
|
||||
|
@ -231,7 +231,7 @@ class WC_Gateway_Paypal_Request {
|
|||
* @return string
|
||||
*/
|
||||
protected function get_order_item_name( $order, $item ) {
|
||||
$item_name = $item['name'];
|
||||
$item_name = $item->get_name();
|
||||
$item_meta = new WC_Order_Item_Meta( $item );
|
||||
|
||||
if ( $meta = $item_meta->display( true, true ) ) {
|
||||
|
@ -268,7 +268,7 @@ class WC_Gateway_Paypal_Request {
|
|||
foreach ( $order->get_items( array( 'line_item', 'fee' ) ) as $item ) {
|
||||
if ( 'fee' === $item['type'] ) {
|
||||
$item_line_total = $this->number_format( $item['line_total'], $order );
|
||||
$line_item = $this->add_line_item( $item['name'], 1, $item_line_total );
|
||||
$line_item = $this->add_line_item( $item->get_name(), 1, $item_line_total );
|
||||
$calculated_total += $item_line_total;
|
||||
} else {
|
||||
$product = $order->get_product_from_item( $item );
|
||||
|
|
|
@ -1416,3 +1416,18 @@ function wc_get_logger() {
|
|||
$class = apply_filters( 'woocommerce_logging_class', 'WC_Logger' );
|
||||
return new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a deprecated action with notice only if used.
|
||||
* @since 2.7.0
|
||||
* @param string $action
|
||||
* @param array $args
|
||||
* @param string $deprecated_in
|
||||
* @param string $replacement
|
||||
*/
|
||||
function wc_do_deprecated_action( $action, $args, $deprecated_in, $replacement ) {
|
||||
if ( has_action( $action ) ) {
|
||||
_deprecated_function( 'Action: ' . $action, $deprecated_in, $replacement );
|
||||
do_action_ref_array( $action, $args );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -663,14 +663,12 @@ function wc_format_postcode( $postcode, $country ) {
|
|||
$postcode = trim( substr_replace( $postcode, ' ', -3, 0 ) );
|
||||
break;
|
||||
case 'BR' :
|
||||
case 'PL' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', -3, 0 ) );
|
||||
break;
|
||||
case 'JP' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', 3, 0 ) );
|
||||
break;
|
||||
case 'PL' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', -3, 0 ) );
|
||||
break;
|
||||
case 'PT' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', 4, 0 ) );
|
||||
break;
|
||||
|
|
|
@ -95,6 +95,18 @@ function wc_prevent_endpoint_indexing() {
|
|||
}
|
||||
add_action( 'template_redirect', 'wc_prevent_endpoint_indexing' );
|
||||
|
||||
/**
|
||||
* Remove adjacent_posts_rel_link_wp_head - pointless for products.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
function wc_prevent_adjacent_posts_rel_link_wp_head() {
|
||||
if ( is_singular( 'product' ) ) {
|
||||
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'wc_prevent_adjacent_posts_rel_link_wp_head' );
|
||||
|
||||
/**
|
||||
* When the_post is called, put product data into a global.
|
||||
*
|
||||
|
@ -567,7 +579,9 @@ if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
|
|||
* Show the product title in the product loop. By default this is an H3.
|
||||
*/
|
||||
function woocommerce_template_loop_product_title() {
|
||||
echo '<h3>' . get_the_title() . '</h3>';
|
||||
$tag = is_product_taxonomy() || is_shop() ? 'h2' : 'h3';
|
||||
|
||||
echo '<' . $tag . ' class="woocommerce-loop-product__title">' . get_the_title() . '</' . $tag . '>';
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'woocommerce_template_loop_category_title' ) ) {
|
||||
|
@ -577,14 +591,14 @@ if ( ! function_exists( 'woocommerce_template_loop_category_title' ) ) {
|
|||
*/
|
||||
function woocommerce_template_loop_category_title( $category ) {
|
||||
?>
|
||||
<h3>
|
||||
<h2 class="woocommerce-loop-category__title">
|
||||
<?php
|
||||
echo $category->name;
|
||||
|
||||
if ( $category->count > 0 )
|
||||
echo apply_filters( 'woocommerce_subcategory_count_html', ' <mark class="count">(' . $category->count . ')</mark>', $category );
|
||||
?>
|
||||
</h3>
|
||||
</h2>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ function wc_customer_has_capability( $allcaps, $caps, $args ) {
|
|||
}
|
||||
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( $user_id == $order->get_user_id() || empty( $order->get_user_id() ) ) {
|
||||
if ( $user_id == $order->get_user_id() || ! $order->get_user_id() ) {
|
||||
$allcaps['pay_for_order'] = true;
|
||||
}
|
||||
break;
|
||||
|
@ -453,7 +453,7 @@ function wc_get_customer_available_downloads( $customer_id ) {
|
|||
home_url( '/' )
|
||||
),
|
||||
'download_id' => $result->download_id,
|
||||
'product_id' => $product_id,
|
||||
'product_id' => $_product->id,
|
||||
'download_name' => $download_name,
|
||||
'order_id' => $order->get_id(),
|
||||
'order_key' => $order->get_order_key(),
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @version 2.7.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
class WC_Widget_Top_Rated_Products extends WC_Widget {
|
||||
|
@ -62,9 +62,15 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
|
|||
|
||||
$number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std'];
|
||||
|
||||
add_filter( 'posts_clauses', array( WC()->query, 'order_by_rating_post_clauses' ) );
|
||||
|
||||
$query_args = array( 'posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product' );
|
||||
$query_args = array(
|
||||
'posts_per_page' => $number,
|
||||
'no_found_rows' => 1,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'meta_key' => '_wc_average_rating',
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'DESC',
|
||||
);
|
||||
|
||||
$query_args['meta_query'] = WC()->query->get_meta_query();
|
||||
|
||||
|
@ -86,8 +92,6 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
|
|||
$this->widget_end( $args );
|
||||
}
|
||||
|
||||
remove_filter( 'posts_clauses', array( WC()->query, 'order_by_rating_post_clauses' ) );
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$content = ob_get_clean();
|
||||
|
|
12
readme.txt
12
readme.txt
|
@ -2,7 +2,7 @@
|
|||
Contributors: automattic, mikejolley, jameskoster, claudiosanches, jshreve, coderkevin, woothemes, BFTrick, iCaleb
|
||||
Tags: ecommerce, e-commerce, store, sales, sell, shop, cart, checkout, downloadable, downloads, paypal, storefront
|
||||
Requires at least: 4.4
|
||||
Tested up to: 4.5
|
||||
Tested up to: 4.6
|
||||
Stable tag: 2.6.3
|
||||
License: GPLv3
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
@ -88,10 +88,13 @@ And, finally, consider joining or spearheading a WooCommerce Meetup locally, mor
|
|||
|
||||
= Minimum Requirements =
|
||||
|
||||
* WordPress 3.8 or greater
|
||||
* PHP version 5.2.4 or greater
|
||||
* MySQL version 5.0 or greater
|
||||
* PHP version 5.2.4 or greater (PHP 5.6 or greater is recommended)
|
||||
* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended)
|
||||
* Some payment gateways require fsockopen support (for IPN access)
|
||||
* WooCommerce 2.5 requires WordPress 4.1+
|
||||
* WooCommerce 2.6 requires WordPress 4.4+
|
||||
|
||||
Visit the [WooCommerce server requirements documentation](https://docs.woocommerce.com/document/server-requirements/) for a detailed list of server requirements.
|
||||
|
||||
= Automatic installation =
|
||||
|
||||
|
@ -168,6 +171,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Show variable weights/dimensions even when parent values are not set.
|
||||
* Automatically sort tax rates rather than allow clunky manual sorting.
|
||||
* Made WC_Logger pluggable via wc_get_logger function.
|
||||
* Use 'average rating' post meta for 'rating' product sorting option.
|
||||
|
||||
[See changelog for all versions](https://raw.githubusercontent.com/woothemes/woocommerce/master/CHANGELOG.txt).
|
||||
|
||||
|
|
|
@ -42,14 +42,14 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
|
||||
<td class="product-name">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_order_item_name', esc_html( $item['name'] ), $item, false );
|
||||
echo apply_filters( 'woocommerce_order_item_name', esc_html( $item->get_name() ), $item, false );
|
||||
|
||||
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
|
||||
$order->display_item_meta( $item );
|
||||
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order );
|
||||
?>
|
||||
</td>
|
||||
<td class="product-quantity"><?php echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', esc_html( $item['qty'] ) ) . '</strong>', $item ); ?></td>
|
||||
<td class="product-quantity"><?php echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', esc_html( $item->get_quantity() ) ) . '</strong>', $item ); ?></td>
|
||||
<td class="product-subtotal"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -33,7 +33,7 @@ foreach ( $items as $item_id => $item ) :
|
|||
}
|
||||
|
||||
// Product name
|
||||
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false );
|
||||
echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false );
|
||||
|
||||
// SKU
|
||||
if ( $show_sku && is_object( $product ) && $product->get_sku() ) {
|
||||
|
@ -53,7 +53,7 @@ foreach ( $items as $item_id => $item ) :
|
|||
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
|
||||
|
||||
?></td>
|
||||
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item ); ?></td>
|
||||
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
|
||||
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -27,7 +27,7 @@ foreach ( $items as $item_id => $item ) :
|
|||
if ( $show_sku && $product->get_sku() ) {
|
||||
echo ' (#' . $product->get_sku() . ')';
|
||||
}
|
||||
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item );
|
||||
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item );
|
||||
echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n";
|
||||
// allow other plugins to add additional product information here
|
||||
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
|
||||
|
|
|
@ -30,8 +30,8 @@ if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
|
|||
$is_visible = $product && $product->is_visible();
|
||||
$product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order );
|
||||
|
||||
echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '<a href="%s">%s</a>', $product_permalink, $item['name'] ) : $item['name'], $item, $is_visible );
|
||||
echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', $item['qty'] ) . '</strong>', $item );
|
||||
echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '<a href="%s">%s</a>', $product_permalink, $item->get_name() ) : $item->get_name(), $item, $is_visible );
|
||||
echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', $item->get_quantity() ) . '</strong>', $item );
|
||||
|
||||
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ if ( ! comments_open() ) {
|
|||
<div id="comments">
|
||||
<h2 class="woocommerce-Reviews-title"><?php
|
||||
if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' && ( $count = $product->get_review_count() ) )
|
||||
printf( _n( '%s review for %s%s%s', '%s reviews for %s%s%s', $count, 'woocommerce' ), $count, '<span>', get_the_title(), '</span>' );
|
||||
printf( esc_html( _n( '%s review for %s%s%s', '%s reviews for %s%s%s', $count, 'woocommerce' ) ), $count, '<span>', get_the_title(), '</span>' );
|
||||
else
|
||||
_e( 'Reviews', 'woocommerce' );
|
||||
?></h2>
|
||||
|
@ -68,6 +68,8 @@ if ( ! comments_open() ) {
|
|||
$comment_form = array(
|
||||
'title_reply' => have_comments() ? __( 'Add a review', 'woocommerce' ) : sprintf( __( 'Be the first to review “%s”', 'woocommerce' ), get_the_title() ),
|
||||
'title_reply_to' => __( 'Leave a Reply to %s', 'woocommerce' ),
|
||||
'title_reply_before' => '<span id="reply-title" class="comment-reply-title">',
|
||||
'title_reply_after' => '</span>',
|
||||
'comment_notes_after' => '',
|
||||
'fields' => array(
|
||||
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'woocommerce' ) . ' <span class="required">*</span></label> ' .
|
||||
|
|
|
@ -25,7 +25,7 @@ $attribute_keys = array_keys( $attributes );
|
|||
|
||||
do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
||||
|
||||
<form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->id ); ?>" data-product_variations="<?php echo htmlspecialchars( json_encode( $available_variations ) ) ?>">
|
||||
<form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->id ); ?>" data-product_variations="<?php echo htmlspecialchars( wp_json_encode( $available_variations ) ) ?>">
|
||||
<?php do_action( 'woocommerce_before_variations_form' ); ?>
|
||||
|
||||
<?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
|
||||
|
|
|
@ -46,9 +46,9 @@ $woocommerce_loop['columns'] = apply_filters( 'woocommerce_related_products_colu
|
|||
|
||||
if ( $products->have_posts() ) : ?>
|
||||
|
||||
<div class="related products">
|
||||
<section class="related products">
|
||||
|
||||
<h2><?php _e( 'Related Products', 'woocommerce' ); ?></h2>
|
||||
<h2><?php esc_html_e( 'Related Products', 'woocommerce' ); ?></h2>
|
||||
|
||||
<?php woocommerce_product_loop_start(); ?>
|
||||
|
||||
|
@ -60,7 +60,7 @@ if ( $products->have_posts() ) : ?>
|
|||
|
||||
<?php woocommerce_product_loop_end(); ?>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php endif;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
|
||||
global $product;
|
||||
|
||||
$heading = apply_filters( 'woocommerce_product_additional_information_heading', __( 'Additional Information', 'woocommerce' ) );
|
||||
$heading = esc_html( apply_filters( 'woocommerce_product_additional_information_heading', __( 'Additional Information', 'woocommerce' ) ) );
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
|
||||
global $post;
|
||||
|
||||
$heading = esc_html( apply_filters( 'woocommerce_product_description_heading', __( 'Product Description', 'woocommerce' ) ) );
|
||||
$heading = esc_html( apply_filters( 'woocommerce_product_description_heading', __( 'Description', 'woocommerce' ) ) );
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ $woocommerce_loop['columns'] = apply_filters( 'woocommerce_up_sells_columns', $c
|
|||
|
||||
if ( $products->have_posts() ) : ?>
|
||||
|
||||
<div class="up-sells upsells products">
|
||||
<section class="up-sells upsells products">
|
||||
|
||||
<h2><?php _e( 'You may also like…', 'woocommerce' ) ?></h2>
|
||||
<h2><?php esc_html_e( 'You may also like…', 'woocommerce' ) ?></h2>
|
||||
|
||||
<?php woocommerce_product_loop_start(); ?>
|
||||
|
||||
|
@ -57,7 +57,7 @@ if ( $products->have_posts() ) : ?>
|
|||
|
||||
<?php woocommerce_product_loop_end(); ?>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php endif;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class WC_Helper_Order {
|
|||
$order = wc_create_order( $order_data );
|
||||
|
||||
// Add order products
|
||||
$item_id = $order->add_product( $product, array( 'qty' => 4 ) );
|
||||
$item_id = $order->add_product( $product, 4 );
|
||||
|
||||
// Set billing address
|
||||
$billing_address = array(
|
||||
|
@ -84,9 +84,8 @@ class WC_Helper_Order {
|
|||
$order->set_cart_tax( 0 );
|
||||
$order->set_shipping_tax( 0 );
|
||||
$order->set_total( 40 ); // 4 x $10 simple helper product
|
||||
|
||||
$order->save();
|
||||
|
||||
return wc_get_order( $order->get_id() );
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
<?php
|
||||
namespace WooCommerce\Tests\API;
|
||||
|
||||
/**
|
||||
* Coupon API Tests
|
||||
* @package WooCommerce\Tests\API
|
||||
* @since 2.7.0
|
||||
*/
|
||||
class Coupons extends \WC_API_Unit_Test_Case {
|
||||
class WC_Tests_API_Coupons extends WC_API_Unit_Test_Case {
|
||||
|
||||
/** @var \WC_API_Coupons instance */
|
||||
/** @var WC_API_Coupons instance */
|
||||
protected $endpoint;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +17,7 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->endpoint = WC()->api->WC_API_Coupons;
|
||||
$this->coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$this->coupon = WC_Helper_Coupon::create_coupon();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,7 +194,7 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
$response = $this->endpoint->create_coupon( $this->get_defaults() );
|
||||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupon', $response );
|
||||
$this->check_get_coupon_response( $response['coupon'], new \WC_Coupon( $response['coupon']['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupon'], new WC_Coupon( $response['coupon']['code'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +259,7 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
|
||||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupon', $response );
|
||||
$this->check_get_coupon_response( $response['coupon'], new \WC_Coupon( $response['coupon']['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupon'], new WC_Coupon( $response['coupon']['code'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,8 +299,8 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupons', $response );
|
||||
$this->assertCount( 2, $response['coupons'] );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new \WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][1], new \WC_Coupon( $response['coupons'][1]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][1], new WC_Coupon( $response['coupons'][1]['code'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,14 +308,14 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_edit_coupon_bulk() {
|
||||
$coupon_1 = \WC_Helper_Coupon::create_coupon( 'dummycoupon-1-' . time() );
|
||||
$coupon_1 = WC_Helper_Coupon::create_coupon( 'dummycoupon-1-' . time() );
|
||||
$test_coupon_data = $this->get_defaults( array( 'description' => rand_str() ) );
|
||||
$test_coupon_data['coupon']['id'] = $coupon_1->get_id();
|
||||
$coupons = array( 'coupons' => array( $test_coupon_data['coupon'] ) );
|
||||
$response = $this->endpoint->bulk( $coupons );
|
||||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupons', $response );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new \WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,28 +1,419 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class Functions.
|
||||
* Tests for the orders REST API.
|
||||
*
|
||||
* @package WooCommerce\Tests\API
|
||||
* @since 2.4
|
||||
* @since 2.7.0
|
||||
*/
|
||||
class WC_Tests_API_Orders extends WC_API_Unit_Test_Case {
|
||||
class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test test_wc_api_order_get_variation_id_returns_correct_id.
|
||||
*
|
||||
* @since 2.4
|
||||
* Array of order to track
|
||||
* @var array
|
||||
*/
|
||||
public function test_wc_api_order_get_variation_id_returns_correct_id() {
|
||||
protected $orders = array();
|
||||
|
||||
/**
|
||||
* Setup our test server.
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$product = WC_Helper_Product::create_variation_product();
|
||||
$orders_api = WC()->api->WC_API_Orders;
|
||||
|
||||
$variation_id = $orders_api->get_variation_id( $product, array( 'size' => 'small' ) );
|
||||
$this->assertSame( ( $product->id + 1 ), $variation_id );
|
||||
|
||||
$variation_id = $orders_api->get_variation_id( $product, array( 'size' => 'large' ) );
|
||||
$this->assertSame( ( $product->id + 2 ), $variation_id );
|
||||
$this->endpoint = new WC_REST_Orders_Controller();
|
||||
$this->user = $this->factory->user->create( array(
|
||||
'role' => 'administrator',
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test route registration.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_register_routes() {
|
||||
$routes = $this->server->get_routes();
|
||||
$this->assertArrayHasKey( '/wc/v1/orders', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v1/orders/batch', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v1/orders/(?P<id>[\d]+)', $routes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup.
|
||||
*/
|
||||
public function stoppit_and_tidyup() {
|
||||
foreach ( $this->orders as $order ) {
|
||||
wp_delete_post( $order->get_id(), true );
|
||||
}
|
||||
$this->orders = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting all orders.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_items() {
|
||||
wp_set_current_user( $this->user );
|
||||
|
||||
// Create 10 orders.
|
||||
for ( $i = 0; $i < 10; $i++ ) {
|
||||
$this->orders[] = WC_Helper_Order::create_order( $this->user );
|
||||
}
|
||||
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/orders' ) );
|
||||
$orders = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 10, count( $orders ) );
|
||||
$this->stoppit_and_tidyup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to make sure orders cannot be viewed without valid permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_items_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$this->orders[] = WC_Helper_Order::create_order();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/orders' ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$this->stoppit_and_tidyup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting a single order.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_item() {
|
||||
wp_set_current_user( $this->user );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$this->orders[] = $order;
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/orders/' . $order->get_id() ) );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( $order->get_id(), $data['id'] );
|
||||
$this->stoppit_and_tidyup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting a single order without the correct permissions.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_item_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$this->orders[] = $order;
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/orders/' . $order->get_id() ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$this->stoppit_and_tidyup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting an order with an invalid ID.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_item_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/orders/99999999' ) );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creating an order.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_create_order() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/orders' );
|
||||
$request->set_body_params( array(
|
||||
'payment_method' => 'bacs',
|
||||
'payment_method_title' => 'Direct Bank Transfer',
|
||||
'set_paid' => true,
|
||||
'billing' => array(
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
'address_1' => '969 Market',
|
||||
'address_2' => '',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94103',
|
||||
'country' => 'US',
|
||||
'email' => 'john.doe@example.com',
|
||||
'phone' => '(555) 555-5555'
|
||||
),
|
||||
'shipping' => array(
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
'address_1' => '969 Market',
|
||||
'address_2' => '',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94103',
|
||||
'country' => 'US',
|
||||
),
|
||||
'line_items' => array(
|
||||
array(
|
||||
'product_id' => $product->get_id(),
|
||||
'quantity' => 2
|
||||
),
|
||||
),
|
||||
'shipping_lines' => array(
|
||||
array(
|
||||
'method_id' => 'flat_rate',
|
||||
'method_title' => 'Flat Rate',
|
||||
'total' => 10
|
||||
),
|
||||
),
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$order = wc_get_order( $data['id'] );
|
||||
$this->assertEquals( 201, $response->get_status() );
|
||||
$this->assertEquals( $order->get_payment_method(), $data['payment_method'] );
|
||||
$this->assertEquals( $order->get_payment_method_title(), $data['payment_method_title'] );
|
||||
$this->assertEquals( $order->get_billing_first_name(), $data['billing']['first_name'] );
|
||||
$this->assertEquals( $order->get_billing_last_name(), $data['billing']['last_name'] );
|
||||
$this->assertEquals( '', $data['billing']['company'] );
|
||||
$this->assertEquals( $order->get_billing_address_1(), $data['billing']['address_1'] );
|
||||
$this->assertEquals( $order->get_billing_address_2(), $data['billing']['address_2'] );
|
||||
$this->assertEquals( $order->get_billing_city(), $data['billing']['city'] );
|
||||
$this->assertEquals( $order->get_billing_state(), $data['billing']['state'] );
|
||||
$this->assertEquals( $order->get_billing_postcode(), $data['billing']['postcode'] );
|
||||
$this->assertEquals( $order->get_billing_country(), $data['billing']['country'] );
|
||||
$this->assertEquals( $order->get_billing_email(), $data['billing']['email'] );
|
||||
$this->assertEquals( $order->get_billing_phone(), $data['billing']['phone'] );
|
||||
$this->assertEquals( $order->get_shipping_first_name(), $data['shipping']['first_name'] );
|
||||
$this->assertEquals( $order->get_shipping_last_name(), $data['shipping']['last_name'] );
|
||||
$this->assertEquals( '', $data['shipping']['company'] );
|
||||
$this->assertEquals( $order->get_shipping_address_1(), $data['shipping']['address_1'] );
|
||||
$this->assertEquals( $order->get_shipping_address_2(), $data['shipping']['address_2'] );
|
||||
$this->assertEquals( $order->get_shipping_city(), $data['shipping']['city'] );
|
||||
$this->assertEquals( $order->get_shipping_state(), $data['shipping']['state'] );
|
||||
$this->assertEquals( $order->get_shipping_postcode(), $data['shipping']['postcode'] );
|
||||
$this->assertEquals( $order->get_shipping_country(), $data['shipping']['country'] );
|
||||
$this->assertEquals( 1, count( $data['line_items'] ) );
|
||||
$this->assertEquals( 1, count( $data['shipping_lines'] ) );
|
||||
|
||||
wp_delete_post( $product->get_id(), true );
|
||||
wp_delete_post( $data['id'], true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creating an order without required fields.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_create_order_invalid_fields() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
// non-existant customer
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/orders' );
|
||||
$request->set_body_params( array(
|
||||
'payment_method' => 'bacs',
|
||||
'payment_method_title' => 'Direct Bank Transfer',
|
||||
'set_paid' => true,
|
||||
'customer_id' => 99999,
|
||||
'billing' => array(
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
'address_1' => '969 Market',
|
||||
'address_2' => '',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94103',
|
||||
'country' => 'US',
|
||||
'email' => 'john.doe@example.com',
|
||||
'phone' => '(555) 555-5555'
|
||||
),
|
||||
'shipping' => array(
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
'address_1' => '969 Market',
|
||||
'address_2' => '',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94103',
|
||||
'country' => 'US',
|
||||
),
|
||||
'line_items' => array(
|
||||
array(
|
||||
'product_id' => $product->get_id(),
|
||||
'quantity' => 2
|
||||
),
|
||||
),
|
||||
'shipping_lines' => array(
|
||||
array(
|
||||
'method_id' => 'flat_rate',
|
||||
'method_title' => 'Flat Rate',
|
||||
'total' => 10
|
||||
),
|
||||
),
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
wp_delete_post( $product->get_id(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests updating an order.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_order() {
|
||||
wp_set_current_user( $this->user );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/orders/' . $order->get_id() );
|
||||
$request->set_body_params( array(
|
||||
'payment_method' => 'test-update',
|
||||
'billing' => array(
|
||||
'first_name' => 'Fish',
|
||||
'last_name' => 'Face',
|
||||
),
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 'test-update', $data['payment_method'] );
|
||||
$this->assertEquals( 'Fish', $data['billing']['first_name'] );
|
||||
$this->assertEquals( 'Face', $data['billing']['last_name'] );
|
||||
|
||||
wp_delete_post( $order->get_id(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests updating an order without the correct permissions.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_order_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/orders/' . $order->get_id() );
|
||||
$request->set_body_params( array(
|
||||
'payment_method' => 'test-update',
|
||||
'billing' => array(
|
||||
'first_name' => 'Fish',
|
||||
'last_name' => 'Face',
|
||||
),
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that updating an order with an invalid id fails.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_order_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/orders/999999' );
|
||||
$request->set_body_params( array(
|
||||
'payment_method' => 'test-update',
|
||||
'billing' => array(
|
||||
'first_name' => 'Fish',
|
||||
'last_name' => 'Face',
|
||||
),
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting an order.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_order() {
|
||||
wp_set_current_user( $this->user );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/orders/' . $order->get_id() );
|
||||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( null, get_post( $order->get_id() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting an order without permission/creds.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_order_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/orders/' . $order->get_id() );
|
||||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
wp_delete_post( $order->get_id(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting an order with an invalid id.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_order_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/orders/9999999' );
|
||||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch managing product reviews.
|
||||
*/
|
||||
public function test_orders_batch() {
|
||||
wp_set_current_user( $this->user );
|
||||
|
||||
$order1 = WC_Helper_Order::create_order();
|
||||
$order2 = WC_Helper_Order::create_order();
|
||||
$order3 = WC_Helper_Order::create_order();
|
||||
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/orders/batch' );
|
||||
$request->set_body_params( array(
|
||||
'update' => array(
|
||||
array(
|
||||
'id' => $order1->get_id(),
|
||||
'payment_method' => 'updated',
|
||||
),
|
||||
),
|
||||
'delete' => array(
|
||||
$order2->get_id(),
|
||||
$order3->get_id(),
|
||||
),
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 'updated', $data['update'][0]['payment_method'] );
|
||||
$this->assertEquals( $order2->get_id(), $data['delete'][0]['id'] );
|
||||
$this->assertEquals( $order3->get_id(), $data['delete'][1]['id'] );
|
||||
|
||||
$request = new WP_REST_Request( 'GET', '/wc/v1/orders' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 1, count( $data ) );
|
||||
|
||||
wp_delete_post( $order1->get_id(), true );
|
||||
wp_delete_post( $order2->get_id(), true );
|
||||
wp_delete_post( $order3->get_id(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the order schema.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_order_schema() {
|
||||
wp_set_current_user( $this->user );
|
||||
$order = WC_Helper_Order::create_order();
|
||||
$request = new WP_REST_Request( 'OPTIONS', '/wc/v1/orders/' . $order->get_id() );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$properties = $data['schema']['properties'];
|
||||
|
||||
$this->assertEquals( 38, count( $properties ) );
|
||||
$this->assertArrayHasKey( 'id', $properties );
|
||||
wp_delete_post( $order->get_id(), true );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->endpoint = new WC_REST_Product_Reviews_Controller();
|
||||
$this->user = $this->factory->user->create( array(
|
||||
'role' => 'administrator',
|
||||
) );
|
||||
$this->user = $this->factory->user->create( array(
|
||||
'role' => 'administrator',
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test route registration.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_register_routes() {
|
||||
$routes = $this->server->get_routes();
|
||||
|
@ -30,311 +30,311 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$this->assertArrayHasKey( '/wc/v1/products/(?P<product_id>[\d]+)/reviews/(?P<id>[\d]+)', $routes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting all product reviews.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_reviews() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
// Create 10 products reviews for the product
|
||||
for ( $i = 0; $i < 10; $i++ ) {
|
||||
WC_Helper_Product::create_product_review( $product->id );
|
||||
}
|
||||
/**
|
||||
* Test getting all product reviews.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_reviews() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
// Create 10 products reviews for the product
|
||||
for ( $i = 0; $i < 10; $i++ ) {
|
||||
$review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
}
|
||||
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews' ) );
|
||||
$product_reviews = $response->get_data();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews' ) );
|
||||
$product_reviews = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 10, count( $product_reviews ) );
|
||||
$this->assertContains( array(
|
||||
'id' => 2,
|
||||
'date_created' => '2016-01-01T11:11:11',
|
||||
'review' => 'Review content here',
|
||||
'rating' => 0,
|
||||
'name' => 'admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
'_links' => array(
|
||||
'self' => array(
|
||||
array(
|
||||
'href' => rest_url( '/wc/v1/products/' . $product->id . '/reviews/2' ),
|
||||
),
|
||||
),
|
||||
'collection' => array(
|
||||
array(
|
||||
'href' => rest_url( '/wc/v1/products/' . $product->id . '/reviews' ),
|
||||
),
|
||||
),
|
||||
'up' => array(
|
||||
array(
|
||||
'href' => rest_url( '/wc/v1/products/' . $product->id ),
|
||||
),
|
||||
),
|
||||
),
|
||||
), $product_reviews );
|
||||
}
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 10, count( $product_reviews ) );
|
||||
$this->assertContains( array(
|
||||
'id' => $review_id,
|
||||
'date_created' => '2016-01-01T11:11:11',
|
||||
'review' => 'Review content here',
|
||||
'rating' => 0,
|
||||
'name' => 'admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
'_links' => array(
|
||||
'self' => array(
|
||||
array(
|
||||
'href' => rest_url( '/wc/v1/products/' . $product->id . '/reviews/' . $review_id ),
|
||||
),
|
||||
),
|
||||
'collection' => array(
|
||||
array(
|
||||
'href' => rest_url( '/wc/v1/products/' . $product->id . '/reviews' ),
|
||||
),
|
||||
),
|
||||
'up' => array(
|
||||
array(
|
||||
'href' => rest_url( '/wc/v1/products/' . $product->id ),
|
||||
),
|
||||
),
|
||||
),
|
||||
), $product_reviews );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to make sure product reviews cannot be viewed without valid permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_reviews_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
/**
|
||||
* Tests to make sure product reviews cannot be viewed without valid permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_reviews_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews' ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to make sure an error is returned when an invalid product is loaded.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_reviews_invalid_product() {
|
||||
wp_set_current_user( $this->user );
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/0/reviews' ) );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
/**
|
||||
* Tests to make sure an error is returned when an invalid product is loaded.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_reviews_invalid_product() {
|
||||
wp_set_current_user( $this->user );
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/0/reviews' ) );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting a single product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
/**
|
||||
* Tests getting a single product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id ) );
|
||||
$data = $response->get_data();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id ) );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( array(
|
||||
'id' => $product_review_id ,
|
||||
'date_created' => '2016-01-01T11:11:11',
|
||||
'review' => 'Review content here',
|
||||
'rating' => 0,
|
||||
'name' => 'admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
), $data );
|
||||
}
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( array(
|
||||
'id' => $product_review_id ,
|
||||
'date_created' => '2016-01-01T11:11:11',
|
||||
'review' => 'Review content here',
|
||||
'rating' => 0,
|
||||
'name' => 'admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
), $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting a single product review without the correct permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_review_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
/**
|
||||
* Tests getting a single product review without the correct permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_review_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting a product review with an invalid ID.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_review_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/0' ) );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creating a product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_create_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'rating' => '5',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 201, $response->get_status() );
|
||||
$this->assertEquals( array(
|
||||
'id' => $data['id'],
|
||||
'date_created' => $data['date_created'],
|
||||
'review' => 'Hello world.',
|
||||
'rating' => 5,
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
), $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creating a product review without required fields.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_create_product_review_invalid_fields() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
// missing review
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.local',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
|
||||
// missing name
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'email' => 'woo@woo.local',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
|
||||
// missing email
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests updating a product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id ) );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 'Review content here', $data['review'] );
|
||||
$this->assertEquals( 'admin', $data['name'] );
|
||||
$this->assertEquals( 'woo@woo.local', $data['email'] );
|
||||
$this->assertEquals( 0, $data['rating'] );
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world - updated.',
|
||||
'name' => 'Justin',
|
||||
'email' => 'woo2@woo.local',
|
||||
'rating' => 3,
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 'Hello world - updated.', $data['review'] );
|
||||
$this->assertEquals( 'Justin', $data['name'] );
|
||||
$this->assertEquals( 'woo2@woo.local', $data['email'] );
|
||||
$this->assertEquals( 3, $data['rating'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests updating a product review without the correct permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_product_review_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.dev',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that updating a product review with an invalid id fails.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_product_review_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', '/wc/v1/products/' . $product->id . '/reviews/0' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.dev',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_product_review() {
|
||||
/**
|
||||
* Tests getting a product review with an invalid ID.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_product_review_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/0' ) );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
}
|
||||
/**
|
||||
* Tests creating a product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_create_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'rating' => '5',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
/**
|
||||
* Test deleting a product review without permission/creds.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_product_without_permission() {
|
||||
$this->assertEquals( 201, $response->get_status() );
|
||||
$this->assertEquals( array(
|
||||
'id' => $data['id'],
|
||||
'date_created' => $data['date_created'],
|
||||
'review' => 'Hello world.',
|
||||
'rating' => 5,
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
), $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creating a product review without required fields.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_create_product_review_invalid_fields() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
// missing review
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.local',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
|
||||
// missing name
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'email' => 'woo@woo.local',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
|
||||
// missing email
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests updating a product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id ) );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 'Review content here', $data['review'] );
|
||||
$this->assertEquals( 'admin', $data['name'] );
|
||||
$this->assertEquals( 'woo@woo.local', $data['email'] );
|
||||
$this->assertEquals( 0, $data['rating'] );
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world - updated.',
|
||||
'name' => 'Justin',
|
||||
'email' => 'woo2@woo.local',
|
||||
'rating' => 3,
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 'Hello world - updated.', $data['review'] );
|
||||
$this->assertEquals( 'Justin', $data['name'] );
|
||||
$this->assertEquals( 'woo2@woo.local', $data['email'] );
|
||||
$this->assertEquals( 3, $data['rating'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests updating a product review without the correct permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_product_review_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$request = new WP_REST_Request( 'PUT', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.dev',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a product review with an invalid id.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_product_review_invalid_id() {
|
||||
/**
|
||||
* Tests that updating a product review with an invalid id fails.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_product_review_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', '/wc/v1/products/' . $product->id . '/reviews/0' );
|
||||
$request->set_body_params( array(
|
||||
'review' => 'Hello world.',
|
||||
'name' => 'Admin',
|
||||
'email' => 'woo@woo.dev',
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a product review.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_product_review() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a product review without permission/creds.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_product_without_permission() {
|
||||
wp_set_current_user( 0 );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
||||
$request = new WP_REST_Request( 'DELETE', '/wc/v1/products/' . $product->id . '/reviews/' . $product_review_id );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a product review with an invalid id.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_product_review_invalid_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product_review_id = WC_Helper_Product::create_product_review( $product->id );
|
||||
|
@ -344,7 +344,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch managing product reviews.
|
||||
|
@ -397,27 +397,27 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$this->assertEquals( 3, count( $data ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the product review schema.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_product_review_schema() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$request = new WP_REST_Request( 'OPTIONS', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$properties = $data['schema']['properties'];
|
||||
/**
|
||||
* Test the product review schema.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_product_review_schema() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$request = new WP_REST_Request( 'OPTIONS', '/wc/v1/products/' . $product->id . '/reviews' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$properties = $data['schema']['properties'];
|
||||
|
||||
$this->assertEquals( 7, count( $properties ) );
|
||||
$this->assertArrayHasKey( 'id', $properties );
|
||||
$this->assertArrayHasKey( 'review', $properties );
|
||||
$this->assertArrayHasKey( 'date_created', $properties );
|
||||
$this->assertArrayHasKey( 'rating', $properties );
|
||||
$this->assertArrayHasKey( 'name', $properties );
|
||||
$this->assertArrayHasKey( 'email', $properties );
|
||||
$this->assertArrayHasKey( 'verified', $properties );
|
||||
}
|
||||
$this->assertEquals( 7, count( $properties ) );
|
||||
$this->assertArrayHasKey( 'id', $properties );
|
||||
$this->assertArrayHasKey( 'review', $properties );
|
||||
$this->assertArrayHasKey( 'date_created', $properties );
|
||||
$this->assertArrayHasKey( 'rating', $properties );
|
||||
$this->assertArrayHasKey( 'name', $properties );
|
||||
$this->assertArrayHasKey( 'email', $properties );
|
||||
$this->assertArrayHasKey( 'verified', $properties );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
|
||||
// Add coupon
|
||||
WC()->cart->add_discount( $coupon->code );
|
||||
WC()->cart->add_discount( $coupon->get_code() );
|
||||
|
||||
// Create dummy product - price will be 10
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
@ -58,8 +58,8 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
# Test case 2 #10573
|
||||
update_post_meta( $product->id, '_regular_price', '29.95' );
|
||||
update_post_meta( $product->id, '_price', '29.95' );
|
||||
update_post_meta( $coupon->id, 'discount_type', 'percent' );
|
||||
update_post_meta( $coupon->id, 'coupon_amount', '10' );
|
||||
update_post_meta( $coupon->get_id(), 'discount_type', 'percent' );
|
||||
update_post_meta( $coupon->get_id(), 'coupon_amount', '10' );
|
||||
update_option( 'woocommerce_prices_include_tax', 'yes' );
|
||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||
$tax_rate = array(
|
||||
|
@ -77,7 +77,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
$product = wc_get_product( $product->id );
|
||||
|
||||
WC()->cart->add_to_cart( $product->id, 1 );
|
||||
WC()->cart->add_discount( $coupon->code );
|
||||
WC()->cart->add_discount( $coupon->get_code() );
|
||||
|
||||
WC()->cart->calculate_totals();
|
||||
$cart_item = current( WC()->cart->get_cart() );
|
||||
|
@ -92,8 +92,8 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
|
||||
|
||||
# Test case 3 #11626
|
||||
update_post_meta( $coupon->id, 'discount_type', 'percent' );
|
||||
update_post_meta( $coupon->id, 'coupon_amount', '50' );
|
||||
update_post_meta( $coupon->get_id(), 'discount_type', 'percent' );
|
||||
update_post_meta( $coupon->get_id(), 'coupon_amount', '50' );
|
||||
update_option( 'woocommerce_prices_include_tax', 'yes' );
|
||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||
|
||||
|
@ -122,7 +122,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
WC()->cart->add_to_cart( $loop_product->id, 1 );
|
||||
}
|
||||
|
||||
WC()->cart->add_discount( $coupon->code );
|
||||
WC()->cart->add_discount( $coupon->get_code() );
|
||||
WC()->cart->calculate_totals();
|
||||
$cart_item = current( WC()->cart->get_cart() );
|
||||
$this->assertEquals( '16.55', WC()->cart->total );
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace WooCommerce\Tests\Coupon;
|
||||
|
||||
/**
|
||||
* Class CRUD
|
||||
* @package WooCommerce\Tests\Coupon
|
||||
*/
|
||||
class CouponCRUD extends \WC_Unit_Test_Case {
|
||||
class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Some of our get/setters were renamed. This will return the function
|
||||
|
@ -33,7 +31,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
function test_coupon_create() {
|
||||
$code = 'coupon-' . time();
|
||||
$coupon = new \WC_Coupon;
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon->set_code( $code );
|
||||
$coupon->set_description( 'This is a test comment.' );
|
||||
$coupon->create();
|
||||
|
@ -47,7 +45,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function test_coupon_delete() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$this->assertNotEquals( 0, $coupon_id );
|
||||
$coupon->delete();
|
||||
|
@ -60,7 +58,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function test_coupon_update() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$this->assertEquals( 'dummycoupon', $coupon->get_code() );
|
||||
$coupon->set_code( 'dummycoupon2' );
|
||||
|
@ -75,14 +73,14 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
function test_coupon_read() {
|
||||
$code = 'coupon-' . time();
|
||||
$coupon = new \WC_Coupon;
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon->set_code( $code );
|
||||
$coupon->set_description( 'This is a test coupon.' );
|
||||
$coupon->set_usage_count( 5 );
|
||||
$coupon->create();
|
||||
$coupon_id = $coupon->get_id();
|
||||
|
||||
$coupon_read = new \WC_Coupon;
|
||||
$coupon_read = new WC_Coupon;
|
||||
$coupon_read->read( $coupon_id );
|
||||
|
||||
$this->assertEquals( 5, $coupon_read->get_usage_count() );
|
||||
|
@ -95,7 +93,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function test_coupon_save() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$coupon->set_code( 'dummycoupon2' );
|
||||
$coupon->save();
|
||||
|
@ -103,7 +101,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
$this->assertEquals( 'dummycoupon2', $coupon->get_code() );
|
||||
$this->assertEquals( $coupon_id, $coupon->get_id() );
|
||||
|
||||
$new_coupon = new \WC_Coupon;
|
||||
$new_coupon = new WC_Coupon;
|
||||
$new_coupon->set_code( 'dummycoupon3' );
|
||||
$new_coupon->save();
|
||||
$new_coupon_id = $new_coupon->get_id();
|
||||
|
@ -127,7 +125,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
);
|
||||
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
|
||||
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
add_post_meta( $coupon->get_id(), 'test_coupon_field', 'testing', true );
|
||||
$coupon->read( $coupon->get_id() );
|
||||
|
||||
|
@ -161,7 +159,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_read_manual_coupon() {
|
||||
$code = 'manual_coupon_' . time();
|
||||
$coupon = new \WC_Coupon( $code );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
$coupon->read_manual_coupon( $code, array(
|
||||
'id' => true,
|
||||
'type' => 'fixed_cart',
|
||||
|
@ -193,7 +191,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
$legacy_keys = array( 'product_ids', 'exclude_product_ids', 'individual_use', 'free_shipping', 'exclude_sale_items' );
|
||||
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
|
||||
$code = 'bc_manual_coupon_' . time();
|
||||
$coupon = new \WC_Coupon( $code );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
$coupon->read_manual_coupon( $code, array(
|
||||
'id' => true,
|
||||
'type' => 'fixed_cart',
|
||||
|
@ -236,7 +234,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
'customer_email' => array( 'test@woo.local' ), 'used_by' => array( 1 ),
|
||||
);
|
||||
|
||||
$coupon = new \WC_Coupon;
|
||||
$coupon = new WC_Coupon;
|
||||
foreach ( $standard_getters_and_setters as $function => $value ) {
|
||||
$function = $this->get_function_name( $function );
|
||||
$coupon->{"set_{$function}"}( $value );
|
||||
|
@ -249,7 +247,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_custom_fields() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
add_post_meta( $coupon_id, 'test_coupon_field', $meta_value, true );
|
||||
|
@ -264,7 +262,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_set_custom_fields() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
$coupon->add_meta_data( 'my-custom-field', $meta_value, true );
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
namespace WooCommerce\Tests\Customer;
|
||||
|
||||
/**
|
||||
* Class CustomerCRUD.
|
||||
* @package WooCommerce\Tests\Customer
|
||||
*/
|
||||
class CustomerCRUD extends \WC_Unit_Test_Case {
|
||||
class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test creating a new customer.
|
||||
|
@ -13,12 +12,12 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_create_customer() {
|
||||
$username = 'testusername-' . time();
|
||||
$customer = new \WC_Customer();
|
||||
$customer = new WC_Customer();
|
||||
$customer->set_username( 'testusername-' . time() );
|
||||
$customer->set_password( 'test123' );
|
||||
$customer->set_email( 'test@woo.local' );
|
||||
$customer->create();
|
||||
$wp_user = new \WP_User( $customer->get_id() );
|
||||
$wp_user = new WP_User( $customer->get_id() );
|
||||
|
||||
$this->assertEquals( $username, $customer->get_username() );
|
||||
$this->assertNotEquals( 0, $customer->get_id() );
|
||||
|
@ -30,7 +29,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_customer() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$this->assertEquals( 'test@woo.local', $customer->get_email() );
|
||||
$this->assertEquals( 'Apt 1', $customer->get_billing_address_2() );
|
||||
|
@ -39,7 +38,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$customer->set_billing_address_2( 'Apt 5' );
|
||||
$customer->update();
|
||||
|
||||
$customer = new \WC_Customer( $customer_id ); // so we can read fresh copies from the DB
|
||||
$customer = new WC_Customer( $customer_id ); // so we can read fresh copies from the DB
|
||||
$this->assertEquals( 'test@wc.local', $customer->get_email() );
|
||||
$this->assertEquals( 'Justin', $customer->get_first_name() );
|
||||
$this->assertEquals( 'Apt 5', $customer->get_billing_address_2() );
|
||||
|
@ -52,14 +51,14 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_save_customer() {
|
||||
// test save() -> Create
|
||||
$customer = new \WC_Customer();
|
||||
$customer = new WC_Customer();
|
||||
$customer->set_username( 'testusername-' . time() );
|
||||
$customer->set_password( 'test123' );
|
||||
$customer->set_email( 'test@woo.local' );
|
||||
$this->assertEquals( 0, $customer->get_id() );
|
||||
$customer->save();
|
||||
$customer_id = $customer->get_id();
|
||||
$wp_user = new \WP_User( $customer->get_id() );
|
||||
$wp_user = new WP_User( $customer->get_id() );
|
||||
|
||||
$this->assertNotEquals( 0, $customer->get_id() );
|
||||
|
||||
|
@ -68,7 +67,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$customer->set_email( 'test@wc.local' );
|
||||
$customer->save();
|
||||
|
||||
$customer = new \WC_Customer( $customer_id );
|
||||
$customer = new WC_Customer( $customer_id );
|
||||
$this->assertEquals( 'test@wc.local', $customer->get_email() );
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_customer() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$this->assertNotEquals( 0, $customer->get_id() );
|
||||
$customer->delete();
|
||||
|
@ -91,7 +90,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_read_customer() {
|
||||
$username = 'user-' . time();
|
||||
$customer = new \WC_Customer();
|
||||
$customer = new WC_Customer();
|
||||
$customer->set_username( $username );
|
||||
$customer->set_email( 'test@woo.local' );
|
||||
$customer->set_password( 'hunter2' );
|
||||
|
@ -99,7 +98,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$customer->set_last_name( 'Bob' );
|
||||
$customer->create();
|
||||
$customer_id = $customer->get_id();
|
||||
$customer_read = new \WC_Customer();
|
||||
$customer_read = new WC_Customer();
|
||||
$customer_read->read( $customer_id );
|
||||
|
||||
$this->assertEquals( $customer_id, $customer_read->get_id() );
|
||||
|
@ -132,7 +131,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
|
||||
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
|
||||
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
|
||||
$this->assertEquals( $customer->get_id(), $customer->id );
|
||||
$this->assertEquals( $customer->get_billing_country(), $customer->country );
|
||||
|
@ -172,8 +171,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$time = time();
|
||||
$standard_getters_and_setters = array(
|
||||
'username' => 'test', 'email' => 'test@woo.local', 'first_name' => 'Bob', 'last_name' => 'tester',
|
||||
'role' => 'customer', 'last_order_id' => 5, 'last_order_date' => $time, 'orders_count' => 2,
|
||||
'total_spent' => 10.57, 'date_created' => $time, 'date_modified' => $time, 'billing_postcode' => 11010,
|
||||
'role' => 'customer', 'date_created' => $time, 'date_modified' => $time, 'billing_postcode' => 11010,
|
||||
'billing_city' => 'New York', 'billing_address' => '123 Main St.', 'billing_address_1' => '123 Main St.', 'billing_address_2' => 'Apt 2', 'billing_state' => 'NY',
|
||||
'billing_country' => 'US', 'shipping_state' => 'NY', 'shipping_postcode' => 11011, 'shipping_city' =>
|
||||
'New York', 'shipping_address' => '123 Main St.', 'shipping_address_1' => '123 Main St.',
|
||||
|
@ -181,7 +179,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
'is_paying_customer' => true
|
||||
);
|
||||
|
||||
$customer = new \WC_Customer;
|
||||
$customer = new WC_Customer;
|
||||
foreach ( $standard_getters_and_setters as $function => $value ) {
|
||||
$customer->{"set_{$function}"}( $value );
|
||||
$this->assertEquals( $value, $customer->{"get_{$function}"}(), $function );
|
||||
|
@ -193,26 +191,28 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_last_order_info() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$order = \WC_Helper_Order::create_order( $customer_id );
|
||||
$order = WC_Helper_Order::create_order( $customer_id );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( $order->get_id(), $customer->get_last_order_id() );
|
||||
$this->assertEquals( $order->get_date_created(), $customer->get_last_order_date() );
|
||||
$last_order = $customer->get_last_order();
|
||||
$this->assertEquals( $order->get_id(), $last_order ? $last_order->get_id() : 0 );
|
||||
$this->assertEquals( $order->get_date_created(), $last_order ? $last_order->get_date_created() : 0 );
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting a customer's order count from DB.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_orders_count_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
public function test_customer_get_order_count_read() {
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
\WC_Helper_Order::create_order( $customer_id );
|
||||
\WC_Helper_Order::create_order( $customer_id );
|
||||
\WC_Helper_Order::create_order( $customer_id );
|
||||
WC_Helper_Order::create_order( $customer_id );
|
||||
WC_Helper_Order::create_order( $customer_id );
|
||||
WC_Helper_Order::create_order( $customer_id );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( 3, $customer->get_orders_count() );
|
||||
$this->assertEquals( 3, $customer->get_order_count() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,14 +220,15 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_total_spent_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$order = \WC_Helper_Order::create_order( $customer_id );
|
||||
$order = WC_Helper_Order::create_order( $customer_id );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( 0, $customer->get_total_spent() );
|
||||
$order->update_status( 'wc-completed' );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( 40, $customer->get_total_spent() );
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,7 +236,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_avatar_url() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$this->assertContains( 'gravatar.com/avatar', $customer->get_avatar_url() );
|
||||
$this->assertContains( md5( 'test@woo.local' ), $customer->get_avatar_url() );
|
||||
}
|
||||
|
@ -245,9 +246,9 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_date_created_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$user = new \WP_User( $customer_id );
|
||||
$user = new WP_User( $customer_id );
|
||||
$this->assertEquals( strtotime( $user->data->user_registered ), $customer->get_date_created() );
|
||||
}
|
||||
|
||||
|
@ -256,7 +257,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_date_modified_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$last = get_user_meta( $customer_id, 'last_update', true );
|
||||
sleep(1);
|
||||
|
@ -273,7 +274,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_taxable_address() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$customer->set_shipping_postcode( '11111' );
|
||||
$customer->set_shipping_city( 'Test' );
|
||||
|
@ -307,7 +308,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_downloadable_products() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$this->assertEquals( wc_get_customer_available_downloads( $customer_id ), $customer->get_downloadable_products() );
|
||||
}
|
||||
|
@ -317,7 +318,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_password() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
|
||||
$user = get_user_by( 'id', $customer_id );
|
||||
|
@ -335,7 +336,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_address_to_base() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_billing_address_to_base();
|
||||
$base = wc_get_customer_default_location();
|
||||
$this->assertEquals( $base['country'], $customer->get_billing_country() );
|
||||
|
@ -349,7 +350,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_shipping_address_to_base() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_shipping_address_to_base();
|
||||
$base = wc_get_customer_default_location();
|
||||
$this->assertEquals( $base['country'], $customer->get_shipping_country() );
|
||||
|
@ -363,7 +364,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_location() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_billing_location( 'US', 'OH', '12345', 'Cleveland' );
|
||||
$this->assertEquals( 'US', $customer->get_billing_country() );
|
||||
$this->assertEquals( 'OH', $customer->get_billing_state() );
|
||||
|
@ -376,7 +377,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_shipping_location() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_shipping_location( 'US', 'OH', '12345', 'Cleveland' );
|
||||
$this->assertEquals( 'US', $customer->get_shipping_country() );
|
||||
$this->assertEquals( 'OH', $customer->get_shipping_state() );
|
||||
|
@ -389,7 +390,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_is_customer_outside_base() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$this->assertTrue( $customer->is_customer_outside_base() );
|
||||
update_option( 'woocommerce_tax_based_on', 'base' );
|
||||
$customer->set_billing_address_to_base();
|
||||
|
@ -401,11 +402,9 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_sessions() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$session = \WC_Helper_Customer::create_mock_customer(); // set into session....
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$session = WC_Helper_Customer::create_mock_customer(); // set into session....
|
||||
|
||||
$this->assertNotEmpty( $session->get_id() );
|
||||
$this->assertFalse( is_numeric( $session->get_id() ) );
|
||||
$this->assertEquals( '19123', $session->get_billing_postcode() );
|
||||
$this->assertEquals( '123 South Street', $session->get_billing_address() );
|
||||
$this->assertEquals( 'Philadelphia', $session->get_billing_city() );
|
||||
|
@ -413,17 +412,17 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$session->set_billing_address( '124 South Street' );
|
||||
$session->save_to_session();
|
||||
|
||||
$session = new \WC_Customer();
|
||||
$session = new WC_Customer( 0, true );
|
||||
$session->load_session();
|
||||
$this->assertEquals( '124 South Street', $session->get_billing_address() );
|
||||
|
||||
$session = new \WC_Customer();
|
||||
$session = new WC_Customer( 0, true );
|
||||
$session->load_session();
|
||||
$session->set_billing_postcode( '32191' );
|
||||
$session->save();
|
||||
|
||||
// should still be session ID, not a created row, since we are working with guests/sessions
|
||||
$this->assertFalse( is_numeric( $session->get_id() ) );
|
||||
$this->assertFalse( $session->get_id() > 0 );
|
||||
$this->assertEquals( '32191' , $session->get_billing_postcode() );
|
||||
}
|
||||
|
||||
|
@ -432,7 +431,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_meta() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
add_user_meta( $customer_id, 'test_field', $meta_value, true );
|
||||
|
@ -446,7 +445,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_set_meta() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
$customer->add_meta_data( 'my-field', $meta_value, true );
|
||||
|
|
|
@ -14,15 +14,6 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( 'shop_order', $object->get_type() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: get_type
|
||||
*/
|
||||
function test_get_order_type() {
|
||||
$object = new WC_Order();
|
||||
$id = $object->save();
|
||||
$this->assertEquals( 'shop_order', $object->get_order_type() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: get_data
|
||||
*/
|
||||
|
@ -242,8 +233,8 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$product = WC_Helper_Product::create_simple_product();
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$item_id = $object->add_product( $product, array( 'qty' => 4 ) );
|
||||
$item_id = $object->add_product( $product, array( 'qty' => 2 ) );
|
||||
$item_id = $object->add_product( $product, 4 );
|
||||
$item_id = $object->add_product( $product, 2 );
|
||||
$this->assertCount( 2, $object->get_items() );
|
||||
$object->remove_order_items();
|
||||
$this->assertCount( 0, $object->get_items() );
|
||||
|
@ -255,8 +246,8 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
function test_get_items() {
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 2 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 2 );
|
||||
$this->assertCount( 2, $object->get_items() );
|
||||
}
|
||||
|
||||
|
@ -299,7 +290,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$object->calculate_totals();
|
||||
$this->assertCount( 1, $object->get_taxes() );
|
||||
|
||||
|
@ -347,13 +338,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
function test_get_used_coupons() {
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_coupon(
|
||||
array(
|
||||
'code' => '12345',
|
||||
'discount' => '10',
|
||||
'discount_tax' => '5',
|
||||
)
|
||||
);
|
||||
$object->add_coupon( '12345', '10', '5' );
|
||||
$this->assertCount( 1, $object->get_used_coupons() );
|
||||
}
|
||||
|
||||
|
@ -363,8 +348,8 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
function test_get_item_count() {
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 2 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 2 );
|
||||
$this->assertEquals( 6, $object->get_item_count() );
|
||||
}
|
||||
|
||||
|
@ -375,16 +360,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$object = new WC_Order();
|
||||
$object->save();
|
||||
|
||||
$item_id = $object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$item_id = $object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$this->assertTrue( $object->get_item( $item_id ) instanceOf WC_Order_Item_Product );
|
||||
|
||||
$item_id = $object->add_coupon(
|
||||
array(
|
||||
'code' => '12345',
|
||||
'discount' => '10',
|
||||
'discount_tax' => '5',
|
||||
)
|
||||
);
|
||||
$item_id = $object->add_coupon( '12345', '10', '5' );
|
||||
$this->assertTrue( $object->get_item( $item_id ) instanceOf WC_Order_Item_Coupon );
|
||||
}
|
||||
|
||||
|
@ -449,7 +428,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$object->add_shipping( new WC_Shipping_Rate( 'flat_rate_shipping', 'Flat rate shipping', '10', array(), 'flat_rate' ) );
|
||||
$object->calculate_taxes();
|
||||
$this->assertEquals( 5, $object->get_total_tax() );
|
||||
|
@ -481,7 +460,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$object->add_shipping( new WC_Shipping_Rate( 'flat_rate_shipping', 'Flat rate shipping', '10', array(), 'flat_rate' ) );
|
||||
$object->calculate_totals();
|
||||
$this->assertEquals( 55, $object->get_total() );
|
||||
|
@ -531,12 +510,12 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
function test_has_free_item() {
|
||||
$object = new WC_Order();
|
||||
$object->save();
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), array( 'qty' => 4 ) );
|
||||
$object->add_product( WC_Helper_Product::create_simple_product(), 4 );
|
||||
$this->assertFalse( $object->has_free_item() );
|
||||
|
||||
$free_product = WC_Helper_Product::create_simple_product();
|
||||
$free_product->set_price( 0 );
|
||||
$object->add_product( $free_product, array( 'qty' => 4 ) );
|
||||
$object->add_product( $free_product, 4 );
|
||||
$this->assertTrue( $object->has_free_item() );
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* Author: WooThemes
|
||||
* Author URI: https://woothemes.com
|
||||
* Requires at least: 4.4
|
||||
* Tested up to: 4.5
|
||||
* Tested up to: 4.6
|
||||
*
|
||||
* Text Domain: woocommerce
|
||||
* Domain Path: /i18n/languages/
|
||||
|
@ -237,7 +237,8 @@ final class WooCommerce {
|
|||
include_once( WC_ABSPATH . 'includes/class-wc-post-data.php' );
|
||||
include_once( WC_ABSPATH . 'includes/class-wc-ajax.php' );
|
||||
|
||||
include_once( 'includes/abstracts/abstract-wc-data.php' ); // WC_Data for CRUD
|
||||
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-data.php' ); // WC_Data for CRUD
|
||||
include_once( WC_ABSPATH . 'includes/class-wc-data-exception.php' );
|
||||
|
||||
if ( $this->is_request( 'admin' ) ) {
|
||||
include_once( WC_ABSPATH . 'includes/admin/class-wc-admin.php' );
|
||||
|
@ -334,8 +335,7 @@ final class WooCommerce {
|
|||
// Classes/actions loaded for the frontend and for ajax requests.
|
||||
if ( $this->is_request( 'frontend' ) ) {
|
||||
$this->cart = new WC_Cart(); // Cart class, stores the cart contents
|
||||
$this->customer = new WC_Customer(); // Customer class, handles data such as customer location
|
||||
$this->customer->load_session();
|
||||
$this->customer = new WC_Customer( get_current_user_id(), true ); // Customer class, handles data such as customer location
|
||||
}
|
||||
|
||||
$this->load_webhooks();
|
||||
|
|
Loading…
Reference in New Issue