2

How do i refresh a page when someone clicks the add to cart button my current add to cart code is

<?php $_product = $this->getProduct(); ?>

<?php $buttonTitle = $this->__('Add to Cart');  ?>

<?php if($_product->isSaleable()): ?>

    <div class="add-to-cart">

        <?php if(!$_product->isGrouped()): ?>
<label class="qty_label" for="qty"><?php echo $this->__('Quantity') ?>:</label>

<div class="qty_pan">

        <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />

</div>

        <?php endif; ?>

        <button type="button" title="<?php echo $buttonTitle ?>" <location.reload();> <class="button btn-cart" onclick="productAddToCartForm.submit(this)" > <span><span><?php echo $buttonTitle ?></span></span></button>

        <?php echo $this->getChildHtml('', true, true) ?>

    </div>

<?php endif; ?>

<script type="text/javascript">

jQuery(function() {

    jQuery("div.add-to-cart .qty_pan").append('<div class="inc add">&#8250;</div><div class="dec add">&#8249;</div>');

jQuery(".add").click(function() {

        var jQueryadd = jQuery(this);

        var oldValue = jQueryadd.parent().find("input").val();

        var newVal = 0;

        if (jQueryadd.text() == "›") {

           newVal = parseFloat(oldValue) + 1;

          // AJAX save would go here

        } else {

          // Don't allow decrementing below zero

          if (oldValue > 1) {

              newVal = parseFloat(oldValue) - 1;

              // AJAX save would go here

          }

          if(oldValue == 1){

              newVal = parseFloat(oldValue);

              }

        }

        jQueryadd.parent().find("input").val(newVal);

    });

});

</script>
1

Is it possible that all you want is something that can be done via system configuration?

System --> Configuration --> Sales --> Checkout --> After Adding a Product Redirect to Shopping Cart = no

0

You can try creating an observer on event checkout_cart_add_product_complete and redirect to same product page which is recently added to cart.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.