HWR
HWR

Reputation: 31

Magento tech add to shopping cart not working ie 8?

the Magento product detail page has add to wishlist and add to cart buttons which do nothing in ie 8, but works on other browsers. The part of the code in the one button is

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

The script function it supposed to be connected with is:

<script type="text/javascript">
    <?php if($this->getMessagesBlock()->getGroupedHtml()): ?>
        document.observe("dom:loaded", function(){
            var submitButton = $$('.btn-cart')[0];
            productAddToCartForm.submit(submitButton);
         });
    <?php endif; ?>
</script>

Any help would be appreciated.

When I ran the debug, it gave me this error: SCRIPT5007: Unable to set property 'href' of undefined or null reference

It pointed to code somewhere around

    <?php if (Mage::getStoreConfig('Moii_Pinterest_Config/configuration/Moii_Pinterest_Price') == 1) { ?>
            var pinit_desc = desc + ' - ' + window['pinit_price_'+params.colour];
        <?php } ?>
        var pinit_href = $$('.product-share')[0].firstElementChild.href;
?><

Upvotes: 1

Views: 577

Answers (1)

ndlinh
ndlinh

Reputation: 1365

Due to the solution in this question firstElementChild doesn't work in Internet Explorer 7...what are my options?. Your should replace:

var pinit_href = $$('.product-share')[0].firstElementChild.href;

With

var pShare = $$('.product-share')[0];
var pinit_href = (pShare.firstElementChild || pShare.children[0] || {}).href;

Hope this help.

Upvotes: 1

Related Questions