Osclass Support Forums

Osclass plugin support => SMS Payments Plugin => Topic started by: mwindey on July 28, 2021, 04:44:02 PM

Title: Show premium expiration date on user_items
Post 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   ;)
Title: Re: Show premium expiration date on user_items
Post by: MB Themes on July 29, 2021, 02:14:32 PM
@mwindey
You should be able to find this information in table oc_t_item_sms_premium_expire
Title: Re: Show premium expiration date on user_items
Post by: mwindey on July 30, 2021, 08:45:53 AM
@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:

Code: [Select]
<?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?
Title: Re: Show premium expiration date on user_items
Post by: MB Themes on July 30, 2021, 11:54:29 AM
@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.
Title: Re: Show premium expiration date on user_items
Post by: mwindey on September 19, 2021, 11:56:30 AM
Solved this finally.....
In theme functions.php
Code: [Select]
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
Code: [Select]
               <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>
Title: Re: Show premium expiration date on user_items
Post by: MB Themes on September 20, 2021, 08:03:49 AM
@mwindey
Glad to hear that, you rock ;)