Created
September 27, 2013 23:10
-
-
Save rickbenetti/6736487 to your computer and use it in GitHub Desktop.
Bloco para adicionar funcionalidade de incremento e decremento no box de quantidade na tela de produto.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="qty-box"> | |
| <label for="qty"><sup>*</sup> <?php echo $this->__('Qty') ?></label> | |
| <div class="qty-wrapper"> | |
| <input type="text" name="qty" id="qty" maxlength="3" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /> | |
| <div class="actions"> | |
| <a class="btn-increment" href="javascript:void(0);" title="<?php echo $this->__('Increment Value')?>"><?php echo $this->__('Increment Value')?></a> | |
| <a class="btn-decrement" href="javascript:void(0);" title="<?php echo $this->__('Decrement Value')?>"><?php echo $this->__('Decrement Value')?></a> | |
| </div> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(function(){ | |
| $box = jQuery('.add-to-cart .qty'); | |
| resetValue(); | |
| jQuery($box).blur(function(){ | |
| if(!jQuery(this).val() || (jQuery(this).val() <=0) || !jQuery.isNumeric(jQuery(this).val())) { | |
| jQuery(this).val(1); | |
| } | |
| }); | |
| jQuery('.add-to-cart .btn-increment').click(function(){ | |
| $value++; | |
| updateQtyBox(); | |
| }); | |
| jQuery('.add-to-cart .btn-decrement').click(function(){ | |
| if($value >= 2) { | |
| $value--; | |
| } | |
| updateQtyBox(); | |
| }); | |
| function resetValue() | |
| { | |
| $value = Number(jQuery($box).val()); | |
| } | |
| function updateQtyBox() | |
| { | |
| jQuery($box).val($value); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Olá meu camarada, desculpe mas sou leigo no assunto.
Como eu coloco esse bloco de código PHP na minha loja?