Jump to content

Help to create hooks


tonnybarros

Recommended Posts

I need to create hooks to appear on the customer's product area.

I already know it's clientareaproductdetails

 

The problem is the data you need to get the product are the custom field.

The product has 6 custom fields.

 

How do I get them in clientareaproductdetails?

 

When I get this data will also need to create a link in clientareaproductdetails in html used data from custom fields.

 

Can anyone help me in this matter?

Link to comment
Share on other sites

I think there is no need for ActionHook there as product custom fields are already there, you only need to use something as the following to display these custom fields values where you need it to :

 

{foreach item=customfield from=$productcustomfields}
   {$customfield.name}: {$customfield.value}<br>
{/foreach}

Link to comment
Share on other sites

I thank everyone, including those who sent me budgets, but managed to solve.

 

I had to create a module, although I have little knowledge, search in whmcs documentation and researched a lot on Google.

 

But anyway, it is ready, it is now possible with this module.

* Create the product with external API data

* Option to activate the product after payment

* Suspension for non-payment

* Information in real time the product.

 

It is simple but very functional, see how it went:

 

module.png

 

But still I need help, how can I customize the image of the product, different for each product?

This image:

 

modelu2.png

Link to comment
Share on other sites

when you say "different image for each product", do you mean that each separate product requires a different image... or that these products are of different types and you want an image for each different type of product?

 

if they're different types, then you could create a series of images and call them type1.png, type2.png etc (or something that makes sense for these products) and then use the image for that product type.

Link to comment
Share on other sites

Yes, I want a different image for each product example, if I had I would have ready 100 100 images a imaagem for each product.

 

It's possible?

if you can prepare the images in advance, then you could use the product ID (pid) in the image filename, e.g 45.png where 45 is the pid value of the product - product IDs should be unique, so should be ideal for your situation.

Link to comment
Share on other sites

Yes, I want a different image for each product example, if I had I would have ready 100 100 images a imaagem for each product.

 

It's possible?

it might be possible to use your API for the same purpose too, so images will be called dynamically

Link to comment
Share on other sites

you could do it in the clientareaproductdetails template - as it will already have access to the $pid value...

 

<img src="{$pid}.png">

so if $pid equals 45, it will try to display 45.png - though you'd have to remember to add the correct path to the image in the above code.

Link to comment
Share on other sites

Sure, but the images are in url formats, and all different, it is still possible?

i'm unsure what you mean by URL formats - are the images on another server? can you give an example...

 

as I understand it (and working from your screenshots), what you want to do for these products is replace the font-awesome icon that is there currently with a unique image - perhaps you could surround the fa code with an if statement to see if the image exists, if so display it; if not, use the fa icon.

Link to comment
Share on other sites

The image that need to change for each product is this:

http://image.prntscr.com/image/dc28ee3af9cc4c81898e6f5e30c7fa9b.png

 

 

The format received from api's how:

https://thumb-cc.s3.envato.com/files/102530217/ajax-chat-system-thumb.jpg

 

If you can use condition has image or not, it would be perfect.

 

I already have the string that contains this image of each product.

 

How to use?

Link to comment
Share on other sites

unfortunately, you can't use file_exists on external links, only on local files - so if you're intending to use external images, you aren't going to be able to check if they exist before displaying them.

 

if all your products are going to use an external image instead of a fa icon, then that makes it simpler, but not ideal... the better solution would be if these images were local.

 

anyway, in clientareaproductdetails.tpl, this is the code that displays the appropriate font-awesome icon...

 

                                <span class="fa-stack fa-lg">
                                   <i class="fa fa-circle fa-stack-2x"></i>
                                   <i class="fa fa-{if $type eq "hostingaccount" || $type == "reselleraccount"}hdd-o{elseif $type eq "server"}database{else}archive{/if} fa-stack-1x fa-inverse"></i>
                               </span>

if your images were local, you would simply do this...

 

                            {assign "image_exists" "..{$BASE_PATH_IMG}/{$pid}.png"}
                           {if file_exists($image_exists)}
                               <img src="{$image_exists}">
                           {else}
                               <span class="fa-stack fa-lg">
                                   <i class="fa fa-circle fa-stack-2x"></i>
                                   <i class="fa fa-{if $type eq "hostingaccount" || $type == "reselleraccount"}hdd-o{elseif $type eq "server"}database{else}archive{/if} fa-stack-1x fa-inverse"></i>
                               </span>
                           {/if}

but if you're going to use external images, then because you can't check if the image exists, you'll need to create an {if} statement based on an existing Smarty variable unique to these products - e.g $product if all these products have the same product name...

 

                            {assign "image_exists" "..{$BASE_PATH_IMG}/{$pid}.png"}
                           {if $product eq "name"}
                               <img src="{$image_exists}">
                           {else}
                               <span class="fa-stack fa-lg">
                                   <i class="fa fa-circle fa-stack-2x"></i>
                                    <i class="fa fa-{if $type eq "hostingaccount" || $type ==  "reselleraccount"}hdd-o{elseif $type eq  "server"}database{else}archive{/if} fa-stack-1x  fa-inverse"></i>
                               </span>
                           {/if}

Link to comment
Share on other sites

I will make small adjustment in Brian code

 

                           {if $apithumburl}
                               <img src="{$apithumburl}" alt="" width="80" height="80">
                           {else}
                               <span class="fa-stack fa-lg">
                                   <i class="fa fa-circle fa-stack-2x"></i>
                                    <i class="fa fa-{if $type eq "hostingaccount" || $type ==  "reselleraccount"}hdd-o{elseif $type eq  "server"}database{else}archive{/if} fa-stack-1x  fa-inverse"></i>
                               </span>
                           {/if}  

where $apithumburl is your product thumbnail URL, if it has value this code will display it, when empty WHMCS default icon will be displayed.

 

it's easy to pass value to this variable from your addon module.

Link to comment
Share on other sites

My file is in module/servers/code

And in php, how do I generate a string {} to put on clientareaproductdetails.tpl?

 

It works well using the code in the server, for example:

echo $params['configoption1'];

echo "<br>";

echo $params['configoption2'];

echo "<br>";

echo $params['configoption3'];

echo "<br>";

echo $params['configoption4'];

echo "<br>";

echo $params['configoption5

'];

But to put in the clientareaproductdetails.tpl does not work {$params['configoption4']}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated