0

I'm using Business King Product Out of Stock Subscription (Link here)

to develop product out of stock alert subscription. Its working fine in product details page but it s not working on product listing page(list.phtml). Actually I'm keeping a from for every product who is out of stock.And in the browser console its showing Uncaught TypeError: undefined is not a function error. Here is my code:

<ul>
    <?php $i=0; foreach ($_productCollection as $_product): ?>          
                <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?> home_prod_list_list">
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
                        <?php $_imgSize = 210; ?>
                        <img id="product-collection-image-<?php echo $_product->getId(); ?>"
                             src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image', $_product->getFile())->keepFrame(false)->resize(250,310); ?>"
                             alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
                    </a>
                    <script type="text/javascript">
        var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
    </script>
                    <div class="own_share">
                    <?php $_storeId = Mage::app()->getStore()->getId(); ?>
                        <?php $_isActive = Mage::getStoreConfig('outofstocksubscription/mail/active', $_storeId); ?>
                        <?php if(!$_product->isSaleable() && $_isActive): ?>
                             <?php $_url = $this->getUrl('outofstocksubscription') ?>
                            <button class="own"></button>
                            <button class="share" onclick="ShowSocialMedia(jQuery(this));"></button>
                            <div id="out_of_stk">
                            <form action="<?php echo $_url ?>" name="productAddToCartForm" method="post"  id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
                            <?php echo $this->getBlockHtml('formkey') ?>
                        <input type="text" id="subscription_email" name="subscription_email"  style="width:100px;" class="input-text required-entry validate-email" />                   
                        <button class="subscribe_btn" type="button" onclick="productAddToCartForm.submit(this);"></button>

                        </form>

                        </div>

                        <?php else :?>
                        <?php $_url = $this->getAddToCartUrl($_product); ?>
                        <form action="<?php echo $_url ?>" name="productAddToCartForm1" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?> style="display:inline;vertical-align:top;">
                            <button class="own" onclick="productAddToCartForm1.submit();" ></button>
                            </form>
                            <button class="share" onclick="ShowSocialMedia(jQuery(this));"></button>


                        <?php endif; ?>             

                </li>

                <?php 
                    $rowsCounter++;

                    ?>

            <?php endforeach ?>
            </ul>

            <script type="text/javascript">
        //<![CDATA[
                var productAddToCartForm = new VarienForm('product_addtocart_form');
                productAddToCartForm.submit = function(){
                        if (this.validator.validate()) {
                                this.form.submit();
                        }
                }.bind(productAddToCartForm);
        //]]>
        </script> 
0

Note var productAddToCartForm = new VarienForm('product_addtocart_form'); assumes there is one form at the page, however there are many forms. May be the code contain more logical errors I do not see at the moment, as it assumes we are at the product edit page.

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.