Jump to content

Display product on addon page


yggdrasil

Recommended Posts

I want to display a product in the addons page and while I can just add the code there manually this would be true for all customers which would not be desirable.

 

I would like to rather emulate how addons work in that page, I'f my memory serves me right, the addons displayed there are only for addons valid for the products you have active as the user. So if you don't have some package it would not displays addons not available for you.

 

I was wondering if this can be made with conditionals in the template or it would require more complex code like querying the database?

 

In the documentation the only example with conditionals is this:

Displaying Text if Certain Conditions Are Met

{if $gateway.name eq "PayPal"}We accept PayPal{/if}

 

Where can I consult the rest of conditionals available?

 

I would like to show a link for example, only if X product is active for that user. If this can't be made with conditionals then no problem, I will do it another way but I'm curious if something this simple could be achieved with template conditionals instead.

Link to comment
Share on other sites

I think you're going to have to query the database to find out if the user has product X active.

 

if you add {debug} to your addons template, you will get a popup window showing you the available Smarty variables and arrays that can be used in conditional statements as per your Paypal example... but I think in this instance, you won't see what you need.

 

let me add two obvious suggestions that you have probably considered and ruled out, butworth mentioning in case you haven't!

 

1. can you make this product into a product addon instead? if so, then you could link it to Product X and avoid editing the templates.

 

2. you could create a product addon, linked to product X, but modify the addons template to change the "Order Now" button for that addon to a link to your actual product - once clicked, the user would then be redirected to the product.

 

something along the lines of...

 

{if $addon.id eq 5}*show link to product*{else}*show order now button*{/if}

this second option would remove the need to query the database to see if they had product X in their account.

 

there are a number of other ways to do this, but if you're familiar with querying the database, and once you have confirmed they have Product X, you could just add a link with a conditional statement in the template.

Link to comment
Share on other sites

Hi thanks for the reply. :)

 

1. That is not possible because the product in my case requires a domain name in the order process. I don't think you can do that with addons, I need the product to check for a proper domain in the setup, WHMCS does the proper checks in the ordering process. This is why I decided to make it a product instead of an addon.

 

2. Yes, that is exactly what I had in my mind at first. Create an addon, then just modify the addon link/button manually to actually link to the product but how?

 

The addons template pulls the addons dynamically. Where could I find the code that is for a specific addon alone?

 

Right now, in the addon page I just copied an existing addon and modified the HTML manually, it looks exactly like all other addons, no difference, but since I have put the code there manually, of course it displays for all customers, regardless of products.

 

You mean your code would just change the order button (only for that addon alone) in the page or I should manually change the HTML code for that addon? If so, I would like to know where they are, since I think they are generated on the fly there from the database.

Link to comment
Share on other sites

2. Yes, that is exactly what I had in my mind at first. Create an addon, then just modify the addon link/button manually to actually link to the product but how?

 

The addons template pulls the addons dynamically. Where could I find the code that is for a specific addon alone?

you modify the code I gave you in the second post - as an example, if the addon has an ID value of 5 (i'll explain that in a minute), then that code will show a link to your secondary product, for all other addons, it shows the order now button.

 

every addon will have a unique ID value that you can use to identify the addon - to find the ID value of your addon, probably the easiest way is to click on the edit button in the product addons page in the admin area - you'll see a URL similar to this...

 

configaddons.php?action=manage&id=1

 

so for that addon, its ID value equals 1 and that is what you would use if the {if} statement.

 

you will need to do this to obtain your addon id value for this product addon.

 

Right now, in the addon page I just copied an existing addon and modified the HTML manually, it looks exactly like all other addons, no difference, but since I have put the code there manually, of course it displays for all customers, regardless of products.

 

You mean your code would just change the order button (only for that addon alone) in the page or I should manually change the HTML code for that addon? If so, I would like to know where they are, since I think they are generated on the fly there from the database.

it could be used to change more than the order button for that particular addon if you wanted it to, but i'm trying to keep the solution simple for now! :)

 

the addons are generated in a loop - all we are doing is putting a condition into that loop saying when *this* addon is displayed, show a link... for any other addons, show order now buttons as normal... it should only need one line of code to do that.

 

the reason why I didn't give you the exact code to do this is because it will depend on which order form template you are using for your addons page - each template's code will likely be slightly different.

 

so if you can tell me which order-form template you are using for your addons page, i'll be able to give you the specific code and where to add it.

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