View Single Post
  #4  
Old 06-02-2014, 05:15 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: image from products in mini cart

Hi!

This is the example of test script that will be helpful for you. It will work only when there are some products in your cart.

PHP Code:
<?php

require_once 'top.inc.php';

$itemCount 0;
$cart = \XLite\Controller\Customer\Cart::getInstance()->getCart();

foreach (
$cart->getItems() as $item) {
    if (
$item->getProduct()) {
        foreach (
$item->getProduct()->getImages() as $image) {
            echo 
$image->getFrontURL() . '<br />';
        }

        
$itemCount += 1;
    }
}

if (
$itemCount == 0) {
    echo 
'No products in the cart';
}

You should put this code into any script (test.php for example) in the root folder of your X-Cart 5 installation and it will work. Hopefully, it will give you an idea of how to get info about product images.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote