yf_shop__products_last_viewed user module

Fileplugins/shop/modules/shop/yf_shop__products_last_viewed.class.php
Usemodule('shop__products_last_viewed'), URL ?object=shop__products_last_viewed

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 1

None without a leading underscore.

Methods starting with _ hooks and helpers; not routable as page actions

public function _products_last_viewed()
    public function _products_last_viewed()
    {
        $sql_prod_id = 'SELECT * FROM  ' . db('shop_products') . '  ORDER BY last_viewed_date  DESC LIMIT 5';
        $item_prod_id = db()->query_fetch_all($sql_prod_id);
        $items = [];
        foreach ((array) $item_prod_id as $k => $product_info) {
            $thumb_path = $product_info['url'] . '_' . $product_info['id'] . '_1' . module('shop')->THUMB_SUFFIX . '.jpg';
            $URL_PRODUCT_ID = module('shop')->_product_id_url($product_info);
            $items[$product_info['id']] = [
                'name' => _prepare_html($product_info['name']),
                'price' => module('shop')->_format_price(module('shop')->_product_get_price($product_info)),
                'currency' => _prepare_html(module('shop')->CURRENCY),
                'image' => file_exists(module('shop')->products_img_dir . $thumb_path) ? module('shop')->products_img_webdir . $thumb_path : '',
                'link' => ($product_info['external_url']) ? $product_info['external_url'] : process_url('./?object=shop&action=product_details&id=' . $URL_PRODUCT_ID),
                'special' => '',
            ];
        }
        return tpl()->parse('shop/last_viewed', [
            'items' => $items,
        ]);
    }