Refactor coupon code so coupons get the actual discount amount, redone edit coupon screen with tabs, added coupon item limits which Closes #3902

This commit is contained in:
Mike Jolley 2013-10-18 18:10:55 +01:00
parent 626624ad87
commit 5d2e1ac031
18 changed files with 826 additions and 1602 deletions

View File

@ -1 +1,151 @@
.woocommerce-message{position:relative;z-index:100;border:1px solid #b76ca9!important;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 0 15px rgba(0,0,0,0.04);-moz-box-shadow:inset 0 0 15px rgba(0,0,0,0.04);box-shadow:inset 0 0 15px rgba(0,0,0,0.04);overflow:hidden;padding:10px 0 10px!important;background:#cc99c2 url(../images/message.png) no-repeat right bottom!important}.woocommerce-message .squeezer{max-width:960px;margin:0;padding:0 10px;text-align:left;overflow:hidden}.woocommerce-message h4{margin:5px 10px 5px 0;font-size:18px;line-height:27px;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif;font-weight:normal;color:#fff;text-shadow:0 1px 1px #b574a8;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;float:left;vertical-align:middle}.woocommerce-message p{margin:5px 0!important;padding:1px 2px!important;float:left!important;line-height:27px;vertical-align:middle}.woocommerce-message .twitter-share-button{vertical-align:middle;margin-left:3px}p.woocommerce-actions a.button-primary,.woocommerce-message a.button-primary{font-size:14px!important;line-height:16px!important;height:auto!important;-webkit-border-radius:3px;border-radius:3px;margin:0 5px 0 0;padding:5px 12px;vertical-align:middle;color:#fff;text-align:center;text-decoration:none;border:1px solid #76456d;-webkit-transition:none;-moz-transition:none;cursor:pointer;outline:0;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif;text-shadow:0 1px 0 rgba(0,0,0,0.3);background-color:#a46497;background-image:-webkit-gradient(linear,left top,left bottom,from(#a46497),to(#864f7b));background-image:-webkit-linear-gradient(top,#a46497,#864f7b);background-image:-moz-linear-gradient(top,#a46497,#864f7b);background-image:-ms-linear-gradient(top,#a46497,#864f7b);background-image:-o-linear-gradient(top,#a46497,#864f7b);background-image:linear-gradient(to bottom,#a46497,#864f7b);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),inset 0 -1px 0 rgba(0,0,0,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),inset 0 -1px 0 rgba(0,0,0,0.1)}p.woocommerce-actions a.button-primary:hover,.woocommerce-message a.button-primary:hover{text-shadow:0 -1px 0 rgba(0,0,0,0.3);border:1px solid #76456d;background-color:#ad74a2;background-image:-webkit-gradient(linear,left top,left bottom,from(#ad74a2),to(#864f7b));background-image:-webkit-linear-gradient(top,#ad74a2,#864f7b);background-image:-moz-linear-gradient(top,#ad74a2,#864f7b);background-image:-ms-linear-gradient(top,#ad74a2,#864f7b);background-image:-o-linear-gradient(top,#ad74a2,#864f7b);background-image:linear-gradient(to bottom,#ad74a2,#864f7b);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),inset 0 -1px 0 rgba(0,0,0,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),inset 0 -1px 0 rgba(0,0,0,0.1)}p.woocommerce-actions a.button-primary:active,.woocommerce-message a.button-primary:active{border:1px solid #76456d;text-shadow:0 1px 0 rgba(0,0,0,0.3);background-color:#864f7b;background-image:-webkit-gradient(linear,left top,left bottom,from(#864f7b),to(#864f7b));background-image:-webkit-linear-gradient(top,#864f7b,#a46497);background-image:-moz-linear-gradient(top,#864f7b,#a46497);background-image:-ms-linear-gradient(top,#864f7b,#a46497);background-image:-o-linear-gradient(top,#864f7b,#a46497);background-image:linear-gradient(to bottom,#a46497,#a46497);-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.2);box-shadow:inset 0 1px 1px rgba(0,0,0,0.2)}p.woocommerce-actions a.skip,.woocommerce-message a.skip,p.woocommerce-actions a.docs,.woocommerce-message a.docs{opacity:.7}p.woocommerce-actions .twitter-share-button,.woocommerce-message .twitter-share-button{vertical-align:middle;margin-left:3px}p.woocommerce-actions{margin-bottom:2em}.woocommerce-about-text{margin-bottom:1em!important}
.woocommerce-message {
position: relative;
z-index: 100;
border: 1px solid #b76ca9 !important;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.04);
-moz-box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.04);
box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.04);
overflow: hidden;
padding: 10px 0 10px !important;
background: #cc99c2 url(../images/message.png) no-repeat right bottom !important;
}
.woocommerce-message .squeezer {
max-width: 960px;
margin: 0;
padding: 0 10px;
text-align: left;
overflow: hidden;
}
.woocommerce-message h4 {
margin: 5px 10px 5px 0;
font-size: 18px;
line-height: 27px;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", Verdana, "Bitstream Vera Sans", sans-serif;
font-weight: normal;
color: #fff;
text-shadow: 0px 1px 1px #b574a8;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
float: left;
vertical-align: middle;
}
.woocommerce-message p {
margin: 5px 0 !important;
padding: 1px 2px !important;
float: left !important;
line-height: 27px;
vertical-align: middle;
}
.woocommerce-message .twitter-share-button {
vertical-align: middle;
margin-left: 3px;
}
p.woocommerce-actions a.button-primary,
.woocommerce-message a.button-primary {
font-size: 14px !important;
line-height: 16px !important;
height: auto !important;
-webkit-border-radius: 3px;
border-radius: 3px;
margin: 0 5px 0 0;
padding: 5px 12px;
vertical-align: middle;
color: #fff;
text-align: center;
text-decoration: none;
border: 1px solid #76456d;
-webkit-transition: none;
-moz-transition: none;
cursor: pointer;
outline: none;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", Verdana, "Bitstream Vera Sans", sans-serif;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.3);
background-color: #a46497;
background-image: -webkit-gradient(linear, left top, left bottom, from(#a46497), to(#864f7b));
/* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, #a46497, #864f7b);
/* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, #a46497, #864f7b);
/* FF3.6+ */
background-image: -ms-linear-gradient(top, #a46497, #864f7b);
/* IE10 */
background-image: -o-linear-gradient(top, #a46497, #864f7b);
/* Opera 11.10+ */
background-image: linear-gradient(to bottom, #a46497, #864f7b);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}
p.woocommerce-actions a.button-primary:hover,
.woocommerce-message a.button-primary:hover {
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.3);
border: 1px solid #76456d;
background-color: #ad74a2;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ad74a2), to(#864f7b));
/* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, #ad74a2, #864f7b);
/* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, #ad74a2, #864f7b);
/* FF3.6+ */
background-image: -ms-linear-gradient(top, #ad74a2, #864f7b);
/* IE10 */
background-image: -o-linear-gradient(top, #ad74a2, #864f7b);
/* Opera 11.10+ */
background-image: linear-gradient(to bottom, #ad74a2, #864f7b);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}
p.woocommerce-actions a.button-primary:active,
.woocommerce-message a.button-primary:active {
border: 1px solid #76456d;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.3);
background-color: #864f7b;
background-image: -webkit-gradient(linear, left top, left bottom, from(#864f7b), to(#864f7b));
/* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, #864f7b, #a46497);
/* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, #864f7b, #a46497);
/* FF3.6+ */
background-image: -ms-linear-gradient(top, #864f7b, #a46497);
/* IE10 */
background-image: -o-linear-gradient(top, #864f7b, #a46497);
/* Opera 11.10+ */
background-image: linear-gradient(to bottom, #a46497, #a46497);
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2);
}
p.woocommerce-actions a.skip,
.woocommerce-message a.skip,
p.woocommerce-actions a.docs,
.woocommerce-message a.docs {
opacity: 0.7;
}
p.woocommerce-actions .twitter-share-button,
.woocommerce-message .twitter-share-button {
vertical-align: middle;
margin-left: 3px;
}
p.woocommerce-actions {
margin-bottom: 2em;
}
.woocommerce-about-text {
margin-bottom: 1em !important;
}

File diff suppressed because one or more lines are too long

View File

@ -2096,7 +2096,22 @@ img.help_tip {
}
/* Tabs and panels */
#woocommerce-product-data {
#woocommerce-coupon-description {
padding: 3px 8px;
font-size: 1.7em;
line-height: 1.42em;
height: auto;
width: 100%;
outline: 0;
margin: 10px 0 10px;
display: block;
&::-webkit-input-placeholder { line-height: 1.42em; color: #bbb; }
&::-moz-placeholder { line-height: 1.42em; color: #bbb; } /* firefox 19+ */
&:-ms-input-placeholder { line-height: 1.42em; color: #bbb; } /* ie */
&:-moz-placeholder { line-height: 1.42em; color: #bbb; }
}
#woocommerce-product-data, #woocommerce-coupon-data {
.panel-wrap {
background: #f8f8f8;
padding-left: 153px;
@ -2120,89 +2135,101 @@ img.help_tip {
border-right: 1px solid #DFDFDF;
}
}
#woocommerce-product-data ul.product_data_tabs, .woocommerce ul.wc-tabs {
background: #f1f1f1;
line-height: 1em;
float: left;
width: 145px;
margin: 0;
position: relative;
padding: 0 0 10px;
margin-left: -153px;
li {
display:block;
padding: 0;
#woocommerce-product-data, #woocommerce-coupon-data, .woocommerce {
ul.wc-tabs {
background: #f1f1f1;
line-height: 1em;
float: left;
width: 145px;
margin: 0;
position: relative;
padding: 0 0 10px;
margin-left: -153px;
a {
padding: 5px;
line-height: 18px !important;
li {
display:block;
padding: 0;
margin: 0;
display: block;
background: #f1f1f1;
text-decoration: none;
border-bottom: 1px solid #f1f1f1;
border-top: 1px solid #f1f1f1;
padding-left:10px;
&:before {
.iconbefore( "\e028" );
}
}
&:first-child {
a {
border-top: 0 !important;
padding: 5px;
line-height: 18px !important;
margin: 0;
display: block;
background: #f1f1f1;
text-decoration: none;
border-bottom: 1px solid #f1f1f1;
border-top: 1px solid #f1f1f1;
padding-left:10px;
&:before {
.iconbefore( "\e028" );
}
}
}
&.general_options {
a:before {
content: "\e006";
}
}
&.tax_options {
a:before {
&:first-child {
a {
border-top: 0 !important;
}
}
}
&.inventory_options {
a:before {
content: "\e02c";
&.general_options {
a:before {
content: "\e006";
}
}
}
&.shipping_options {
a:before {
content: "\e01a";
}
}
&.linked_product_options {
a:before {
content: "\e00d";
}
}
&.attribute_options {
a:before {
content: "\e02b";
}
}
&.advanced_options {
a:before {
content: "\e01c";
}
}
&.variation_options {
a:before {
content: "\e003";
}
}
&.tax_options {
a:before {
&.active {
a {
border-color: #DFDFDF;
position: relative;
background-color: #f8f8f8;
color: #555;
margin: 0 -1px 0 0;
}
}
&.inventory_options {
a:before {
content: "\e02c";
}
}
&.shipping_options {
a:before {
content: "\e01a";
}
}
&.linked_product_options {
a:before {
content: "\e00d";
}
}
&.attribute_options {
a:before {
content: "\e02b";
}
}
&.advanced_options {
a:before {
content: "\e01c";
}
}
&.variation_options {
a:before {
content: "\e003";
}
}
&.usage_restriction_options {
a:before {
content: "\e013";
}
}
&.usage_limit_options {
a:before {
content: "\e016";
}
}
&.active {
a {
border-color: #DFDFDF;
position: relative;
background-color: #f8f8f8;
color: #555;
margin: 0 -1px 0 0;
}
}
}
}
@ -2210,7 +2237,7 @@ img.help_tip {
@media only screen and (max-width: 900px) {
#woocommerce-product-data {
#woocommerce-product-data, #woocommerce-coupon-data {
.panel-wrap {
padding-left: 35px;
}

View File

@ -1,194 +1 @@
.clear {
clear: both;
}
.nobr {
white-space: nowrap;
}
/**
* Objects
*/
@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: normal;
font-style: normal;
}
#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;
-webkit-box-sizing: border-box;
/* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;
/* Firefox, other Gecko */
box-sizing: border-box;
/* Opera/IE 8+ */
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;
}
#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: normal;
display: block;
color: #21759b;
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
}
#woocommerce_dashboard_status .wc_status_list li a:hover {
box-shadow: inset 0 -1px 0 0 #dfdfdf, inset 700px 0 0 rgba(156, 93, 144, 0.1);
padding-left: 2em;
color: #9c5d90;
}
#woocommerce_dashboard_status .wc_status_list li a:hover:before,
#woocommerce_dashboard_status .wc_status_list li a:hover strong {
color: #9c5d90 !important;
}
#woocommerce_dashboard_status .wc_status_list li a:before {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
margin: 0;
text-indent: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
content: "\e001";
font-size: 2em;
position: relative;
width: auto;
line-height: 1.2em;
color: #464646;
float: left;
margin-right: 12px;
margin-bottom: 12px;
}
#woocommerce_dashboard_status .wc_status_list li:first-child {
border-top: 0;
}
#woocommerce_dashboard_status .wc_status_list li.sales-this-month {
width: 100%;
}
#woocommerce_dashboard_status .wc_status_list li.sales-this-month a:before {
content: "\e01f";
}
#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month {
width: 100%;
}
#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a:before {
content: "\e006";
}
#woocommerce_dashboard_status .wc_status_list li.processing-orders {
border-right: 1px solid #ececec;
}
#woocommerce_dashboard_status .wc_status_list li.processing-orders a:before {
content: "\e011";
color: #73a724;
}
#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a:before {
content: "\e033";
color: #999;
}
#woocommerce_dashboard_status .wc_status_list li.low-in-stock {
border-right: 1px solid #ececec;
}
#woocommerce_dashboard_status .wc_status_list li.low-in-stock a:before {
content: "\e02c";
color: #c1692f;
}
#woocommerce_dashboard_status .wc_status_list li.out-of-stock a:before {
content: "\e02c";
color: #aa4444;
}
#woocommerce_dashboard_recent_reviews li {
line-height: 1.5em;
margin-bottom: 12px;
}
#woocommerce_dashboard_recent_reviews h4.meta {
line-height: 1.4;
margin: -0.2em 0 0 0;
font-weight: normal;
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: 0.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: 0.1em;
letter-spacing: 0\9;
color: #9c5d90;
}
.clear{clear:both}.nobr{white-space:nowrap}@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:normal;font-style:normal}#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;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;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}#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:normal;display:block;color:#21759b;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif}#woocommerce_dashboard_status .wc_status_list li a:hover{box-shadow:inset 0 -1px 0 0 #dfdfdf,inset 700px 0 0 rgba(156,93,144,0.1);padding-left:2em;color:#9c5d90}#woocommerce_dashboard_status .wc_status_list li a:hover:before,#woocommerce_dashboard_status .wc_status_list li a:hover strong{color:#9c5d90!important}#woocommerce_dashboard_status .wc_status_list li a:before{font-family:'WooCommerce';speak:none;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"\e001";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left;margin-right:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a:before{content:"\e01f"}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a:before{content:"\e006"}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.processing-orders a:before{content:"\e011";color:#73a724}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a:before{content:"\e033";color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock{border-right:1px solid #ececec}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a:before{content:"\e02c";color:#c1692f}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a:before{content:"\e02c";color:#a44}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-0.2em 0 0 0;font-weight:normal;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}

File diff suppressed because one or more lines are too long

View File

@ -1,165 +1 @@
/**
* This stylesheet optimises the default WooCommerce layout when viewed on smaller screens.
*/
.clear {
clear: both;
}
.nobr {
white-space: nowrap;
}
/**
* Objects
*/
.woocommerce,
.woocommerce-page {
/**
* General layout
*/
/**
* Products
*/
/**
* Product Details
*/
/**
* Cart
*/
/**
* Checkout
*/
}
.woocommerce .col2-set .col-1,
.woocommerce-page .col2-set .col-1,
.woocommerce .col2-set .col-2,
.woocommerce-page .col2-set .col-2 {
float: none;
width: 100%;
}
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
width: 48%;
float: left;
clear: both;
margin: 0 0 2.992em;
}
.woocommerce ul.products li.product:nth-child(2n),
.woocommerce-page ul.products li.product:nth-child(2n) {
float: right;
clear: none !important;
}
.woocommerce div.product div.images,
.woocommerce-page div.product div.images,
.woocommerce #content div.product div.images,
.woocommerce-page #content div.product div.images,
.woocommerce div.product div.summary,
.woocommerce-page div.product div.summary,
.woocommerce #content div.product div.summary,
.woocommerce-page #content div.product div.summary {
float: none;
width: 100%;
}
.woocommerce table.cart .product-thumbnail,
.woocommerce-page table.cart .product-thumbnail,
.woocommerce #content table.cart .product-thumbnail,
.woocommerce-page #content table.cart .product-thumbnail {
display: none;
}
.woocommerce table.cart td.actions,
.woocommerce-page table.cart td.actions,
.woocommerce #content table.cart td.actions,
.woocommerce-page #content table.cart td.actions {
text-align: left;
}
.woocommerce table.cart td.actions .coupon,
.woocommerce-page table.cart td.actions .coupon,
.woocommerce #content table.cart td.actions .coupon,
.woocommerce-page #content table.cart td.actions .coupon {
float: none;
*zoom: 1;
padding-bottom: .5em;
}
.woocommerce table.cart td.actions .coupon:before,
.woocommerce-page table.cart td.actions .coupon:before,
.woocommerce #content table.cart td.actions .coupon:before,
.woocommerce-page #content table.cart td.actions .coupon:before,
.woocommerce table.cart td.actions .coupon:after,
.woocommerce-page table.cart td.actions .coupon:after,
.woocommerce #content table.cart td.actions .coupon:after,
.woocommerce-page #content table.cart td.actions .coupon:after {
content: " ";
display: table;
}
.woocommerce table.cart td.actions .coupon:after,
.woocommerce-page table.cart td.actions .coupon:after,
.woocommerce #content table.cart td.actions .coupon:after,
.woocommerce-page #content table.cart td.actions .coupon:after {
clear: both;
}
.woocommerce table.cart td.actions input,
.woocommerce-page table.cart td.actions input,
.woocommerce #content table.cart td.actions input,
.woocommerce-page #content table.cart td.actions input,
.woocommerce table.cart td.actions .button,
.woocommerce-page table.cart td.actions .button,
.woocommerce #content table.cart td.actions .button,
.woocommerce-page #content table.cart td.actions .button,
.woocommerce table.cart td.actions .input-text,
.woocommerce-page table.cart td.actions .input-text,
.woocommerce #content table.cart td.actions .input-text,
.woocommerce-page #content table.cart td.actions .input-text {
width: 48%;
-webkit-box-sizing: border-box;
/* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;
/* Firefox, other Gecko */
box-sizing: border-box;
/* Opera/IE 8+ */
}
.woocommerce table.cart td.actions .input-text + .button,
.woocommerce-page table.cart td.actions .input-text + .button,
.woocommerce #content table.cart td.actions .input-text + .button,
.woocommerce-page #content table.cart td.actions .input-text + .button,
.woocommerce table.cart td.actions .button.alt,
.woocommerce-page table.cart td.actions .button.alt,
.woocommerce #content table.cart td.actions .button.alt,
.woocommerce-page #content table.cart td.actions .button.alt {
float: right;
}
.woocommerce .cart-collaterals .cart_totals,
.woocommerce-page .cart-collaterals .cart_totals,
.woocommerce .cart-collaterals .shipping_calculator,
.woocommerce-page .cart-collaterals .shipping_calculator,
.woocommerce .cart-collaterals .cross-sells,
.woocommerce-page .cart-collaterals .cross-sells {
width: 100%;
float: none;
text-align: left;
}
.woocommerce #payment .terms,
.woocommerce-page #payment .terms {
text-align: left;
padding: 0;
}
.woocommerce #payment #place_order,
.woocommerce-page #payment #place_order {
float: none;
width: 100%;
-webkit-box-sizing: border-box;
/* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;
/* Firefox, other Gecko */
box-sizing: border-box;
/* Opera/IE 8+ */
margin-bottom: 1em;
}
.clear{clear:both}.nobr{white-space:nowrap}.woocommerce .col2-set .col-1,.woocommerce-page .col2-set .col-1,.woocommerce .col2-set .col-2,.woocommerce-page .col2-set .col-2{float:none;width:100%}.woocommerce ul.products li.product,.woocommerce-page ul.products li.product{width:48%;float:left;clear:both;margin:0 0 2.992em}.woocommerce ul.products li.product:nth-child(2n),.woocommerce-page ul.products li.product:nth-child(2n){float:right;clear:none!important}.woocommerce div.product div.images,.woocommerce-page div.product div.images,.woocommerce #content div.product div.images,.woocommerce-page #content div.product div.images,.woocommerce div.product div.summary,.woocommerce-page div.product div.summary,.woocommerce #content div.product div.summary,.woocommerce-page #content div.product div.summary{float:none;width:100%}.woocommerce table.cart .product-thumbnail,.woocommerce-page table.cart .product-thumbnail,.woocommerce #content table.cart .product-thumbnail,.woocommerce-page #content table.cart .product-thumbnail{display:none}.woocommerce table.cart td.actions,.woocommerce-page table.cart td.actions,.woocommerce #content table.cart td.actions,.woocommerce-page #content table.cart td.actions{text-align:left}.woocommerce table.cart td.actions .coupon,.woocommerce-page table.cart td.actions .coupon,.woocommerce #content table.cart td.actions .coupon,.woocommerce-page #content table.cart td.actions .coupon{float:none;*zoom:1;padding-bottom:.5em}.woocommerce table.cart td.actions .coupon:before,.woocommerce-page table.cart td.actions .coupon:before,.woocommerce #content table.cart td.actions .coupon:before,.woocommerce-page #content table.cart td.actions .coupon:before,.woocommerce table.cart td.actions .coupon:after,.woocommerce-page table.cart td.actions .coupon:after,.woocommerce #content table.cart td.actions .coupon:after,.woocommerce-page #content table.cart td.actions .coupon:after{content:" ";display:table}.woocommerce table.cart td.actions .coupon:after,.woocommerce-page table.cart td.actions .coupon:after,.woocommerce #content table.cart td.actions .coupon:after,.woocommerce-page #content table.cart td.actions .coupon:after{clear:both}.woocommerce table.cart td.actions input,.woocommerce-page table.cart td.actions input,.woocommerce #content table.cart td.actions input,.woocommerce-page #content table.cart td.actions input,.woocommerce table.cart td.actions .button,.woocommerce-page table.cart td.actions .button,.woocommerce #content table.cart td.actions .button,.woocommerce-page #content table.cart td.actions .button,.woocommerce table.cart td.actions .input-text,.woocommerce-page table.cart td.actions .input-text,.woocommerce #content table.cart td.actions .input-text,.woocommerce-page #content table.cart td.actions .input-text{width:48%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.woocommerce table.cart td.actions .input-text+.button,.woocommerce-page table.cart td.actions .input-text+.button,.woocommerce #content table.cart td.actions .input-text+.button,.woocommerce-page #content table.cart td.actions .input-text+.button,.woocommerce table.cart td.actions .button.alt,.woocommerce-page table.cart td.actions .button.alt,.woocommerce #content table.cart td.actions .button.alt,.woocommerce-page #content table.cart td.actions .button.alt{float:right}.woocommerce .cart-collaterals .cart_totals,.woocommerce-page .cart-collaterals .cart_totals,.woocommerce .cart-collaterals .shipping_calculator,.woocommerce-page .cart-collaterals .shipping_calculator,.woocommerce .cart-collaterals .cross-sells,.woocommerce-page .cart-collaterals .cross-sells{width:100%;float:none;text-align:left}.woocommerce #payment .terms,.woocommerce-page #payment .terms{text-align:left;padding:0}.woocommerce #payment #place_order,.woocommerce-page #payment #place_order{float:none;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:1em}

View File

@ -1,5 +1,30 @@
jQuery( function($){
// Allow tabbing
$('#titlediv #title').keyup(function( event ) {
var code = event.keyCode || event.which;
if ( code == '9' && $('#woocommerce-coupon-description').size() > 0 ) {
event.stopPropagation();
$('#woocommerce-coupon-description').focus();
return false;
}
});
// Coupon type options
$('select#discount_type').change(function(){
// Get value
var select_val = $(this).val();
if ( select_val == 'fixed_product' || select_val == 'percent_product' ) {
$('.limit_usage_to_x_items_field').show();
} else {
$('.limit_usage_to_x_items_field').hide();
}
}).change();
// Scroll to first checked category - https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
$(function(){
$('[id$="-all"] > ul.categorychecklist').each(function() {
@ -847,14 +872,16 @@ jQuery( function($){
$('input#_virtual').removeAttr('checked');
}
show_and_hide_panels();
$('ul.wc-tabs li:visible').eq(0).find('a').click();
$('body').trigger('woocommerce-product-type-change', select_val, $(this) );
}).change();
$('ul.wc-tabs li:visible').eq(0).find('a').click();
$('input#_downloadable, input#_virtual').change(function(){
show_and_hide_panels();
});

File diff suppressed because one or more lines are too long

1
assets/js/admin/quick-edit.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(){jQuery("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var e=jQuery(this).closest("tr").attr("id");e=e.replace("post-","");var t=jQuery("#woocommerce_inline_"+e),n=t.find(".sku").text(),r=t.find(".regular_price").text(),i=t.find(".sale_price").text(),s=t.find(".weight").text(),o=t.find(".length").text(),u=t.find(".width").text(),a=t.find(".height").text(),f=t.find(".visibility").text(),l=t.find(".stock_status").text(),c=t.find(".stock").text(),h=t.find(".featured").text(),p=t.find(".manage_stock").text(),d=t.find(".menu_order").text(),v=t.find(".tax_status").text(),m=t.find(".tax_class").text(),g=t.find(".backorders").text();jQuery('input[name="_sku"]',".inline-edit-row").val(n);jQuery('input[name="_regular_price"]',".inline-edit-row").val(r);jQuery('input[name="_sale_price"]',".inline-edit-row").val(i);jQuery('input[name="_weight"]',".inline-edit-row").val(s);jQuery('input[name="_length"]',".inline-edit-row").val(o);jQuery('input[name="_width"]',".inline-edit-row").val(u);jQuery('input[name="_height"]',".inline-edit-row").val(a);jQuery('input[name="_stock"]',".inline-edit-row").val(c);jQuery('input[name="menu_order"]',".inline-edit-row").val(d);jQuery('select[name="_tax_status"] option[value="'+v+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_tax_class"] option[value="'+m+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option').removeAttr("selected");jQuery('select[name="_visibility"] option[value="'+f+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_stock_status"] option[value="'+l+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_backorders"] option[value="'+g+'"]',".inline-edit-row").attr("selected","selected");h=="yes"?jQuery('input[name="_featured"]',".inline-edit-row").attr("checked","checked"):jQuery('input[name="_featured"]',".inline-edit-row").removeAttr("checked");if(p=="yes"){jQuery(".stock_qty_field",".inline-edit-row").show().removeAttr("style");jQuery('input[name="_manage_stock"]',".inline-edit-row").attr("checked","checked")}else{jQuery(".stock_qty_field",".inline-edit-row").hide();jQuery('input[name="_manage_stock"]',".inline-edit-row").removeAttr("checked")}var y=t.find(".product_type").text(),b=t.find(".product_is_virtual").text();y=="simple"||y=="external"?jQuery(".price_fields",".inline-edit-row").show().removeAttr("style"):jQuery(".price_fields",".inline-edit-row").hide();b=="yes"?jQuery(".dimension_fields",".inline-edit-row").hide():jQuery(".dimension_fields",".inline-edit-row").show().removeAttr("style");y=="grouped"?jQuery(".stock_fields",".inline-edit-row").hide():jQuery(".stock_fields",".inline-edit-row").show().removeAttr("style")});jQuery("#the-list").on("change",'.inline-edit-row input[name="_manage_stock"]',function(){jQuery(this).is(":checked")?jQuery(".stock_qty_field",".inline-edit-row").show().removeAttr("style"):jQuery(".stock_qty_field",".inline-edit-row").hide()});jQuery("#wpbody").on("click","#doaction, #doaction2",function(){jQuery("input.text",".inline-edit-row").val("");jQuery("#woocommerce-fields select").prop("selectedIndex",0);jQuery("#woocommerce-fields-bulk .inline-edit-group .alignright").hide()});jQuery("#wpbody").on("change","#woocommerce-fields-bulk .inline-edit-group .change_to",function(){jQuery(this).val()>0?jQuery(this).closest("div").find(".alignright").show():jQuery(this).closest("div").find(".alignright").hide()});jQuery(".product_shipping_class-checklist input").change(function(){jQuery(this).closest("li").siblings().find("input:checked").removeAttr("checked")})});

View File

@ -28,13 +28,14 @@ class WC_Admin_CPT_Shop_Coupon extends WC_Admin_CPT {
// Post title fields
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
add_action( 'edit_form_after_title', array( $this, 'coupon_description_field' ) );
// Admin Columns
add_filter( 'manage_edit-shop_coupon_columns', array( $this, 'edit_columns' ) );
add_action( 'manage_shop_coupon_posts_custom_column', array( $this, 'custom_columns' ), 2 );
add_filter( 'request', array( $this, 'coupons_by_type_query' ) );
// Prouct filtering
// Product filtering
add_action( 'restrict_manage_posts', array( $this, 'coupon_filters' ) );
// Call WC_Admin_CPT constructor
@ -54,6 +55,14 @@ class WC_Admin_CPT_Shop_Coupon extends WC_Admin_CPT {
return $text;
}
public function coupon_description_field( $post ) {
if ( $post->post_type != 'shop_coupon' )
return;
?>
<textarea id="woocommerce-coupon-description" name="excerpt" cols="5" rows="2" placeholder="<?php esc_attr_e( 'Description (optional)', 'woocommerce' ); ?>"><?php echo esc_textarea( $post->post_excerpt ); ?></textarea>
<?php
}
/**
* Change the columns shown in admin.
*/

View File

@ -22,43 +22,73 @@ class WC_Meta_Box_Coupon_Data {
*/
public static function output( $post ) {
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
?>
<style type="text/css">
#edit-slug-box, #minor-publishing-actions { display:none }
</style>
<div id="coupon_options" class="panel woocommerce_options_panel">
<?php
<div id="coupon_options" class="panel-wrap coupon_data">
echo '<div class="options_group">';
<div class="wc-tabs-back"></div>
// Description
woocommerce_wp_text_input( array( 'id' => 'coupon_description', 'label' => __( 'Coupon description', 'woocommerce' ), 'description' => __( 'Optionally enter a description for this coupon for your reference.', 'woocommerce' ), 'value' => $post->post_excerpt, 'name' => 'excerpt' ) );
<ul class="coupon_data_tabs wc-tabs" style="display:none;">
<?php
$coupon_data_tabs = apply_filters( 'woocommerce_coupon_data_tabs', array(
'general' => array(
'label' => __( 'General', 'woocommerce' ),
'target' => 'general_coupon_data',
'class' => '',
),
'usage_restriction' => array(
'label' => __( 'Usage Restriction', 'woocommerce' ),
'target' => 'usage_restriction_coupon_data',
'class' => '',
),
'usage_limit' => array(
'label' => __( 'Usage Limits', 'woocommerce' ),
'target' => 'usage_limit_coupon_data',
'class' => '',
)
) );
echo '</div><div class="options_group">';
foreach ( $coupon_data_tabs as $key => $tab ) {
?><li class="<?php echo $key; ?>_options <?php echo $key; ?>_tab <?php echo implode( ' ' , $tab['class'] ); ?>">
<a href="#<?php echo $tab['target']; ?>"><?php echo esc_html( $tab['label'] ); ?></a>
</li><?php
}
?>
</ul>
<div id="general_coupon_data" class="panel woocommerce_options_panel"><?php
// Type
woocommerce_wp_select( array( 'id' => 'discount_type', 'label' => __( 'Discount type', 'woocommerce' ), 'options' => wc_get_coupon_types() ) );
// Amount
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => '0.00', 'description' => __( 'Value of the coupon.', 'woocommerce' ), 'class' => 'wc_input_decimal' ) );
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => '0.00', 'description' => __( 'Value of the coupon.', 'woocommerce' ), 'class' => 'wc_input_decimal', 'desc_tip' => true ) );
// Free Shipping
woocommerce_wp_checkbox( array( 'id' => 'free_shipping', 'label' => __( 'Enable free shipping', 'woocommerce' ), 'description' => sprintf(__( 'Check this box if the coupon grants free shipping. The <a href="%s">free shipping method</a> must be enabled with the "must use coupon" setting checked.', 'woocommerce' ), admin_url('admin.php?page=woocommerce_settings&tab=shipping&section=WC_Shipping_Free_Shipping')) ) );
// Individual use
woocommerce_wp_checkbox( array( 'id' => 'individual_use', 'label' => __( 'Individual use', 'woocommerce' ), 'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ) ) );
woocommerce_wp_checkbox( array( 'id' => 'free_shipping', 'label' => __( 'Allow free shipping', 'woocommerce' ), 'description' => sprintf(__( 'Check this box if the coupon grants free shipping. The <a href="%s">free shipping method</a> must be enabled with the "must use coupon" setting.', 'woocommerce' ), admin_url('admin.php?page=woocommerce_settings&tab=shipping&section=WC_Shipping_Free_Shipping')) ) );
// Apply before tax
woocommerce_wp_checkbox( array( 'id' => 'apply_before_tax', 'label' => __( 'Apply before tax', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should be applied before calculating cart tax.', 'woocommerce' ) ) );
// Exclude Sale Products
woocommerce_wp_checkbox( array( 'id' => 'exclude_sale_items', 'label' => __( 'Exclude sale items', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' ) ) );
// Expiry date
woocommerce_wp_text_input( array( 'id' => 'expiry_date', 'label' => __( 'Coupon expiry date', 'woocommerce' ), 'placeholder' => _x( 'YYYY-MM-DD', 'placeholder', 'woocommerce' ), 'description' => '', 'class' => 'date-picker', 'custom_attributes' => array( 'pattern' => "[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" ) ) );
echo '</div><div class="options_group">';
do_action( 'woocommerce_coupon_options' );
?></div>
<div id="usage_restriction_coupon_data" class="panel woocommerce_options_panel"><?php
echo '<div class="options_group">';
// minimum spend
woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum amount', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum subtotal needed to use the coupon.', 'woocommerce' ), 'class' => 'wc_input_decimal' ) );
woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum spend', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum subtotal needed to use the coupon.', 'woocommerce' ), 'class' => 'wc_input_decimal', 'desc_tip' => true ) );
// Individual use
woocommerce_wp_checkbox( array( 'id' => 'individual_use', 'label' => __( 'Individual use only', 'woocommerce' ), 'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ) ) );
// Exclude Sale Products
woocommerce_wp_checkbox( array( 'id' => 'exclude_sale_items', 'label' => __( 'Exclude sale items', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' ) ) );
echo '</div><div class="options_group">';
@ -133,31 +163,39 @@ class WC_Meta_Box_Coupon_Data {
echo '</div><div class="options_group">';
// Customers
woocommerce_wp_text_input( array( 'id' => 'customer_email', 'label' => __( 'Email restrictions', 'woocommerce' ), 'placeholder' => __( 'No restrictions', 'woocommerce' ), 'description' => __( 'List of emails to check against the customer\'s billing email when an order is placed.', 'woocommerce' ), 'value' => implode(', ', (array) get_post_meta( $post->ID, 'customer_email', true ) ), 'type' => 'email', 'custom_attributes' => array(
woocommerce_wp_text_input( array( 'id' => 'customer_email', 'label' => __( 'Email restrictions', 'woocommerce' ), 'placeholder' => __( 'No restrictions', 'woocommerce' ), 'description' => __( 'List of emails to check against the customer\'s billing email when an order is placed.', 'woocommerce' ), 'value' => implode(', ', (array) get_post_meta( $post->ID, 'customer_email', true ) ), 'desc_tip' => true, 'type' => 'email', 'class' => '', 'custom_attributes' => array(
'multiple' => 'multiple'
) ) );
echo '</div><div class="options_group">';
echo '</div>';
// Usage limit
woocommerce_wp_text_input( array( 'id' => 'usage_limit', 'label' => __( 'Usage limit per coupon', 'woocommerce' ), 'placeholder' => _x('Unlimited usage', 'placeholder', 'woocommerce'), 'description' => __( 'How many times this coupon can be used before it is void.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
?></div>
<div id="usage_limit_coupon_data" class="panel woocommerce_options_panel"><?php
echo '<div class="options_group">';
// Usage limit per coupons
woocommerce_wp_text_input( array( 'id' => 'usage_limit', 'label' => __( 'Usage limit per coupon', 'woocommerce' ), 'placeholder' => _x('Unlimited usage', 'placeholder', 'woocommerce'), 'description' => __( 'How many times this coupon can be used before it is void.', 'woocommerce' ), 'type' => 'number', 'desc_tip' => true, 'class' => '', 'custom_attributes' => array(
'step' => '1',
'min' => '0'
) ) );
// Usage limit
woocommerce_wp_text_input( array( 'id' => 'usage_limit_per_user', 'label' => __( 'Usage limit per user', 'woocommerce' ), 'placeholder' => _x( 'Unlimited usage', 'placeholder', 'woocommerce' ), 'description' => __( 'How many times this coupon can be used by an invidual user. Uses billing email for guests, and user ID for logged in users.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
// Usage limit per product
woocommerce_wp_text_input( array( 'id' => 'limit_usage_to_x_items', 'label' => __( 'Limit usage to X items', 'woocommerce' ), 'placeholder' => _x( 'Apply to all qualifying items in cart', 'placeholder', 'woocommerce' ), 'description' => __( 'The maximum number of individual items this coupon can apply to when using product discounts. Leave blank to apply to all qualifying items in cart.', 'woocommerce' ), 'desc_tip' => true, 'class' => '', 'type' => 'number', 'custom_attributes' => array(
'step' => '1',
'min' => '0'
) ) );
// Expiry date
woocommerce_wp_text_input( array( 'id' => 'expiry_date', 'label' => __( 'Expiry date', 'woocommerce' ), 'placeholder' => _x('Never expire', 'placeholder', 'woocommerce'), 'description' => __( 'The date this coupon will expire, <code>YYYY-MM-DD</code>.', 'woocommerce' ), 'class' => 'short date-picker', 'custom_attributes' => array( 'pattern' => "[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" ) ) );
// Usage limit per users
woocommerce_wp_text_input( array( 'id' => 'usage_limit_per_user', 'label' => __( 'Usage limit per user', 'woocommerce' ), 'placeholder' => _x( 'Unlimited usage', 'placeholder', 'woocommerce' ), 'description' => __( 'How many times this coupon can be used by an invidual user. Uses billing email for guests, and user ID for logged in users.', 'woocommerce' ), 'desc_tip' => true, 'class' => '', 'type' => 'number', 'custom_attributes' => array(
'step' => '1',
'min' => '0'
) ) );
echo '</div>';
do_action( 'woocommerce_coupon_options' );
?>
?></div>
<div class="clear"></div>
</div>
<?php
}
@ -190,6 +228,7 @@ class WC_Meta_Box_Coupon_Data {
$amount = woocommerce_format_decimal( $_POST['coupon_amount'], false );
$usage_limit = empty( $_POST['usage_limit'] ) ? '' : absint( $_POST['usage_limit'] );
$usage_limit_per_user = empty( $_POST['usage_limit_per_user'] ) ? '' : absint( $_POST['usage_limit_per_user'] );
$limit_usage_to_x_items = empty( $_POST['limit_usage_to_x_items'] ) ? '' : absint( $_POST['limit_usage_to_x_items'] );
$individual_use = isset( $_POST['individual_use'] ) ? 'yes' : 'no';
$expiry_date = woocommerce_clean( $_POST['expiry_date'] );
$apply_before_tax = isset( $_POST['apply_before_tax'] ) ? 'yes' : 'no';
@ -221,6 +260,7 @@ class WC_Meta_Box_Coupon_Data {
update_post_meta( $post_id, 'exclude_product_ids', $exclude_product_ids );
update_post_meta( $post_id, 'usage_limit', $usage_limit );
update_post_meta( $post_id, 'usage_limit_per_user', $usage_limit_per_user );
update_post_meta( $post_id, 'limit_usage_to_x_items', $limit_usage_to_x_items );
update_post_meta( $post_id, 'expiry_date', $expiry_date );
update_post_meta( $post_id, 'apply_before_tax', $apply_before_tax );
update_post_meta( $post_id, 'free_shipping', $free_shipping );

File diff suppressed because it is too large Load Diff

View File

@ -345,8 +345,8 @@ class WC_Checkout {
}
// Store coupons
if ( $applied_coupons = $woocommerce->cart->get_applied_coupons() ) {
foreach ( $applied_coupons as $code ) {
if ( $applied_coupons = $woocommerce->cart->get_coupons() ) {
foreach ( $applied_coupons as $code => $coupon ) {
$item_id = woocommerce_add_order_item( $order_id, array(
'order_item_name' => $code,

View File

@ -54,6 +54,9 @@ class WC_Coupon {
/** @public int Coupon usage limit per user. */
public $usage_limit_per_user;
/** @public int Coupon usage limit per item. */
public $limit_usage_to_x_items;
/** @public int Coupon usage count. */
public $usage_count;
@ -115,6 +118,7 @@ class WC_Coupon {
$this->exclude_product_ids = is_array( $coupon_data['exclude_product_ids'] ) ? $coupon_data['exclude_product_ids'] : array();
$this->usage_limit = absint( $coupon_data['usage_limit'] );
$this->usage_limit_per_user = isset( $coupon_data['usage_limit_per_user'] ) ? absint( $coupon_data['usage_limit_per_user'] ) : 0;
$this->limit_usage_to_x_items = isset( $coupon_data['limit_usage_to_x_items'] ) ? absint( $coupon_data['limit_usage_to_x_items'] ) : '';
$this->usage_count = absint( $coupon_data['usage_count'] );
$this->expiry_date = esc_html( $coupon_data['expiry_date'] );
$this->apply_before_tax = esc_html( $coupon_data['apply_before_tax'] );
@ -133,7 +137,7 @@ class WC_Coupon {
return;
$coupon = get_post( $coupon_id );
$coupon->post_title = apply_filters( 'woocommerce_coupon_code', $coupon->post_title );
$this->post_title = apply_filters( 'woocommerce_coupon_code', $coupon->post_title );
if ( empty( $coupon ) || $this->code !== $coupon->post_title )
return;
@ -149,6 +153,7 @@ class WC_Coupon {
'exclude_product_ids' => '',
'usage_limit' => '',
'usage_limit_per_user' => '',
'limit_usage_to_x_items' => '',
'usage_count' => '',
'expiry_date' => '',
'apply_before_tax' => 'yes',
@ -420,6 +425,116 @@ class WC_Coupon {
return false;
}
public function is_valid_for_cart() {
if ( $this->type != 'fixed_cart' && $this->type != 'percent' )
return false;
else
return true;
}
/**
* Check if a coupon is valid for a product
*
* @param WC_Product $product
* @return boolean
*/
public function is_valid_for_product( $product ) {
if ( $this->type != 'fixed_product' && $this->type != 'percent_product' )
return false;
$valid = false;
$product_cats = wp_get_post_terms( $product->id, 'product_cat', array( "fields" => "ids" ) );
// Specific products get the discount
if ( sizeof( $this->product_ids ) > 0 ) {
if ( in_array( $product->id, $this->product_ids ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $this->product_ids ) ) || in_array( $product->get_parent(), $this->product_ids ) )
$valid = true;
// Category discounts
} elseif ( sizeof( $this->product_categories ) > 0 ) {
if ( sizeof( array_intersect( $product_cats, $this->product_categories ) ) > 0 )
$valid = true;
} else {
// No product ids - all items discounted
$valid = true;
}
// Specific product ID's excluded from the discount
if ( sizeof( $this->exclude_product_ids ) > 0 )
if ( in_array( $product->id, $this->exclude_product_ids ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $this->exclude_product_ids ) ) || in_array( $product->get_parent(), $this->exclude_product_ids ) )
$valid = false;
// Specific categories excluded from the discount
if ( sizeof( $this->exclude_product_categories ) > 0 )
if ( sizeof( array_intersect( $product_cats, $this->exclude_product_categories ) ) > 0 )
$valid = false;
// Sale Items excluded from discount
if ( $this->exclude_sale_items == 'yes' ) {
$product_ids_on_sale = woocommerce_get_product_ids_on_sale();
if ( in_array( $product->id, $product_ids_on_sale, true ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $product_ids_on_sale, true ) ) || in_array( $product->get_parent(), $product_ids_on_sale, true ) )
$valid = false;
}
return apply_filters( 'woocommerce_coupon_is_valid_for_product', $valid, $product, $this );
}
/**
* Get discount amount for a cart item
*
* @param float $discounting_amount Amount the coupon is being applied to
* @param array|null $cart_item Cart item being discounted if applicable
* @param boolean $single True if discounting a single qty item, false if its the line
* @return float Amount this coupon has discounted
*/
public function get_discount_amount( $discounting_amount, $cart_item = null, $single = false ) {
$discount = 0;
if ( $this->type == 'fixed_product') {
$discount = $discounting_amount < $this->amount ? $discounting_amount : $this->amount;
} elseif ( $this->type == 'percent_product' || $this->type == 'percent' ) {
$discount = ( $discounting_amount / 100 ) * $this->amount;
} elseif ( $this->type == 'fixed_cart' ) {
if ( ! is_null( $cart_item ) ) {
/**
* This is the most complex discount - we need to divide the discount between rows based on their price in
* proportion to the subtotal. This is so rows with different tax rates get a fair discount, and so rows
* with no price (free) don't get discounted.
*
* Get item discount by dividing item cost by subtotal to get a %
*/
$discount_percent = 0;
if ( WC()->cart->subtotal_ex_tax )
$discount_percent = ( $cart_item['data']->get_price_excluding_tax() * $cart_item['quantity'] ) / WC()->cart->subtotal_ex_tax;
$discount = min( ( $this->amount * $discount_percent ) / $cart_item['quantity'], $discounting_amount );
} else {
$discount = min( $this->amount, $discounting_amount );
}
}
if ( in_array( $this->type, array( 'percent_product', 'fixed_product' ) ) && ! is_null( $cart_item ) ) {
$qty = empty( $this->limit_usage_to_x_items ) ? $cart_item['quantity'] : min( $this->limit_usage_to_x_items, $cart_item['quantity'] );
if ( $single ) {
$discount = ( $discount * $qty ) / $cart_item['quantity'];
} else {
$discount = ( $discount / $cart_item['quantity'] ) * $qty;
}
}
return $discount;
}
/**
* Converts one of the WC_Coupon message/error codes to a message string and
* displays the message/error.

View File

@ -173,10 +173,8 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
if ( in_array( $this->requires, array( 'coupon', 'either', 'both' ) ) ) {
if ( $woocommerce->cart->applied_coupons ) {
foreach ($woocommerce->cart->applied_coupons as $code) {
$coupon = new WC_Coupon( $code );
if ( $coupons = $woocommerce->cart->get_coupons() ) {
foreach ( $coupons as $code => $coupon ) {
if ( $coupon->is_valid() && $coupon->enable_free_shipping() )
$has_coupon = true;
}

View File

@ -1102,17 +1102,19 @@ function wc_cart_totals_subtotal_html() {
* Get a coupon value
* @param string $code
*/
function wc_cart_totals_coupon_html( $code ) {
$coupon = new WC_Coupon( $code );
function wc_cart_totals_coupon_html( $coupon ) {
if ( is_string( $coupon ) )
$coupon = new WC_Coupon( $coupon );
$value = array();
if ( ! empty( WC()->cart->coupon_discount_amounts[ $code ] ) )
$value[] = '-' . woocommerce_price( WC()->cart->coupon_discount_amounts[ $code ] );
if ( ! empty( WC()->cart->coupon_discount_amounts[ $coupon->code ] ) )
$value[] = '-' . woocommerce_price( WC()->cart->coupon_discount_amounts[ $coupon->code ] );
if ( $coupon->enable_free_shipping() )
$value[] = __( 'Free shipping coupon', 'woocommerce' );
echo implode( ', ', $value ) . ' <a href="' . add_query_arg( 'remove_coupon', $code, WC()->cart->get_cart_url() ) . '" class="woocommerce-remove-coupon">' . __( '[Remove]', 'woocommerce' ) . '</a>';
echo implode( ', ', $value ) . ' <a href="' . add_query_arg( 'remove_coupon', $coupon->code, WC()->cart->get_cart_url() ) . '" class="woocommerce-remove-coupon">' . __( '[Remove]', 'woocommerce' ) . '</a>';
}
/**

View File

@ -22,10 +22,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_applied_coupons( 'cart' ) as $code ) : ?>
<?php foreach ( WC()->cart->get_coupons( 'cart' ) as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php echo esc_html( $code ); ?></th>
<td><?php wc_cart_totals_coupon_html( $code ); ?></td>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
@ -62,10 +62,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php endif; ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_applied_coupons( 'order' ) as $code ) : ?>
<?php foreach ( WC()->cart->get_coupons( 'order' ) as $code => $coupon ) : ?>
<tr class="order-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php echo esc_html( $code ); ?></th>
<td><?php wc_cart_totals_coupon_html( $code ); ?></td>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>

View File

@ -26,10 +26,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_applied_coupons( 'cart' ) as $code ) : ?>
<?php foreach ( WC()->cart->get_coupons( 'cart' ) as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php echo esc_html( $code ); ?></th>
<td><?php wc_cart_totals_coupon_html( $code ); ?></td>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
@ -66,10 +66,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php endif; ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_applied_coupons( 'order' ) as $code ) : ?>
<?php foreach ( WC()->cart->get_coupons( 'order' ) as $code => $coupon ) : ?>
<tr class="order-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php echo esc_html( $code ); ?></th>
<td><?php wc_cart_totals_coupon_html( $code ); ?></td>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>