News:

Support the VirtueMart project and become a member

Main Menu

$product['image'] missing in drop down cart.

Started by prokops, November 18, 2016, 08:52:09 AM

Previous topic - Next topic

prokops

Hi!

I used to output product images in drop down cart module of my template with <?php foreach ($data->products as $product){ .... echo $product['image'];?>.

After recent updates, I can't find product images in $data->products . Can anyone shed light on how to find the images now?

Cheers

Jumbo!

Standard VM Cart Module does not load product images. See VirtueMartCart::prepareAjaxData() function in cart helper - components/com_virtuemart/helpers/cart.php

You will first have to hack or customize this function to add images to the products. Then you will also have to customize the JavaScript so that the images can be updated over Ajax. Virtuemart.cartEffect() function in components/com_virtuemart/assets/js/vmprices.js

Ideally, I would suggest you develop your own custom module instead of hacking core codes. You can use Joomla! Ajax Interface to update the module over Ajax in your scripts. Refer - https://docs.joomla.org/Using_Joomla_Ajax_Interface

Alternatively, you can use some 3rd party module.

GJC Web Design

$cart is also available in the module

I use a tmpl. snippet like

<?php foreach ($data->products as $product){
                    foreach (
$cart->products as $cproduct) {
                      if (
$product['product_sku'] == $cproduct->product_sku ) {
$image $cproduct->images[0]->displayMediaThumb (''FALSE);
                      }
                  } 
?>


but isn't ajax so only updates after a page refresh
if u use a dropdown cart etc no one will notice..  ;)
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation