Jump to content

Data Feed & replacement possible ?


wp4all

Recommended Posts

Hi @ all,

is it possible to change / translate or replace the result of an Data Feed ?

Why I'm asking is I would like to use the data feed to show the price on an external Page but I won't show the Prefix.

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

In my little stupid world I would use :

document.body.innerHTML = document.body.innerHTML.replace(/€/g, ' ');

 which works already but this affects the entire page.

Thanks and best regards
Christian

Link to comment
Share on other sites

Hi Christian,

2 hours ago, wp4all said:

is it possible to change / translate or replace the result of an Data Feed ?

yes, but you're thinking of it entirely the wrong way. headshake.gif

2 hours ago, wp4all said:

Why I'm asking is I would like to use the data feed to show the price on an external Page but I won't show the Prefix.

that's simple enough.

2 hours ago, wp4all said:

In my little stupid world I would use... which works already but this affects the entire page.

then it's time for you to leave your stupid world and enter my insane world!

the solution is that instead of letting the data feed return the default price, e.g €100 EUR, and then trying to translate/manipulate/edit the result, you modify the feed code to suit your needs and return what you want from it! bright-idea-smiley-emoticon.gif

now, you should never modify existing data feeds because they will be overwritten by the WHMCS automatic updater - so create a new data feed in the feeds folder, post your code in there, modify it and use that... to save you time, i've quickly updated the productsinfo feed you mentioned and i've attached it to this post... just rename it to something else and remember to change your references (filename, productid, billingcycle, currency etc) in your template code that calls the feed(s).

I have added 3 options - to either output the price with a suffix; with a prefix, or with neither...

full string = <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=annually&currency=1"></script><br>
suffixed = <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=annually&currency=1&output=suffix"></script><br>
prefixed = <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=annually&currency=1&output=prefix"></script><br>
price only = <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=annually&currency=1&output=number"></script><br>
full string = £100.00 GBP
suffixed = 100.00 GBP
prefixed = £100.00
price only = 100.00

productsinfo.php

Link to comment
Share on other sites

  • 1 year later...

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.

×
×
  • 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