Jump to content

Cant change module position on product page


ComGrafPL

Recommended Posts

Can't change module position on product page.

I have a module "Ask a question" one. For weird reasons, i can't place it in desired position. I have try with hooks like i normal do. But it seems i can only move it above or below social media buttons.

Any clue how to move it below add to cart place?

PHP 7.4 / PS 1.7.8.3

 

Thanks

Przechwytywanie zawartości sieci Web_23-2-2022_84838_testowysklep.republikarowerowa.pl.jpeg

Edited by ComGrafPL (see edit history)
  • Like 1
Link to comment
Share on other sites

And module:
 

public function hookDisplayProductActions(array $params)

{

    if('product' == $this->context->controller->php_self){

        $idProduct = Tools::getValue('id_product');

        $myParams = 'Hello Word !';

        $this->smarty->assign('myParams', $myParams);  

        return $this->display(__FILE__, 'views/templates/front/my_module.tpl');

    }    

}

 

And my_module.tpl:

{block name='my_module'}
<hr>
<div class="my_module_class">
    <div class="clearfix" style="display:flex;">
        <div class="my-btn">{$myParams}</div>   
    </div>
</div>
{/block}

 

Edited by 4you.software (see edit history)
Link to comment
Share on other sites

Another option with inserting your own hook.

It's terribly simple. Just understand it.
Open up ./themes/classic/templates/catalog/product.tpl

1. find

{block name='product_add_to_cart'}
	{include file='catalog/_partials/product-add-to-cart.tpl'}
{/block}

 

2. add after your block or hook

{block name='my_module'}
	{hook h='myCustomDisplayButton' id_product=$product.id}
{/block}

obrazek.png.949a37a7504d25562f6127568a7143a6.png

 

3. edit your module and add your hook

a) edit install function

public function install() 
{ 
	$this->registerHook('myCustomDisplayButton');
....
....
....

b) edit uninstall function

public function uninstall() 
{ 
	$this->unregisterHook('myCustomDisplayButton');
....
....
....

c) add your hook function

public function hookMyCustomDisplayButton($params)
{
    $idProduct = $params;
	return '<hr><div style="display:block; width:100%;"><div class="btn  btn-primary" style="my-button">Hello Word !</div></div>';
}

 

4. register your hook

 - admin => design => positions

obrazek.png.83d3126a9b868e9e8541e76882e920b0.png

and click to Transplant a module button

obrazek.png.d0d9aa21bb62c97885562095fa36d257.png

 

5. find your module

obrazek.png.8b250e62bab3705ffcc5cf4af4e3a39d.png

 

6. select your new HOOK

 

Result:

obrazek.png.428c2b62c746c3ffe1ab1457ac823cc5.png

Edited by 4you.software (see edit history)
  • Like 1
Link to comment
Share on other sites

2 hours ago, 4you.software said:

Creating your own hook and paste it into TPL template is a job for two minutes 🤪

Last step gets me error: Parse error: syntax error, unexpected '$product' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST)

On line:

$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id);

But i haven't edit this line, so not sure.

  • Like 1
Link to comment
Share on other sites

1 hour ago, ComGrafPL said:

Last step gets me error: Parse error: syntax error, unexpected '$product' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST)

On line:

$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id);

But i haven't edit this line, so not sure.

I asked you if you have a default "classic" template. you said yes.
It's not true. You are using another template.
Do you use warehouse theme?

You need to show us the product.tpl file

 

Edited by 4you.software (see edit history)
  • Thanks 1
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...