This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

mwindey

  • ***
  • 93 posts
Show premium expiration date on user_items
« 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   ;)

*

MB Themes

Re: Show premium expiration date on user_items
« Reply #1 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
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • ***
  • 93 posts
Re: Show premium expiration date on user_items
« Reply #2 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?

*

MB Themes

Re: Show premium expiration date on user_items
« Reply #3 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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by frosticek on September 20, 2021, 08:06:08 AM
*

mwindey

  • ***
  • 93 posts
Re: Show premium expiration date on user_items
« Reply #4 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>
« Last Edit: September 19, 2021, 03:37:11 PM by mwindey »

*

MB Themes

Re: Show premium expiration date on user_items
« Reply #5 on: September 20, 2021, 08:03:49 AM »
@mwindey
Glad to hear that, you rock ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots