Back to PhocacartImage class

Method getImageChangedBySelectedAttribute

public static
getImageChangedBySelectedAttribute
(mixed $attributes, mixed $imageSize)

Method getImageChangedBySelectedAttribute - Source code

/*
 * Attribute was selected by customer and product added to cart (displayed in checkout)
 * Displayed in checkout or cart view when the page is loaded, the selected attribute by customer is displayed
 */
public static function getImageChangedBySelectedAttribute($attributes, $imageSize)
{
    $paramsC = PhocacartUtils::getComponentParameters();
    $display_attribute_image_checkout = $paramsC->get('display_attribute_image_checkout', 1);
    if ($display_attribute_image_checkout == 0) {
        return '';
    }
    $image = '';
    if (!empty($attributes)) {
        foreach ($attributes as $k => $v) {
            if (!empty($v)) {
                foreach ($v as $k2 => $v2) {
                    switch ($imageSize) {
                        case 'small':
                            if (isset($v2['oimagesmall']) && $v2['oimagesmall'] != '') {
                                $image = $v2['oimagesmall'];
                                break 2;
                            }
                            break;
                        case 'medium':
                        case 'large':
                        default:
                            if (isset($v2['oimage']) && $v2['oimage'] != '') {
                                $image = $v2['oimage'];
                                break 3;
                            }
                            break;
                    }
                }
            }
        }
    }
    return $image;
}