Jump to content

how to integrate a 7 days trial?


Recommended Posts

Just now, jsgastoniriartecabre said:

I've done a 7 days trial (as a product), but need now to add to my-account page an html iframe or a button with a link to another page. is that possible?

if you want add content to 'my-account' page there are more than a way to do this .

but i think the best way is to use a Hook called

displayCustomerAccount

register the hook in your module

$this->registerHook('displayCustomerAccount')

and re-install it.

then create a function like this

public function hookDisplayCustomerAccount()

inside this function you can fetch any content to be displayed in the my-account page.

, this is how to return a content

return $this->context->smarty->fetch(
	 $this->getLocalPath() . 'views/templates/hook/your_file_name.tpl'
);

then create the .tpl file under

modules/yourmodule/views/templates/hook

inside this file you can put HTML,Buttons,Iframes .. or any think you want.

and it will be displayed in 'my-account' page.

I hope this helps you.

 

  • Like 1
Link to comment
Share on other sites

29 minutes ago, ZiedDams said:

if you want add content to 'my-account' page there are more than a way to do this .

but i think the best way is to use a Hook called

displayCustomerAccount

register the hook in your module

$this->registerHook('displayCustomerAccount')

and re-install it.

then create a function like this

public function hookDisplayCustomerAccount()

inside this function you can fetch any content to be displayed in the my-account page.

, this is how to return a content

return $this->context->smarty->fetch(
	 $this->getLocalPath() . 'views/templates/hook/your_file_name.tpl'
);

then create the .tpl file under

modules/yourmodule/views/templates/hook

inside this file you can put HTML,Buttons,Iframes .. or any think you want.

and it will be displayed in 'my-account' page.

I hope this helps you.

 

awesom! ... my first attempt to php will be difficult.

 

Edited by jsgastoniriartecabre (see edit history)
Link to comment
Share on other sites

it's fine ,

i got you.

Hooks are not components

hooks in Prestashop are like places to insert you custom logic or content.

you can read more about them here

https://devdocs.prestashop-project.org/1.7/modules/concepts/hooks/

first you have to create a custom module

i use this site generate a fast one without selecting any hooks there.

https://validator.prestashop.com/generator

it will give you a zip file  and that is a Prestashop Module .

all you code and content will be there.

why ?

because if you directly change in the Prestashop source code your work will be eased and lost if you upgrade to the next ps (prestashop) version.

so we use module to add our custom logic,features and new functionalities, in prestashop .

-> go to prestashop backoffice in module section -> module catalog page

-> upload the module and install it.

-> now you must have an access to your ps project folder

-> go to modules directory and find your module diractory that we already install it.

-> go to the main module php file (your_module_name.php) and open file (Code editor preferred)

-> find install function

public function install()

you will find some hook are registered there,

add you hook ('displayCustomerAccount')

$this->registerHook('displayCustomerAccount')

and reinstall your module from back-office.

if you module reinstalled successfully your good to continue .

please feel free to ask any think .

 

  • Like 1
Link to comment
Share on other sites

0k, thank's ... and now, how can I make the products, show this I've done, only when the subscription is active?

 

for example, I have a product trial for 7 days, the iframe or button, should only be active while the trial is active.

 

like a while subscription is activated ; give access to the button I've created.

how can I do this?

Edited by jsgastoniriartecabre (see edit history)
Link to comment
Share on other sites

3 hours ago, jsgastoniriartecabre said:

0k, thank's ... and now, how can I make the products, show this I've done, only when the subscription is active?

 

for example, I have a product trial for 7 days, the iframe or button, should only be active while the trial is active.

 

like a while subscription is activated ; give access to the button I've created.

how can I do this?

  

  

i did not understand clearly but i think this might help you .

So previously we created the Hook function 

public function hookDisplayCustomerAccount()

and inside we just return a content inside  a template file  (.tpl) like this

return $this->context->smarty->fetch(
	 $this->getLocalPath() . 'views/templates/hook/your_file_name.tpl'
);

now we gonna add variable to the template file so we can do  IF  statement

before the return..

// i don't know how you did your subsription logic
// so im assuming that you will create a function to get is subsription value ( true or false )

$isActive = $this->isSubscriptionAvailable();

// now we assign the varible to the template
$this->context->smarty->assign(['is_active' => $isActive]);

//and now we return the template 
return $this->context->smarty->fetch(
	 $this->getLocalPath() . 'views/templates/hook/your_file_name.tpl'
);

and now in your template file this is how you do it

{if $is_active}

  {*
  YOUR Iframe or Button
  *}


{else}

  {*
  for ex: DISPLAY THAT is not available 
  *}

{/if}

 

  • Like 1
Link to comment
Share on other sites

6 hours ago, ZiedDams said:

  

  

i did not understand clearly but i think this might help you .

So previously we created the Hook function 

public function hookDisplayCustomerAccount()

and inside we just return a content inside  a template file  (.tpl) like this

return $this->context->smarty->fetch(
	 $this->getLocalPath() . 'views/templates/hook/your_file_name.tpl'
);

now we gonna add variable to the template file so we can do  IF  statement

before the return..

// i don't know how you did your subsription logic
// so im assuming that you will create a function to get is subsription value ( true or false )

$isActive = $this->isSubscriptionAvailable();

// now we assign the varible to the template
$this->context->smarty->assign(['is_active' => $isActive]);

//and now we return the template 
return $this->context->smarty->fetch(
	 $this->getLocalPath() . 'views/templates/hook/your_file_name.tpl'
);

and now in your template file this is how you do it

{if $is_active}

  {*
  YOUR Iframe or Button
  *}


{else}

  {*
  for ex: DISPLAY THAT is not available 
  *}

{/if}

 

in the iframe (for example), do I have to inster a complite html page? (head, body ....)

Link to comment
Share on other sites

Just now, ZiedDams said:

what you mean by

"

one of them virtual product (for the password for the iframe) ->and one of them gave 7 days

"

where you add the 7 days ?

?

and also what you mean by a virtual product for the iframe password ?

I didn't get your point at all.

Link to comment
Share on other sites

On 10/24/2022 at 10:32 AM, ZiedDams said:

and also what you mean by a virtual product for the iframe password ?

I didn't get your point at all.

I just tried to explain how I made my virtual products, it doesn't matter. I need to show a iframe or a web page when accesing to : my-account. And don't know how to create the function (don't whant to try and break the database).

 

Also, sorry ... I would love to pay for your skills ... but just dont have $ and need help to finish this job

Edited by jsgastoniriartecabre (see edit history)
Link to comment
Share on other sites

On 10/24/2022 at 10:32 AM, ZiedDams said:

and also what you mean by a virtual product for the iframe password ?

I didn't get your point at all.

hi, I think I havent explained correctly ....

 

dont know much more about functions than this:

 

public function __subscription()
{

}   ***please help with the subscription.

 

This is what I did to add subscriptions to the products

image.thumb.png.db97ff321a5633b9b336a9f6359d774b.png

 

 

image.thumb.png.226a80c94be13ad347f572e205d14652.png

 

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...