Jump to content

product price snip in language file


keneso

Recommended Posts

Hi,

 

I am creating some custom pages, with the content (text) in the override language files, and among other info I need to put the price in it.

 

Is it possible to call the price from within the language file?

If yes how, i.e. the code snip.

 

Thank you

Link to comment
Share on other sites

it's possible but it depends if the price array is available on that page... but i'm assuming as it's a custom page it won't be.

 

if it isn't, then you'll have to take another route - action hooks and/or data feeds being the simplest path to follow.

 

difficult to say without seeing your custom pages, but I would imagine adding a data feed would be the easiest solution for you.

 

http://docs.whmcs.com/Data_Feeds#Product_Pricing

 

<script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly"></script>

you could add the above into either you custom page or the language file - though if you add it into a language file (via an override), you'll probably need to backslash the double quotes...

 

<script language=\"javascript\" src=\"feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly\"></script>

Link to comment
Share on other sites

Thank you.

 

I get wrong value:

€-1.00Euro

 

If there is a better approach I am open to suggestions, I've put the code in the language file, as the price is between the details, and the order button all in the containing box, and if I put it in the template file I'd need to declare two language items - I think, i.e.

{$LANG.hosting_basic}

javascript price

{$LANG.hosting_basic_order}

Am I correct?

 

Here are my template file, and language file codes:

 

Template

<div class="hosting-box">
{$LANG.hosting_basic}
</div>

 

Language

$_LANG['hosting_basic'] = "<h1>Hosting basic</h1>
<div class='features-sx'>
Disk space<br />
Bandwisth<br />
Domain allowed<br />
Subdomains<br />
Email accounts<br />
MySql database<br />
Instant setup<br />
Advanced anti-spam<br /><br />
</div>
<div class='features-dx'>
2MB<br />
2GB/mo<br />
1<br />
Unlimited<br />
3<br />
1<br />
<img src='images/tick-icon_01-19.png' /><br />
<img src='images/tick-icon_01-19.png' /><br />
</div>
<div class='fz-hosting-box-price'>
<h2>
<script language=\"javascript\" src=\"feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly&currency=2\"></script>
</h2>
</div>
<a href='cart.php?a=add&pid=1'>
<div class='hosting-box-button'>
<h2>order NOW</h2>
</div>
</a>
";

Link to comment
Share on other sites

Thank you.

 

I get wrong value:

€-1.00Euro

then you must be using the wrong Product ID (pid) in the link... I probably should have mentioned that you need to change the pid number - my fault. :oops:

 

go to setup -> products/services -> products/services... and find your "Hosting Basic" product and click on the Links tab.

 

http://docs.whmcs.com/Products_and_Services#Links_tab

 

in the "Direct Shopping Cart Link", it will say something like the following...

 

http://www.yourdomain.com/cart.php?a=add&pid=45

so in this example, the Product ID (pid) for that product is 45 - so you will need to replace pid=1 with pid=45 in your javascript link...

 

<script language=\"javascript\" src=\"feeds/productsinfo.php?pid=45&get=price&billingcycle=monthly&currency=2\"></script>

once you have found the correct PID for the product, and added it to the link, then it should start to show the correct price.

 

I tried it before posting - so when you get the pid right, it will work! :)

 

If there is a better approach I am open to suggestions, I've put the code in the language file, as the price is between the details, and the order button all in the containing box, and if I put it in the template file I'd need to declare two language items - I think, i.e.

{$LANG.hosting_basic}

javascript price

{$LANG.hosting_basic_order}

Am I correct?

in this case, putting it in the language file is probably easier - but there might be times when it's easier to do it in the template as you describe above... I didn't know what you were using these custom pages for, so I gave you both options. :idea:

 

btw - there is a typo in your language text - it should be "bandwidth", not "bandwisth".

Link to comment
Share on other sites

then you must be using the wrong Product ID (pid) in the link... I probably should have mentioned that you need to change the pid number - my fault. :oops:

Thank you, not a fault at all.

I had caught that in the snip, and it is correct.

 

I found the culprit, I had set only the annual pricing, your post triggered me to check there.

 

However there is the currency problem, as it displays the symbol before the price, and the name after: 3.00Euro without any spacing either.

From the above I'd guess is some other setting I am missing, if you have any idea where to look for it.

 

btw - there is a typo in your language text - it should be "bandwidth", not "bandwisth".

Thank you.

 

- - - Updated - - -

 

3.00Euro without any spacing either.

 

It should read € 3.00/month

Link to comment
Share on other sites

However there is the currency problem, as it displays the symbol before the price, and the name after: 3.00Euro without any spacing either.

From the above I'd guess is some other setting I am missing, if you have any idea where to look for it.

it will take the '€' and 'Euro' from your currency settings (Prefix and Suffix).

 

http://docs.whmcs.com/Currencies

 

you could add a space after the '€' in the currency settings, but it would add that space all over the site when displaying prices in that currency.

 

the data feed uses a whmcs function that adds the correct currency prefix/suffix to the price.

 

It should read € 3.00/month

 

I can think of two ways to do this - the "correct" way and the "quick" way.

 

the "correct" way would be to modify the data feed code to display the output in the way that you describe - not technically difficult, but i'm having a lazy Sunday and you probably won't need to do it anyway. :)

 

the "quick" way is slightly simpler and you would modify the data feed to just provide the price with no currency included - so return "3.00" instead of "€ 3.00/month".

 

I would imagine you can use the quick way for your situation.... so in feeds/productsinfo.php, just remove the line...

 

$price = formatCurrency($price);

if you do that, then the feed will just return: 3.00

 

then modify your language override entry and add the currency symbol / month text in there..

 

$_LANG['hosting_basic'] = "<h1>Hosting basic</h1> 
<div class='features-sx'> 
Disk space<br /> 
Bandwidth<br /> 
Domain allowed<br /> 
Subdomains<br /> 
Email accounts<br /> 
MySql database<br /> 
Instant setup<br /> 
Advanced anti-spam<br /><br /> 
</div> 
<div class='features-dx'> 
2MB<br /> 
2GB/mo<br /> 
1<br /> 
Unlimited<br /> 
3<br /> 
1<br /> 
<img src='images/tick-icon_01-19.png' /><br /> 
<img src='images/tick-icon_01-19.png' /><br /> 
</div> 
<div class='fz-hosting-box-price'> 
<h2> 
€ <script language=\"javascript\" src=\"feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly&currency=2\"></script>/month
</h2> 
</div> 
<a href='cart.php?a=add&pid=1'> 
<div class='hosting-box-button'> 
<h2>order NOW</h2> 
</div> 
</a> 
";

that should output the price as € 3.00/month

 

ideally, what you should do instead of modifying the existing productsinfo.php data feed, is make a duplicate of it, rename the copy and then use that copy filename in your script calls - the reason for doing that is two-fold: firstly, when you update WHMCS you might overwrite your modified feed with an updated one from WHMCS; and secondly, it allows you the option to use the original feed elsewhere on the site.

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