Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kamalinfo/2a99bc5606e7f5a29133d2bea5ea65af to your computer and use it in GitHub Desktop.
Save kamalinfo/2a99bc5606e7f5a29133d2bea5ea65af to your computer and use it in GitHub Desktop.
<?php
//templates\global\quantity-input.php
//remove qty class from input field
//add the markup below after input field
<div class="qty">
<a class="plus" href="javascript:void(0);">
<i class="fa fa-plus"></i>
</a>
<a class="minus" href="javascript:void(0);">
<i class="fa fa-minus"></i>
</a>
</div>
// css for the markup (circle style | plus - input - minus)
.woocommerce .quantity {
position: relative;
border: 1px solid #ddd;
border-radius: 50px;
padding: 0 40px;
overflow: hidden;
width: 110px;
}
.woocommerce .quantity input[type=number]::-webkit-inner-spin-button,
.woocommerce .quantity input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.woocommerce .quantity input {
height: 40px;
width: 30px;
border: none;
text-align: center;
padding: 0;
}
.woocommerce .quantity .qty {
height: 0px;
}
.woocommerce .quantity .qty a {
position: absolute;
top: 0;
height: 40px;
padding: 0;
margin: 0;
text-align: center;
width: 40px;
}
.woocommerce .quantity .qty a i {
font-size: 14px;
line-height: 40px;
display: block;
}
.woocommerce .quantity .qty a.plus {
right: 0;
}
.woocommerce .quantity .qty a.minus {
left: 0;
}
// css for the makrup (squre style | input - plus|minus)
.woocommerce .quantity {
position: relative;
border: 1px solid #ddd;
padding: 0 40px;
overflow: hidden;
width: 80px;
}
.woocommerce .quantity input[type=number]::-webkit-inner-spin-button,
.woocommerce .quantity input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.woocommerce .quantity input {
height: 40px;
width: 60px;
border: none;
text-align: center;
padding: 0;
margin-left: -40px !important;
}
.woocommerce .quantity .qty {
height: 0px;
}
.woocommerce .quantity .qty a {
position: absolute;
top: 0;
height: 20px;
padding: 0;
margin: 0;
text-align: center;
width: 30px;
line-height: 20px;
}
.woocommerce .quantity .qty a i {
font-size: 14px;
line-height: 20px;
display: block;
}
.woocommerce .quantity .qty a.plus {
right: 0;
top: 2px;
}
.woocommerce .quantity .qty a.minus {right: 0;top: auto;bottom: 0px;}
// js for quantity increase / decrease
$( 'body' ).on( 'click', '.quantity .plus', function( e ) {
var $input = $( this ).parent().parent().find( 'input' );
$input.val( parseInt( $input.val() ) + 1 );
$input.trigger( 'change' );
});
$( 'body' ).on( 'click', '.quantity .minus', function( e ) {
var $input = $( this ).parent().parent().find( 'input' );
var value = parseInt( $input.val() ) - 1;
if ( value < 0 ) value = 0;
$input.val( value );
$input.trigger( 'change' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment