Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1032091
products_item.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jun 18, 8:07 AM
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Jun 20, 8:06 AM (17 m, 54 s)
Engine
blob
Format
Raw Data
Handle
666714
Attached To
rMINC Modules.In-Commerce
products_item.php
View Options
<?php
/**
* @version $Id: products_item.php 16775 2023-11-22 08:51:48Z alex $
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
class
ProductsItem
extends
kCatDBItem
{
function
GetPackageContentIds
()
{
$ids_string
=
trim
(
$this
->
GetDBField
(
'PackageContent'
),
'|'
);
if
(
$ids_string
)
{
$ids_array
=
explode
(
'|'
,
$ids_string
);
return
$ids_array
;
}
else
{
return
array
();
}
}
/**
* Returns field values from primary pricing for product
*
* @return array
*/
function
getPrimaryPricing
()
{
// product + pricing based
$cache_key
=
'product_primary_pricing[%PIDSerial:'
.
$this
->
GetID
()
.
'%][%PrIDSerial:ProductId:'
.
$this
->
GetID
()
.
'%]'
;
if
(!
$this
->
Application
->
isAdmin
&&
$this
->
Application
->
LoggedIn
())
{
// also group based
/** @var UserHelper $user_helper */
$user_helper
=
$this
->
Application
->
recallObject
(
'UserHelper'
);
$primary_group
=
$user_helper
->
getPrimaryGroup
(
$this
->
Application
->
RecallVar
(
'user_id'
));
$cache_key
.=
':group='
.
$primary_group
;
}
// don't cache, while in temp table
$price_info
=
$this
->
IsTempTable
()
?
false
:
$this
->
Application
->
getCache
(
$cache_key
);
if
(
$price_info
===
false
)
{
if
(!
$this
->
Application
->
isAdmin
&&
$this
->
Application
->
LoggedIn
())
{
// logged in user on front-end
$this
->
Conn
->
nextQueryCachable
=
true
;
$sql
=
'SELECT Price, Cost
FROM '
.
TABLE_PREFIX
.
'ProductsPricing
WHERE (ProductId = '
.
$this
->
GetID
()
.
') AND (GroupId = '
.
$primary_group
.
')
ORDER BY MinQty'
;
$price_info
=
$this
->
Conn
->
GetRow
(
$sql
);
if
(
$price_info
!==
false
)
{
$this
->
Application
->
setCache
(
$cache_key
,
$price_info
);
return
$price_info
;
}
}
// not logged-in user on front-end or in administrative console
$pr_table
=
$this
->
Application
->
getUnitOption
(
'pr'
,
'TableName'
);
if
(
$this
->
IsTempTable
())
{
$pr_table
=
$this
->
Application
->
GetTempName
(
$pr_table
,
'prefix:'
.
$this
->
Prefix
);
}
$this
->
Conn
->
nextQueryCachable
=
true
;
$sql
=
'SELECT Price, Cost
FROM '
.
$pr_table
.
'
WHERE ('
.
$this
->
IDField
.
' = '
.
$this
->
GetID
()
.
') AND (IsPrimary = 1)'
;
$price_info
=
$this
->
Conn
->
GetRow
(
$sql
);
$this
->
Application
->
setCache
(
$cache_key
,
$price_info
);
}
return
$price_info
;
}
}
Event Timeline
Log In to Comment