Created
October 15, 2018 01:29
-
-
Save albertobraschi/d9ecc7b4f24e6e1481a2a847e47fc232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $_configHelper = Mage::helper('searchautocomplete/config'); | |
| $_product = $this->getItem(); | |
| ?> | |
| <!-- li data-url="<?php echo $_product->getProductUrl() ?>" --> | |
| <li> | |
| <?php if ($_configHelper->isShowImage()): ?> | |
| <div class="searchautocomlete-image"> | |
| <img src="<?php echo $this->helper('mstcore/image')->init($_product, 'thumbnail', 'catalog/product')->resize($_configHelper->getImageWidth(), $_configHelper->getImageHeight()) ?>" width="<?php echo $_configHelper->getImageWidth() ?>px" height="<?php echo $_configHelper->getImageHeight() ?>px"/> | |
| </div> | |
| <?php endif ?> | |
| <a class="name highlight" href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a> | |
| <?php if ($_configHelper->isShowRating()): ?> | |
| <?php $_reviewSummary = $_configHelper->getReviewSummary($_product->getId()); ?> | |
| <?php if ($_reviewSummary->getReviewsCount() > 0) : ?> | |
| <div class="ratings"> | |
| <div class="rating-box"> | |
| <div class="rating" style="width:<?php echo $_reviewSummary->getRatingSummary() ?>%"></div> | |
| </div> | |
| <span class="reviews"><?php echo $_reviewSummary->getReviewsCount() ?> Review(s)</span> | |
| </div> | |
| <?php endif ?> | |
| <?php endif ?> | |
| <?php if ($_configHelper->isShowShortDescription()): ?> | |
| <div class="highlight"> | |
| <?php echo Mage::helper('core/string')->truncate(strip_tags($this->getProductShortDescription($_product)), $_configHelper->getShortDescriptionLen()) ?> | |
| </div> | |
| <?php endif ?> | |
| <div class="add-cart"> | |
| <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product);?>" method="post"> | |
| <input type="hidden" name="form_key" | |
| value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>"/> | |
| <input type='button' value='-' class='qtyminus' field='<?php echo $_product->getId(); ?>' /> | |
| <input type="text" name="qty" id="<?php echo $_product->getId(); ?>" value="1"> | |
| <input type='button' value='+' class='qtyplus' field='<?php echo $_product->getId(); ?>' /> | |
| <button type="submit" class="button add-to-cart"><?php echo $this->__('Add to Cart'); ?></button> | |
| </form> | |
| </div> | |
| <?php if ($_configHelper->isShowPrice()): ?> | |
| <?php echo $this->getPriceHtml($_product, false) ?> | |
| <div class="clearfix"></div> | |
| <?php endif ?> | |
| </li> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($) { | |
| // This button will increment the value | |
| $('.qtyplus').click(function(e){ | |
| // Stop acting like a button | |
| e.preventDefault(); | |
| // Get the field name | |
| fieldName = $(this).attr('field'); | |
| // Get its current value | |
| var currentVal = parseInt($('input[id='+fieldName+']').val()); | |
| console.log(fieldName); | |
| // If is not undefined | |
| if (!isNaN(currentVal)) { | |
| // Increment | |
| $('input[id='+fieldName+']').val(currentVal + 1); | |
| } else { | |
| // Otherwise put a 0 there | |
| $('input[id='+fieldName+']').val(0); | |
| } | |
| }); | |
| // This button will decrement the value till 0 | |
| $(".qtyminus").click(function(e) { | |
| // Stop acting like a button | |
| e.preventDefault(); | |
| // Get the field name | |
| fieldName = $(this).attr('field'); | |
| // Get its current value | |
| var currentVal = parseInt($('input[id='+fieldName+']').val()); | |
| // If it isn't undefined or its greater than 0 | |
| if (!isNaN(currentVal) && currentVal > 0) { | |
| // Decrement one | |
| $('input[id='+fieldName+']').val(currentVal - 1); | |
| } else { | |
| // Otherwise put a 0 there | |
| $('input[id='+fieldName+']').val(0); | |
| } | |
| }); | |
| $(document).mouseup(function (e){ | |
| var container = $("#search_autocomplete"); | |
| if (!container.is(e.target) && container.has(e.target).length === 0){ | |
| container.fadeOut(); | |
| } | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment