Premium display in random order
« on: April 25, 2017, 07:39:17 AM »
How to make premium ads are displayed in random order.

Now each page shows the last 2 premium ads and a button -show more-

http://prntscr.com/f0i578

http://prntscr.com/f0i5ah

http://prntscr.com/f0i5cs

Those who bought premium will get improved. don't get it

*

Ivanko

  • *****
  • 388 posts
Re: Premium display in random order
« Reply #1 on: April 25, 2017, 07:48:43 AM »
You can add more premium ads in search page from admin panel.

for randomize premium ads you can use shuffle function in php.



Re: Premium display in random order
« Reply #2 on: April 25, 2017, 08:35:49 AM »
Quote
for randomize premium ads you can use shuffle function in php.

Please tell me how to do it

*

Ivanko

  • *****
  • 388 posts
Re: Premium display in random order
« Reply #3 on: April 25, 2017, 09:08:21 AM »
Quote
for randomize premium ads you can use shuffle function in php.

Please tell me how to do it

It is only function...., but how you implement depends of your creation and skills.

Re: Premium display in random order
« Reply #4 on: April 25, 2017, 09:24:10 AM »
It seems to me that this feature is necessary for all who bought the theme Veronica.

Very useful if someone say how to make it


Re: Premium display in random order
« Reply #6 on: April 26, 2017, 01:32:43 PM »
Found a solution
to add to the file functions.php before ?>
this code


function cust_all_premiums_ontop_random() {
    $mSearch =  Search::newInstance();
    $query_elements = (array) json_decode($mSearch->toJson());

    $mSearch->addField(sprintf("(SELECT RAND() FROM %st_item i2 WHERE %st_item.pk_i_id = i2.pk_i_id AND %st_item.b_premium = 1) AS rand_premiums",  DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX));
    $mSearch->order("rand_premiums DESC, " . $query_elements['order_column'], $query_elements['order_direction']);
}

osc_add_hook('search_conditions', 'cust_all_premiums_ontop_random');