How to pull the cost of usergroup subscription

Post

Posted
Rating:
#4566 (In Topic #920)
Joe

...using Tempcode

Is this at all possible? I don't want to hard code a specific price in my templates in the event I change the price of the subscription, then I'd have to change too many templates. If there was a way using Tempcode to get the set price for a subscription, I'd like to do it this way.

Post

Posted
Rating:
#4567
You don't need to make a symbol, unless this is a template specifically associated with the subscriptions (in which case there may be a parameter with it in).

Last edit: by Chris Graham

Post

Posted
Rating:
#4568
Joe
Chris,

Sorry, but I don't understand your reply.

Let me elaborate what I've done:

My usergroup subscription price is set at 19.99 USD monthly. I've created a custom template file, which is referenced on many Comcode pages throughout my site and details features included with subscribing. And, in some areas, when a user tries to access a subscription-required feature, I have configured the template to show upgrade options to the user, which also displays the current price for the subscription.

Instead of hard coding the price into the template, I'd like get the price dynamically from what is configured inside the usergroup subscription itself.

Post

Posted
Rating:
#4569
Joe
To clarify, if I ever change the price of the subscription from within the usergroup subscription settings, it would automatically be updated in the template without the need to go back and hard code a new price. :thumbs:

Post

Posted
Rating:
#4570
Right, you'd need to program a symbol to get this data. It's doesn't exist currently.

I did make a typo in my post though, I'm editing it.

Post

Posted
Rating:
#4571
Joe
Oh I see now. I'll see if I can figure this out.

Post

Posted
Rating:
#4572
Joe
I thought this would work, but it just leaves me with a lengthy stack trace. Any ideas where I'm going wrong?

Code (php)

function ecv_SUBSCRIPTION_INFO($lang, $escaped, $param)
{
    $db = $GLOBALS['FORUM_DB'];
    $value = $db->query('SELECT s_cost FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_usergroup_subs WHERE id=1 limit 1');
   
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

Post

Posted
Rating:
#4575
query returns a list of row maps.

queryquery_value_if_there

Post

Posted
Rating:
#4576
Joe

Chris Graham said

query returns a list of row maps.

queryquery_value_if_there

That worked, thanks Chris.

I had to remove the LIMIT 1 from the query for it to work as well.
1 guest and 0 members have recently viewed this.