Magento – Show phtml File Only When Button is Clicked

cross-sellsphtmlproductquickview

I want to create a quickview option with my crosssells. When I click on the quickview button, I want a .phtml file to appear (custom/quickview.phtml), and display with product information such as name, id, image etc..

This is the situation:

  • I have 3 crosssell products on the cart page
  • Inside the foreach loop that generates the products, I want a button that calls the quickview.phtml file
  • I want to pass php variables, such as product ID, product name etc.

How do I do this? I cant find out how to do it.

Best Answer

I assume that you want the quickview.phtml to appear in a lightbox without leaving the current page.

To do this, you will need to change the button action to an ajax call with a custom controller action to return the new dynamic HTML.

There are a number of existing extensions out there, and I highly recommend that you use one of them instead of creating your own solution. To do this right, it could easily take dozens of hours to implement (especially if you have any configurable or bundled products).

Take a look here:

https://www.magentocommerce.com/magento-connect/catalogsearch/result/?q=product+quick+view&pl=0

I have used both the Amasty and Belvg ones in the past for various projects.

Related Topic