collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 499
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Author Topic: SMF Store - Block  (Read 6114 times)

0 Members and 1 Guest are viewing this topic.

Offline vbgamer45

  • Semi Newbie
  • *
  • Posts: 5
    • SMFHacks.com
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: 1.1.4
SMF Store - Block
« on: March 04, 2014, 04:11:47 PM »
Block code for Simple Portal for SMF Store
For SMF 2.0.x only
The main SMFStoreBlock function controls what is shown there are two examples below

Code: [Select]

/// examples
//  SMFStoreBlock(2,4. 'recent');
//  SMFStoreBlock(1,1. 'toprated');

/*
$category - is optional
$startHtml - is optional
$endHtml - is optional
*/

function SMFStoreBlock($rows = 4, $products = 4, $type = 'recent', $category = 0, $startHtml = '', $endHtml = '')
{
global  $smcFunc, $scripturl, $txt, $modSettings, $boardurl, $context;

$rows = (int) $rows;

if (empty($modSettings['store_url']))
$modSettings['store_url'] = $boardurl . '/store/';

// Html Header
echo $startHtml;


// Load the language files
if (loadlanguage('Store') == false)
loadLanguage('Store', 'english');

$g_manage = allowedTo('smfstore_manage');

$maxrowlevel = $rows ;
echo '<table cellspacing="0" cellpadding="5" border="0" align="center" width="100%" >
';
// Check what type it is
$query = ' ';
switch($type)
{
case 'recent':
$query = "SELECT i.ID_ITEM, i.commenttotal, i.totalratings, i.rating,
i.primaryID_PICTURE, i.productname, p.thumbfilename, i.price,i.currency,
i.qtyinstock, i.needsstock, i.date, i.views
FROM {db_prefix}store_item as i LEFT JOIN {db_prefix}store_item_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
WHERE  i.hideproduct = 0 ORDER BY i.ID_ITEM DESC LIMIT $products";
break;

case 'viewed':
$query = "SELECT i.ID_ITEM, i.commenttotal, i.totalratings, i.rating,
i.primaryID_PICTURE, i.productname, p.thumbfilename, i.price,i.currency,
i.qtyinstock, i.needsstock, i.date, i.views
FROM {db_prefix}store_item as i LEFT JOIN {db_prefix}store_item_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
WHERE  i.hideproduct = 0  ORDER BY  i.views DESC LIMIT $products";
break;

case 'mostcomments':
$query = "SELECT i.ID_ITEM, i.commenttotal, i.totalratings, i.rating,
i.primaryID_PICTURE, i.productname, p.thumbfilename, i.price,i.currency,
i.qtyinstock, i.needsstock, i.date, i.views
FROM {db_prefix}store_item as i LEFT JOIN {db_prefix}store_item_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
WHERE  i.hideproduct = 0  ORDER BY i.commenttotal DESC LIMIT $products";
break;

case 'toprated':
$query = "SELECT i.ID_ITEM, i.commenttotal, i.totalratings, i.rating,
(i.rating / i.totalratings ) AS ratingaverage,
i.primaryID_PICTURE, i.productname, p.thumbfilename, i.price,i.currency,
i.qtyinstock, i.needsstock, i.date, i.views
FROM {db_prefix}store_item as i LEFT JOIN {db_prefix}store_item_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
WHERE  i.hideproduct = 0  ORDER BY ratingaverage DESC LIMIT $products";
break;

   case 'random':
$query = "SELECT i.ID_ITEM, i.commenttotal, i.totalratings, i.rating,
i.primaryID_PICTURE, i.productname, p.thumbfilename, i.price,i.currency,
i.qtyinstock, i.needsstock, i.date, i.views
FROM {db_prefix}store_item as i LEFT JOIN {db_prefix}store_item_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
WHERE  i.hideproduct = 0 ORDER BY RAND() DESC LIMIT $products";
break;

case 'mostpurchased':

break;


}
// Execute the SQL query
$dbresult = $smcFunc['db_query']('', $query);
$rowlevel = 0;
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
if($rowlevel == 0)
echo '<tr class="windowbg2">';

echo '<td align="center"><a href="', $scripturl, '?action=store;sa=view;id=', $row['ID_ITEM'], '">', $row['productname'], '</a><br />';

if (!empty($row['primaryID_PICTURE']))
echo '<a href="', $scripturl, '?action=store;sa=view;id=', $row['ID_ITEM'], '"><img src="', $modSettings['store_url'], $row['thumbfilename'], '" alt="" /></a><br />';


echo '<span class="smalltext">';


if (!empty($modSettings['store_set_t_price']))
{

echo $txt['store_text_price'] . StoreEzformatprice($row['price'],$row['currency']) . '<br />';

}

if (!empty($modSettings['store_set_t_stock']))
{
if ($row['needsstock'])
{
if ($row['qtyinstock'] > 0)
echo $txt['store_text_instock'] . '<br />';
else
echo $txt['store_text_outofstock'] . '<br />';
}
}

if (!empty($modSettings['store_set_t_date']))
echo $txt['store_text_date'] . timeformat($row['date']) . '<br />';

if (!empty($modSettings['store_set_t_rating']))
echo $txt['store_form_rating'] . StoreEzGetStarsByPrecent(($row['totalratings'] != 0) ? ($row['rating'] / ($row['totalratings']* 5) * 100) : 0) . '<br />';


if (!empty($modSettings['store_set_t_comment']))
echo $txt['store_text_comments'] . ' (<a href="' . $scripturl . '?action=store;sa=view;id=' . $row['ID_ITEM'] . '">' . $row['commenttotal'] . '</a>)<br />';
if ($g_manage)
{

echo '&nbsp;<a href="' . $scripturl . '?action=store;sa=edititem;id=' . $row['ID_ITEM'] . '">' . $txt['store_text_edit'] . '</a>';
echo '&nbsp;<a href="' . $scripturl . '?action=store;sa=deleteitem;id=' . $row['ID_ITEM'] . '">' . $txt['store_text_delete'] . '</a>';
}

echo '</span></td>';


if($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}
if($rowlevel !=0)
{
echo '</tr>';
}

echo '
      </table><br />';
// Free the Mysql Resoruces
$smcFunc['db_free_result']($dbresult);



// Html Footer
echo $endHtml;

}

