2

I have a feature in my cart where the customer can pick to add last minute deals to their shopping carts and for products which are grouped products a pop up box appears showing the different options for them to select.

My only problem is that once they select their options and click add to cart the product gets added but the page doesn't refresh so they wont be able to see a product has been added to their cart until they refresh the page.

So my question is how to i make thepage refresh when the Add to cart button is pushed.

The code that creates the button is this:

                <div class="add-to-box">
                    <?php if($_product->isSaleable()): ?>
                        <?php echo $this->getChildHtml('addtocart') ?>
                    <?php endif; ?>
                </div>

I tried just adding this code instead as this is how i have added buttons before:

<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($product)?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></button></p>

But when i do that nothing shows up.

this is the code in the addtocart.phtml (creates the button)

<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
    <span class="ajax_loading" id='ajax_loader'><img src='<?php echo $this->getSkinUrl('images/ajax-loader.gif')?>'/></span>
    <button type="button" title="<?php echo $buttonTitle ?>" 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; ?>

If you can help thank you, if you need more information just let me know.

1

I found out i had to add this to my script at the bottom of the page

jQuery.ajax({
                                    type:"GET",
                                    url:location,
                                    success:function(data){
                                         parent.window.location.href = "/checkout/cart/";
                                    }
                                 });
0

If you have a boolean flag of some kind you can add to the additional items, you can use something like this:

Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));

With the observer: controller_action_layout_load_before

if ($observer->getEvent()->getAction()->getFullActionName() == 'checkout_cart_index')
  • We don't have a boolean flag that i can see or know about, i have added more code of the template file that actually creates the button if that is any help – Adam Allen Dec 10 '14 at 16:19

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.