Osclass Support Forums
Osclass plugin support => SMS Payments Plugin => Topic started by: mwindey on July 28, 2021, 04:44:02 PM
-
I would like to display the expiration date of the premium ads on the user items page.
Probably this should be possible since the sms plugin also knows until when the item will be extended.
Getting the echo code output in place is no problem but where do I get the date of expiration to echo.
Another difficult question and hopefully a simple solution ;)
-
@mwindey
You should be able to find this information in table oc_t_item_sms_premium_expire
-
@MB Themes
I know it is in table oc_t_item_sms_premium_expire but i cannot find the right code to echo the date.
My knowledge in PHP is moderate and absolutely not as good as yours :)
The code i am testing with in user_items.php is this:
<?php
$expire_date= "";
$sql = "SELECT * .expire_date FROM oc_t_item_sms_premium_expire WHERE item_id=(osc_item_id());";?>
<?php if(osc_item_is_premium()); { ?>
<span><span class="label"><?php _e('Premium', 'veronika'); ?>:</span><?php echo $expire_date; ?>
<?php } ?>
No errors appear but also no output :(
Would you be so kind to look into this please?
-
@mwindey
That of course will not work.
You may need to create new function in Model and then use this function to get value from database.
In Model you may find similar functions those communicate with database.
-
Solved this finally.....
In theme functions.php
function item_sms_premium_expire_date($item_id = null) {
$item_id = ($item_id < 1 ) ? ((osc_premium_id() > 0) ? osc_premium_id() : ((osc_item_id() > 0) ? osc_item_id() : null)) : $item_id;
$dao = new DAO();
$table = 't_item_sms_premium_expire';
$dao->dao->select('*');
$dao->dao->where('item_id', $item_id);
$dao->dao->from(DB_TABLE_PREFIX . $table);
$result = $dao->dao->get();
if (!$result->row()) {
return NULL;
}
$date = $result->row();
return $date['expire_date'];
}
And in user_items.php
<span>
<?php if (osc_item_is_premium()) { ?>
<span class="label"><?php _e('Premium ends', 'veronika'); ?>:</span> <?php echo date('d/m/Y', strtotime(item_sms_premium_expire_date())); ?></span>
<?php } ?></span>
-
@mwindey
Glad to hear that, you rock ;)