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>
Harish Singh
  • 103
  • 1
  • 1
  • 6
Michael1278
  • 21
  • 1
  • 3

2 Answers2

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

Celldweller
  • 967
  • 3
  • 15
  • 26
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.

Anshu Mishra
  • 8,950
  • 7
  • 40
  • 88
  • Thanks for the reply, How would i do this sorry ? – Michael1278 Oct 27 '13 at 12:01
  • You can follow these links to know how to use events and observers in magento - http://www.pierrefay.com/event-observers-magento-tutorial-howto-105 , http://www.solvingmagento.com/events-and-observers-a-magento-tutorial/ , https://inchoo.net/ecommerce/magento/magento-event-driven-programming-tips-tricks/ – Anshu Mishra Oct 28 '13 at 15:57