Jump to content

Small PrestaShop module for short game tips on product pages looking for feedback


Recommended Posts

Hi everyone,

I wanted to share a small real-world use case from a project I’m currently working on and get some advice from people who’ve dealt with similar setups.

I run a relatively simple PrestaShop 1.7 store that focuses on digital / game-related content (guides, updates, short explanations). One thing I noticed from analytics and user feedback is that visitors often just want a very short tip or note (1–2 lines) directly on the product page — not a full CMS article and not buried inside the long description.

At first, I tried CMS pages and even experimented with product features, but both felt a bit heavy or awkward for something this small. So I ended up building a very lightweight custom module whose only job is to:

store a short “quick tip” per product

hook into the product page

render a small, clean snippet under the main product info

The goal was to keep it simple, fast, and easy to maintain without overloading the back office.

Below is a simplified version of what I’m currently using. This is not production-perfect code, just the core idea.

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class GameQuickTips extends Module
{
    public function __construct()
    {
        $this->name = 'gamequicktips';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'Dev';
        parent::__construct();

        $this->displayName = $this->l('Game Quick Tips');
        $this->description = $this->l('Displays a short tip on product pages.');
    }

    public function install()
    {
        return parent::install()
            && $this->registerHook('displayProductAdditionalInfo');
    }

    public function hookDisplayProductAdditionalInfo($params)
    {
        if (empty($params['product']['id_product'])) {
            return '';
        }

        // Example: reading a custom product field "game_tip"
        $tip = $params['product']['game_tip'] ?? '';

        if (!$tip) {
            return '';
        }

        $this->context->smarty->assign([
            'game_tip' => $tip,
        ]);

        return $this->display(__FILE__, 'views/templates/hook/tip.tpl');
    }
}
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...