This Magento extension is designed to enhance the user experience by allowing customers to add products to their cart directly from the category page without having to click through to the product detail page first. This can significantly streamline the shopping process and potentially increase conversion rates.
The key features of this extension include:
- Integration with the Fancybox JavaScript library for creating a “quick view” popup window.
- Support for adding simple, configurable, bundle, or grouped products to the cart from the quick view popup.
- Automatic display of product options (such as size and color) in the popup for configurable products.
Here’s an example of how the extension modifies the category page template:
...
<div class="product-content">
<div id="quickview-<?php echo $_product->getId() ?>">
<button type="button" title="<?php echo $this->__('Quick View') ?>" class="button quickview" onclick="showOptions(<?php echo $_product->getId() ?>)"><span><span><?php echo $this->__('Quick View') ?></span></span></button>
</div>
...
</div>
...
When the “Quick View” button is clicked, a Fancybox popup window is triggered, which displays the product details in a compact format. The extension handles the AJAX request to fetch the quick view content dynamically:
jQuery('.fancybox').fancybox({
hideOnContentClick : true,
width: 582,
autoDimensions: true,
type : 'iframe',
showTitle: false,
scrolling: 'no',
onComplete: function(){ //Resize the iframe to correct size
jQuery('#fancybox-frame').load(function() { // wait for frame to load and then gets it's height
jQuery('#fancybox-content').height(jQuery(this).contents().find('body').height()+30);
jQuery.fancybox.resize();
});
}
});
Within the quick view popup, customers can select their desired options (if applicable) and add the product to the cart using a custom “Add to Cart” button:
<p class="availability in-stock">
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId() ?>')" id="addto<?php echo $_product->getId() ?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<a href='<?php echo $this->getUrl('ajax/index/options',array('product_id'=>$_product->getId()));?>' class='fancybox' id='fancybox<?php echo $_product->getId() ?>' style="display: none;" onClick="hideImage(jQuery('#addto<?php echo $_product->getId() ?>'))" ><?php echo $this->__('Add to Cart') ?></a>
</p>
...
When the “Add to Cart” button is clicked, an AJAX request is sent to add the product to the cart without reloading the page. The extension updates both the mini cart and the header cart area using the retrieved sidebar data:
function setAjaxData(data,iframe){
if(data.status == 'ERROR'){
alert(data.message);
}else{
if(jQuery('.block-cart')){
jQuery('.block-cart').replaceWith(data.sidebar);
}
if(jQuery('.header .block-cart-header')){
jQuery('.header .block-cart-header').replaceWith(data.topcart);
}
jQuery.fancybox.close();
}
}
The extension also includes a custom “Continue shopping” button and a “View cart & checkout” link within the quick view popup, allowing customers to proceed directly to the checkout page if desired.
In conclusion, this Magento extension provides an efficient way for customers to add products to their cart from the category page without having to navigate through multiple pages. By streamlining the shopping process and reducing clicks, it can potentially drive higher conversion rates and improve overall user experience in your Magento store. The extension is compatible with Magento 1.x and Magento 2.x versions.
https://laravelcompany.com offers a wide range of Magento development services and extensions to enhance the functionality and performance of your e-commerce platform. Contact us today to learn more about how we can help you optimize your online store and drive business growth.