Author Topic: $product['image'] missing in drop down cart.  (Read 1802 times)


  • Jr. Member
  • **
  • Posts: 53
$product['image'] missing in drop down cart.
« on: November 18, 2016, 08:52:09 am »

I used to output product images in drop down cart module of my template with
Code: [Select]
<?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?



  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 873
  • Full-stack Web Developer
  • VirtueMart Version: Always the latest
Re: $product['image'] missing in drop down cart.
« Reply #1 on: November 18, 2016, 09:06:38 am »
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 -

Alternatively, you can use some 3rd party module.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10701
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: $product['image'] missing in drop down cart.
« Reply #2 on: November 18, 2016, 11:32:00 am »
$cart is also available in the module

I use a tmpl. snippet like

Code: [Select]
<?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
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
Contact for any VirtueMart or Joomla development & customisation