function StoreEzformatprice($price,$currency)
{
if ($currency == 'USD')
return  '$' .  number_format($price, 2, '.', '');
else if ($currency == 'GBP')
return  '&#163;' .  number_format($price, 2, '.', '');
elseif ($currency == 'CAD')
return  '$' .  number_format($price, 2, '.', '');
elseif ($currency == 'AUD')
return  '$' .  number_format($price, 2, '.', '');
  elseif ($currency == 'ZAR')
return  'R ' .  number_format($price, 2, '-', '');
else
return $price . ' ' . $currency;

}
function StoreEzGetStarsByPrecent($percent)
{
global $settings, $txt;

if ($percent == 0)
return $txt['store_error_no_rating_selected'];
else if ($percent <= 20)
return str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 1);
else if ($percent <= 40)
return str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 2);
else if ($percent <= 60)
return str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 3);
else if ($percent <= 80)
return str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 4);
else if ($percent <= 100)
return str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 5);

}
« Last Edit: March 23, 2014, 09:44:07 PM by vbgamer45 »
https://www.smfhacks.com - Products and Modifications for SMF

Offline dan4ever

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SMF Store - Block
« Reply #1 on: March 16, 2014, 09:10:22 AM »
Hi

I tried this but got a empty box (showing nothing).
Are there any thing I should change inside the code?

/Dan

Offline dan4ever

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SMF Store - Block
« Reply #2 on: March 16, 2014, 12:29:18 PM »
Your 3 first line should be like this I think...

Code: [Select]
/// examples
//  SMFStoreBlock(2,4, 'recent');
//  SMFStoreBlock(1,1, 'toprated');

And I put in a "Random" too.

Code: [Select]

                                case 'random':
$query = "SELECT i.ID_ITEM, i.commenttotal, i.totalratings, i.rating,
i.primaryID_PICTURE, i.productname, p.thumbfilename, i.price,i.currency,
i.qtyinstock, i.needsstock, i.date, i.views
FROM {db_prefix}store_item as i LEFT JOIN {db_prefix}store_item_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
WHERE  i.hideproduct = 0 ORDER BY RAND() DESC LIMIT $products";
break;

dan4ever

Offline vbgamer45

  • Semi Newbie
  • *
  • Posts: 5
    • SMFHacks.com
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: 1.1.4
Re: SMF Store - Block
« Reply #3 on: March 23, 2014, 09:44:23 PM »
Fixed and thanks for the random idea.
https://www.smfhacks.com - Products and Modifications for SMF