WooCommerce Quantity Increment - Version 1.0.0

Version Description

Download this release

Release Info

Developer captaintheme
Plugin Icon 128x128 WooCommerce Quantity Increment
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

assets/css/.sass-cache/6204c37d5a1b3dd02c2bcaccc507b6890dad22fe/wc-quantity-increment.scssc ADDED
Binary file
assets/css/.sass-cache/6204c37d5a1b3dd02c2bcaccc507b6890dad22fe/wc-quantiy-increment.scssc ADDED
Binary file
assets/css/wc-quantity-increment.css ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Styling begins
3
+ */
4
+ .woocommerce, .woocommerce-page {
5
+ /**
6
+ * Quantity inputs
7
+ */ }
8
+ .woocommerce #quantity input::-webkit-outer-spin-button,
9
+ .woocommerce #quantity input::-webkit-inner-spin-button,
10
+ .woocommerce #content .quantity input::-webkit-outer-spin-button,
11
+ .woocommerce #content .quantity input::-webkit-inner-spin-button, .woocommerce-page #quantity input::-webkit-outer-spin-button,
12
+ .woocommerce-page #quantity input::-webkit-inner-spin-button,
13
+ .woocommerce-page #content .quantity input::-webkit-outer-spin-button,
14
+ .woocommerce-page #content .quantity input::-webkit-inner-spin-button {
15
+ display: none; }
16
+ .woocommerce .quantity, .woocommerce-page .quantity {
17
+ position: relative;
18
+ margin: 0 auto;
19
+ overflow: hidden;
20
+ zoom: 1;
21
+ padding-right: 1.1em;
22
+ display: inline-block;
23
+ /* Hide buttons for opera */ }
24
+ .woocommerce .quantity input.qty, .woocommerce-page .quantity input.qty {
25
+ width: 2.618em;
26
+ height: 2.1em;
27
+ float: left;
28
+ padding: 0;
29
+ margin: 0;
30
+ text-align: center;
31
+ border: 1px solid #bbb3b9;
32
+ border-right: 0;
33
+ font-weight: 700;
34
+ border-radius: 2px 0 0 2px;
35
+ -moz-appearance: textfield;
36
+ /* Hide buttons for Firefox 29 and later */ }
37
+ .woocommerce .quantity noindex:-o-prefocus, .woocommerce .quantity input[type=number], .woocommerce-page .quantity noindex:-o-prefocus, .woocommerce-page .quantity input[type=number] {
38
+ padding-right: 1.2em; }
39
+ .woocommerce .quantity .plus,
40
+ .woocommerce .quantity .minus, .woocommerce-page .quantity .plus,
41
+ .woocommerce-page .quantity .minus {
42
+ display: block;
43
+ padding: 0;
44
+ margin: 0;
45
+ position: absolute;
46
+ text-align: center;
47
+ width: 1.387em;
48
+ height: 1.12em;
49
+ text-decoration: none;
50
+ overflow: visible;
51
+ text-decoration: none;
52
+ font-weight: 700;
53
+ cursor: pointer;
54
+ color: #515151;
55
+ border: 1px solid #bbb3b9;
56
+ background-color: #ebe9eb;
57
+ text-shadow: none;
58
+ line-height: 1;
59
+ background-image: none; }
60
+ .woocommerce .quantity .plus:hover,
61
+ .woocommerce .quantity .minus:hover, .woocommerce-page .quantity .plus:hover,
62
+ .woocommerce-page .quantity .minus:hover {
63
+ background-color: #dad8da; }
64
+ .woocommerce .quantity .plus, .woocommerce-page .quantity .plus {
65
+ top: 0;
66
+ right: 0;
67
+ border-bottom: 0;
68
+ border-radius: 2px 2px 0 0; }
69
+ .woocommerce .quantity .minus, .woocommerce-page .quantity .minus {
70
+ bottom: 0;
71
+ right: 0;
72
+ border-radius: 0 0 2px 2px; }
assets/css/wc-quantity-increment.scss ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Variables
2
+ $primary: #a46497; // Primary colour for buttons (alt)
3
+ $primarytext: desaturate(lighten($primary, 50%), 18%); // Text on primary colour bg
4
+
5
+ $secondary: desaturate(lighten($primary, 40%), 21%); // Secondary buttons
6
+ $secondarytext: desaturate(darken($secondary, 60%), 21%); // Text on secondary colour bg
7
+
8
+ /**
9
+ * Styling begins
10
+ */
11
+ .woocommerce, .woocommerce-page {
12
+ #quantity,
13
+ #content .quantity {
14
+ input::-webkit-outer-spin-button,
15
+ input::-webkit-inner-spin-button {
16
+ display: none;
17
+ }
18
+ }
19
+ /**
20
+ * Quantity inputs
21
+ */
22
+ .quantity {
23
+ position: relative;
24
+ margin: 0 auto;
25
+ overflow: hidden;
26
+ zoom: 1;
27
+ padding-right: 1.1em;
28
+ display: inline-block;
29
+
30
+ input.qty {
31
+ width: 2.618em;
32
+ height: 2.1em;
33
+ float: left;
34
+ padding: 0;
35
+ margin: 0;
36
+ text-align: center;
37
+ border: 1px solid darken( $secondary, 20% );
38
+ border-right: 0;
39
+ font-weight: 700;
40
+ border-radius: 2px 0 0 2px;
41
+ -moz-appearance: textfield; /* Hide buttons for Firefox 29 and later */
42
+ }
43
+
44
+ /* Hide buttons for opera */
45
+ noindex:-o-prefocus, input[type=number] {
46
+ padding-right: 1.2em;
47
+ }
48
+
49
+ .plus,
50
+ .minus {
51
+ display: block;
52
+ padding: 0;
53
+ margin: 0;
54
+ position: absolute;
55
+ text-align: center;
56
+ width: 1.387em;
57
+ height: 1.12em;
58
+ text-decoration: none;
59
+ overflow: visible;
60
+ text-decoration: none;
61
+ font-weight: 700;
62
+ cursor: pointer;
63
+ color: $secondarytext;
64
+ border: 1px solid darken( $secondary, 20% );
65
+ background-color: $secondary;
66
+ text-shadow: none;
67
+ line-height: 1;
68
+ background-image: none;
69
+
70
+ &:hover {
71
+ background-color: $secondary - #111;
72
+ }
73
+ }
74
+
75
+ .plus {
76
+ top: 0;
77
+ right: 0;
78
+ border-bottom: 0;
79
+ border-radius: 2px 2px 0 0;
80
+ }
81
+
82
+ .minus {
83
+ bottom: 0;
84
+ right: 0;
85
+ border-radius: 0 0 2px 2px;
86
+ }
87
+ }
88
+ }
assets/js/lib/number-polyfill.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(){(function(e){var t,n;return t=document.createElement("input"),t.setAttribute("type","number"),"text"!==t.type?(e.fn.inputNumber=function(){return e(this)},void 0):(e.fn.inputNumber=function(){return e(this).filter(function(){var t;return t=e(this),t.is('input[type="number"]')&&!(t.parent().is("span")&&t.next().is("div.number-spin-btn-container")&&t.next().children().first().is("div.number-spin-btn-up")&&t.next().children().eq(1).is("div.number-spin-btn-down"))}).each(function(){n.polyfills.push(new n(this))}),e(this)},n=function(t){var i,r,o,s,a=this;if(this.elem=e(t),!(this.elem.is(":root *")&&this.elem.height()>0))throw Error("Element must be in DOM and displayed so that its height can be measured.");s=this.elem.outerHeight()/2+"px",this.upBtn=e("<div/>",{"class":"number-spin-btn number-spin-btn-up",style:"height: "+s}),this.downBtn=e("<div/>",{"class":"number-spin-btn number-spin-btn-down",style:"height: "+s}),this.btnContainer=e("<div/>",{"class":"number-spin-btn-container"}),i=e("<span/>",{style:"white-space: nowrap"}),this.upBtn.appendTo(this.btnContainer),this.downBtn.appendTo(this.btnContainer),this.elem.wrap(i),this.btnContainer.insertAfter(this.elem),this.elem.on({focus:function(){a.elem.on({DOMMouseScroll:n.domMouseScrollHandler,mousewheel:n.mouseWheelHandler},{p:a})},blur:function(){a.elem.off({DOMMouseScroll:n.domMouseScrollHandler,mousewheel:n.mouseWheelHandler})}}),this.elem.on({keypress:n.elemKeypressHandler,change:n.elemChangeHandler},{p:this}),this.upBtn.on("mousedown",{p:this,func:"increment"},n.elemBtnMousedownHandler),this.downBtn.on("mousedown",{p:this,func:"decrement"},n.elemBtnMousedownHandler),this.elem.css("textAlign","right"),this.attrMutationHandler("class"),"undefined"!=typeof WebKitMutationObserver&&null!==WebKitMutationObserver||r!==void 0&&null!==r?("undefined"==typeof WebKitMutationObserver||null===WebKitMutationObserver||void 0!==r&&null!==r||(r=WebKitMutationObserver),o=new r(function(e){var t,n,i;for(n=0,i=e.length;i>n;n++)t=e[n],"attributes"===t.type&&a.attrMutationHandler(t.attributeName,t.oldValue,a.elem.attr(t.attributeName))}),o.observe(t,{attributes:!0,attributeOldValue:!0,attributeFilter:["class","style","min","max","step"]})):"undefined"!=typeof MutationEvent&&null!==MutationEvent&&this.elem.on("DOMAttrModified",function(e){a.attrMutationHandler(e.originalEvent.attrName,e.originalEvent.prevValue,e.originalEvent.newValue)})},n.polyfills=[],n.isNumber=function(e){return null!=e&&"function"==typeof e.toString?/^-?\d+(?:\.\d+)?$/.test(""+e):!1},n.isFloat=function(e){return null!=e&&"function"==typeof e.toString?/^-?\d+\.\d+$/.test(""+e):!1},n.isInt=function(e){return null!=e&&"function"==typeof e.toString?/^-?\d+$/.test(""+e):!1},n.isNegative=function(e){return null!=e&&"function"==typeof e.toString?/^-\d+(?:\.\d+)?$/.test(""+e):!1},n.raiseNum=function(e){var t,i,r;if("number"==typeof e||"object"==typeof e&&e instanceof Number)return e%1?{num:""+e,precision:0}:n.raiseNum(""+e);if("string"==typeof e||"object"==typeof e&&e instanceof String){if(n.isFloat(e))return e=e.replace(/(\.\d)0+$/,"$1"),r=n.getPrecision(e),i=e.slice(0,-(r+1))+e.slice(-r),i=i.replace(/^(-?)0+(\d+)/,"$1$2"),t={num:i,precision:r};if(n.isInt(e))return{num:e,precision:0}}},n.raiseNumPrecision=function(e,n){var i,r;if(n>e.precision){for(t=i=r=e.precision;n>=r?n>i:i>n;t=n>=r?++i:--i)e.num+="0";e.precision=n}},n.lowerNum=function(e){if(e.precision>0){for(;e.num.length<e.precision+1;)e.num=n.isNegative(e.num)?e.num.slice(0,1)+"0"+e.num.slice(1):"0"+e.num;return(e.num.slice(0,-e.precision)+"."+e.num.slice(-e.precision)).replace(/\.?0+$/,"").replace(/^(-?)(\.)/,"$10$2")}return e.num},n.preciseAdd=function(e,t){var i,r,o;if(("number"==typeof e||"object"==typeof e&&e instanceof Number)&&("number"==typeof t||"object"==typeof t&&t instanceof Number))return 0===e%1&&0===t%1?""+(e+t):n.preciseAdd(""+e,""+t);if(("string"==typeof e||"object"==typeof e&&e instanceof String)&&("string"==typeof t||"object"==typeof t&&t instanceof String)){if(n.isNumber(e)){if(n.isNumber(t)){if(n.isInt(e)){if(n.isInt(t))return n.preciseAdd(parseInt(e,10),parseInt(t,10));n.isFloat(t)&&(e+=".0")}else n.isFloat(e)&&n.isInt(t)&&(t+=".0");if(i=n.raiseNum(e),r=n.raiseNum(t),i.precision<r.precision?n.raiseNumPrecision(i,r.precision):i.precision>r.precision&&n.raiseNumPrecision(r,i.precision),o=""+(parseInt(i.num,10)+parseInt(r.num,10)),i.precision>0){if(n.isNegative(o))for(;i.precision>o.length-1;)o="-0"+o.slice(1);else for(;i.precision>o.length;)o="0"+o;o=n.lowerNum({num:o,precision:i.precision})}return o=o.replace(/^(-?)\./,"$10."),n.isFloat(o)&&(o=o.replace(/0+$/,"")),o}throw new SyntaxError('Argument "'+t+'" is not a number.')}throw new SyntaxError('Argument "'+e+'" is not a number.')}return n.preciseAdd(""+e,""+t)},n.preciseSubtract=function(e,t){return"number"==typeof t||"object"==typeof t&&t instanceof Number?n.preciseAdd(e,-t):"string"==typeof t||"object"==typeof t&&t instanceof String?n.isNegative(t)?n.preciseAdd(e,t.slice(1)):n.preciseAdd(e,"-"+t):void 0},n.getPrecision=function(e){var t,i;if("number"==typeof e){for(t=0,i=e;i!==Math.floor(i);)i=e*Math.pow(10,++t);return t}return"string"==typeof e&&n.isNumber(e)?n.isFloat(e)?/^-?\d+(?:\.(\d+))?$/.exec(e)[1].length:0:void 0},n.prototype.getParams=function(){var e,t,i,r;return i=this.elem.attr("step"),t=this.elem.attr("min"),e=this.elem.attr("max"),r=this.elem.val(),n.isNumber(i)||(i=null),n.isNumber(t)||(t=null),n.isNumber(e)||(e=null),n.isNumber(r)||(r=t||0),{min:null!=t?t:null,max:null!=e?e:null,step:null!=i?i:"1",val:null!=r?r:null}},n.prototype.clipValues=function(e,t,n){return null!=n&&parseFloat(e)>parseFloat(n)?n:null!=t&&parseFloat(e)<parseFloat(t)?t:e},n.prototype.stepNormalize=function(e){var t,i,r,o,s;return r=this.getParams(),s=r.step,i=r.min,null==s?e:(s=n.raiseNum(s),t=n.raiseNum(e),t.precision>s.precision?n.raiseNumPrecision(s,t.precision):t.precision<s.precision&&n.raiseNumPrecision(t,s.precision),null!=i&&(t=n.raiseNum(n.preciseSubtract(e,i)),n.raiseNumPrecision(t,s.precision)),0===parseFloat(t.num)%parseFloat(s.num)?e:(t=n.lowerNum({num:""+Math.round(parseFloat(t.num)/(o=parseFloat(s.num)))*o,precision:t.precision}),null!=i&&(t=n.preciseAdd(t,i)),t))},n.domMouseScrollHandler=function(e){var t;t=e.data.p,e.preventDefault(),0>e.originalEvent.detail?t.increment():t.decrement()},n.mouseWheelHandler=function(e){var t;t=e.data.p,e.preventDefault(),e.originalEvent.wheelDelta>0?t.increment():t.decrement()},n.elemKeypressHandler=function(e){var t,n,i;t=e.data.p,38===e.keyCode?t.increment():40===e.keyCode?t.decrement():8!==(n=e.keyCode)&&9!==n&&35!==n&&36!==n&&37!==n&&39!==n&&46!==n&&45!==(i=e.which)&&46!==i&&48!==i&&49!==i&&50!==i&&51!==i&&52!==i&&53!==i&&54!==i&&55!==i&&56!==i&&57!==i&&e.preventDefault()},n.elemChangeHandler=function(e){var t,i,r,o;r=e.data.p,""!==r.elem.val()&&(n.isNumber(r.elem.val())?(o=r.getParams(),i=r.clipValues(o.val,o.min,o.max),i=r.stepNormalize(i),""+i!==r.elem.val()&&r.elem.val(i).change()):(t=r.elem.attr("min"),r.elem.val(null!=t&&n.isNumber(t)?t:"0").change()))},n.elemBtnMousedownHandler=function(t){var n,i,r,o,s=this;i=t.data.p,n=t.data.func,i[n](),o=function(){i[n](),i.timeoutID=window.setTimeout(o,10)},r=function(){window.clearTimeout(i.timeoutID),e(document).off("mouseup",r),e(s).off("mouseleave",r)},e(document).on("mouseup",r),e(this).on("mouseleave",r),i.timeoutID=window.setTimeout(o,700)},n.prototype.attrMutationHandler=function(e){var n,i,r,o,s;if("class"===e||"style"===e){for(i={},n=null,s=["opacity","visibility","-moz-transition-property","-moz-transition-duration","-moz-transition-timing-function","-moz-transition-delay","-webkit-transition-property","-webkit-transition-duration","-webkit-transition-timing-function","-webkit-transition-delay","-o-transition-property","-o-transition-duration","-o-transition-timing-function","-o-transition-delay","transition-property","transition-duration","transition-timing-function","transition-delay"],r=0,o=s.length;o>r;r++)t=s[r],(n=this.elem.css(t))!==this.btnContainer.css(t)&&(i[t]=n);i.display="none"===this.elem.css("display")?"none":"inline-block",this.btnContainer.css(i)}else("min"===e||"max"===e||"step"===e)&&this.elem.change()},n.prototype.increment=function(){var e,t;this.elem.is(":disabled")||this.elem.is("[readonly]")||(t=this.getParams(),e=n.preciseAdd(t.val,t.step),null!=t.max&&parseFloat(e)>parseFloat(t.max)&&(e=t.max),e=this.stepNormalize(e),this.elem.val(e).change())},n.prototype.decrement=function(){var e,t;this.elem.is(":disabled")||this.elem.is("[readonly]")||(t=this.getParams(),e=n.preciseSubtract(t.val,t.step),null!=t.min&&parseFloat(e)<parseFloat(t.min)&&(e=t.min),e=this.stepNormalize(e),this.elem.val(e).change())},e(function(){e('input[type="number"]').inputNumber()}),void 0)})(jQuery)}).call(this);
assets/js/wc-quantity-increment.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function( $ ) {
2
+
3
+ // Quantity buttons
4
+ $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<input type="button" value="+" class="plus" />' ).prepend( '<input type="button" value="-" class="minus" />' );
5
+
6
+ $( document ).on( 'click', '.plus, .minus', function() {
7
+
8
+ // Get values
9
+ var $qty = $( this ).closest( '.quantity' ).find( '.qty' ),
10
+ currentVal = parseFloat( $qty.val() ),
11
+ max = parseFloat( $qty.attr( 'max' ) ),
12
+ min = parseFloat( $qty.attr( 'min' ) ),
13
+ step = $qty.attr( 'step' );
14
+
15
+ // Format values
16
+ if ( ! currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
17
+ if ( max === '' || max === 'NaN' ) max = '';
18
+ if ( min === '' || min === 'NaN' ) min = 0;
19
+ if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = 1;
20
+
21
+ // Change the value
22
+ if ( $( this ).is( '.plus' ) ) {
23
+
24
+ if ( max && ( max == currentVal || currentVal > max ) ) {
25
+ $qty.val( max );
26
+ } else {
27
+ $qty.val( currentVal + parseFloat( step ) );
28
+ }
29
+
30
+ } else {
31
+
32
+ if ( min && ( min == currentVal || currentVal < min ) ) {
33
+ $qty.val( min );
34
+ } else if ( currentVal > 0 ) {
35
+ $qty.val( currentVal - parseFloat( step ) );
36
+ }
37
+
38
+ }
39
+
40
+ // Trigger change event
41
+ $qty.trigger( 'change' );
42
+
43
+ });
44
+
45
+ });
assets/js/wc-quantity-increment.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function($){$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />'),$(document).on("click",".plus, .minus",function(){var t=$(this).closest(".quantity").find(".qty"),a=parseFloat(t.val()),n=parseFloat(t.attr("max")),s=parseFloat(t.attr("min")),e=t.attr("step");a&&""!==a&&"NaN"!==a||(a=0),(""===n||"NaN"===n)&&(n=""),(""===s||"NaN"===s)&&(s=0),("any"===e||""===e||void 0===e||"NaN"===parseFloat(e))&&(e=1),$(this).is(".plus")?t.val(n&&(n==a||a>n)?n:a+parseFloat(e)):s&&(s==a||s>a)?t.val(s):a>0&&t.val(a-parseFloat(e)),t.trigger("change")})});
includes/class-wc-quantity-increment.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ class WooCommerce_Quantity_Increment_Init {
7
+
8
+ function __construct() {
9
+
10
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
11
+
12
+ }
13
+
14
+ public function enqueue_scripts() {
15
+
16
+ $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
17
+
18
+ wp_register_script( 'wcqi-js', plugins_url( 'assets/js/wc-quantity-increment' . $min . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery' ) );
19
+ wp_register_style( 'wcqi-css', plugins_url( 'assets/css/wc-quantity-increment.css', plugin_dir_path( __FILE__ ) ) );
20
+ wp_register_script( 'wcqi-number-polyfill', plugins_url( 'assets/js/lib/number-polyfill.min.js', plugin_dir_path( __FILE__ ) ) );
21
+
22
+ wp_enqueue_script( 'wcqi-js' );
23
+ wp_enqueue_style( 'wcqi-css' );
24
+
25
+ }
26
+
27
+ }
28
+
29
+ new WooCommerce_Quantity_Increment_Init;
languages/woocommerce-quantity-increment-en_GB.mo ADDED
Binary file
languages/woocommerce-quantity-increment-en_GB.po ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WooCommerce Quantity Increment\n"
4
+ "POT-Creation-Date: 2014-11-19 12:50+0700\n"
5
+ "PO-Revision-Date: 2014-11-19 12:50+0700\n"
6
+ "Last-Translator: Bryce <bryce@bryce.se>\n"
7
+ "Language-Team: WooThemes <help@woothemes.com>\n"
8
+ "Language: en_GB\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.4\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../woocommerce-quantity-increment.php:119
19
+ #, php-format
20
+ msgid "WooCommerce Quantity Increment requires the %s 2.3 or higher to work!"
21
+ msgstr ""
22
+
23
+ #: ../woocommerce-quantity-increment.php:119
24
+ msgid "WooCommerce"
25
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: woothemes, bryceadams
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
4
+ Tags: woocommerce, woothemes, quantity, quantity increment, quantity buttons
5
+ Requires at least: 3.6.1
6
+ Tested up to: 4.1
7
+ Stable tag: 1.0.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ WooCommerce Quantity Increment re-adds the quantity buttons depreciated in WooCommerce 2.3
12
+
13
+ == Description ==
14
+
15
+ In WooCommerce 2.3, the quantity increment buttons have been depreciated, as most browsers now support `<input type="number" />`.
16
+
17
+ However, you may want to keep them. Simply install and activate this plugin to do so.
18
+
19
+ It optionally includes [Number Polyfill](https://github.com/jonstipe/number-polyfill), which is a polyfill for implementing the HTML5 `<input type="number">` element in browsers that do not currently support it.
20
+
21
+ To include it, add something like this to your `functions.php`:
22
+
23
+ `
24
+ add_action( 'wp_enqueue_scripts', 'wcqi_enqueue_polyfill' );
25
+ function wcqi_enqueue_polyfill() {
26
+ wp_enqueue_script( 'wcqi-number-polyfill' );
27
+ }
28
+ `
29
+
30
+ == Installation ==
31
+
32
+ 1. Upload `woocommerce-quantity-increment` to the `/wp-content/plugins/` directory or search for 'WooCommerce Quantity Increment' from **Plugins > Add New**.
33
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
34
+
35
+ == Frequently Asked Questions ==
36
+
37
+ = I don’t want to use the plugin styles as it looks bad with my theme =
38
+
39
+ You can add the following to your `functions.php` file:
40
+
41
+ `
42
+ add_action( 'wp_enqueue_scripts', 'wcs_dequeue_quantity' );
43
+ function wcs_dequeue_quantity() {
44
+ wp_dequeue_style( 'wcqi-css' );
45
+ }
46
+ `
47
+
48
+ This will dequeue the plugin’s stylesheet.
49
+
50
+ == Screenshots ==
51
+
52
+ 1. The Quantity Increment buttons
53
+
54
+ == Changelog ==
55
+
56
+ = 1.0 =
57
+ * Initial Release
woocommerce-quantity-increment.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: WooCommerce Quantity Increment
4
+ * Plugin URI: https://www.woothemes.com/
5
+ * Description: Adds Quantity Increment buttons that were depreciated as of WooCommerce 2.3
6
+ * Version: 1.0.0
7
+ * Author: WooThemes, Bryce Adams
8
+ * Author URI: http://woothemes.com/
9
+ * Text Domain: woocommerce-quantity-increment
10
+ * Domain Path: /languages
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ if ( ! class_exists( 'WooCommerce_Quantity_Increment' ) ) :
18
+
19
+ /**
20
+ * WooCommerce_Quantity_Increment main class.
21
+ */
22
+ class WooCommerce_Quantity_Increment {
23
+
24
+ /**
25
+ * Plugin version.
26
+ *
27
+ * @var string
28
+ */
29
+ const VERSION = '1.0.0';
30
+
31
+ /**
32
+ * Instance of this class.
33
+ *
34
+ * @var object
35
+ */
36
+ protected static $instance = null;
37
+
38
+ /**
39
+ * Initialize the plugin.
40
+ */
41
+ private function __construct() {
42
+
43
+
44
+ // Load plugin text domain
45
+ add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
46
+
47
+ // Checks with WooCommerce is installed.
48
+ if ( self::is_wc_version_gte_2_3() ) {
49
+
50
+ $this->includes();
51
+
52
+ } else {
53
+ add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) );
54
+ }
55
+
56
+ }
57
+
58
+ /**
59
+ * Return an instance of this class.
60
+ *
61
+ * @return object A single instance of this class.
62
+ */
63
+ public static function get_instance() {
64
+ // If the single instance hasn't been set, set it now.
65
+ if ( null == self::$instance ) {
66
+ self::$instance = new self;
67
+ }
68
+
69
+ return self::$instance;
70
+ }
71
+
72
+ /**
73
+ * Load the plugin text domain for translation.
74
+ *
75
+ * @return void
76
+ */
77
+ public function load_plugin_textdomain() {
78
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-quantity-increment' );
79
+
80
+ load_textdomain( 'woocommerce-quantity-increment', trailingslashit( WP_LANG_DIR ) . 'woocommerce-quantity-increment/woocommerce-quantity-increment-' . $locale . '.mo' );
81
+ load_plugin_textdomain( 'woocommerce-quantity-increment', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
82
+ }
83
+
84
+ /**
85
+ * Helper method to get the version of the currently installed WooCommerce
86
+ *
87
+ * @since 1.0.0
88
+ * @return string woocommerce version number or null
89
+ */
90
+ private static function get_wc_version() {
91
+ return defined( 'WC_VERSION' ) && WC_VERSION ? WC_VERSION : null;
92
+ }
93
+
94
+ /**
95
+ * Returns true if the installed version of WooCommerce is 2.3 or greater
96
+ *
97
+ * @since 1.0.0
98
+ * @return boolean true if the installed version of WooCommerce is 2.3 or greater
99
+ */
100
+ public static function is_wc_version_gte_2_3() {
101
+ return self::get_wc_version() && version_compare( self::get_wc_version(), '2.3', '>=' );
102
+ }
103
+
104
+ /**
105
+ * Includes.
106
+ *
107
+ * @return void
108
+ */
109
+ public function includes() {
110
+ require_once 'includes/class-wc-quantity-increment.php';
111
+ }
112
+
113
+ /**
114
+ * WooCommerce fallback notice.
115
+ *
116
+ * @return string
117
+ */
118
+ public function woocommerce_missing_notice() {
119
+ echo '<div class="error"><p>' . sprintf( __( 'WooCommerce Quantity Increment requires the %s 2.3 or higher to work!', 'woocommerce-quantity-increment' ), '<a href="http://www.woothemes.com/woocommerce/" target="_blank">' . __( 'WooCommerce', 'woocommerce-quantity-increment' ) . '</a>' ) . '</p></div>';
120
+ }
121
+
122
+ }
123
+
124
+ add_action( 'plugins_loaded', array( 'WooCommerce_Quantity_Increment', 'get_instance' ), 0 );
125
+
126
+ endif;