Skip to content

Instantly share code, notes, and snippets.

@rickbenetti
Created September 27, 2013 23:10
Show Gist options
  • Select an option

  • Save rickbenetti/6736487 to your computer and use it in GitHub Desktop.

Select an option

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.
<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>
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);
}
});
@andersonmendes
Copy link

Olá meu camarada, desculpe mas sou leigo no assunto.
Como eu coloco esse bloco de código PHP na minha loja?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment