本文整理汇总了PHP中CSaleUser::GetUserID方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleUser::GetUserID方法的具体用法?PHP CSaleUser::GetUserID怎么用?PHP CSaleUser::GetUserID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleUser
的用法示例。
在下文中一共展示了CSaleUser::GetUserID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProviderBasketMap
/**
* @param array $basketList
* @param array $select
* @return array
* @throws ObjectNotFoundException
*/
protected static function createProviderBasketMap(array $basketList, array $select = array())
{
$basketProviderMap = array();
/**
* @var string $basketKey
* @var BasketItem $basketItem
*/
foreach ($basketList as $basketIndex => $basketItemDat) {
if (is_array($basketItemDat) && isset($basketItemDat['BASKET_ITEM'])) {
$basketItem = $basketItemDat['BASKET_ITEM'];
} else {
$basketItem = $basketItemDat;
}
$basketProviderData = array('BASKET_ITEM' => $basketItem, 'BASKET_ID' => $basketItem->getId(), 'BASKET_CODE' => $basketItem->getBasketCode(), 'PRODUCT_ID' => $basketItem->getProductId(), 'MODULE' => $basketItem->getField('MODULE'));
if ($provider = $basketItem->getProvider()) {
$basketProviderData['PROVIDER'] = $provider;
} elseif (strval($basketItem->getField('CALLBACK_FUNC')) != '' || strval($basketItem->getField('PAY_CALLBACK_FUNC')) != '') {
$basketProviderData['CALLBACK_FUNC'] = strval($basketItem->getField('CALLBACK_FUNC')) != '' ? $basketItem->getField('CALLBACK_FUNC') : $basketItem->getField('PAY_CALLBACK_FUNC');
} else {
continue;
}
if (in_array('QUANTITY', $select)) {
$basketProviderData['QUANTITY'] = $basketItem->getQuantity();
// ????
}
if (in_array('RENEWAL', $select)) {
$basketProviderData['RENEWAL'] = $basketItem->getField('RENEWAL') !== null && $basketItem->getField('RENEWAL') != 'N' ? 'Y' : 'N';
}
if (in_array('RESERVED', $select)) {
$basketProviderData['RESERVED'] = $basketItemDat['RESERVED'];
}
if (in_array('SITE_ID', $select)) {
$basketProviderData['SITE_ID'] = $basketItem->getField('LID');
}
if (in_array('ORDER_ID', $select)) {
/** @var Basket $basket */
if (!($basket = $basketItem->getCollection())) {
throw new ObjectNotFoundException('Entity "Basket" not found');
}
if ($basket->getOrder() && $basket->getOrderId() > 0) {
$basketProviderData['ORDER_ID'] = $basket->getOrderId();
}
}
if (in_array('USER_ID', $select)) {
/** @var Basket $basket */
if (!($basket = $basketItem->getCollection())) {
throw new ObjectNotFoundException('Entity "Basket" not found');
}
if ($order = $basket->getOrder()) {
$userId = $order->getUserId();
if ($userId === null) {
$userId = \CSaleUser::GetUserID($basket->getFUserId());
}
if ($userId > 0) {
$basketProviderData['USER_ID'] = $userId;
}
}
}
if (in_array('PAID', $select)) {
/** @var Basket $basket */
if (!($basket = $basketItem->getCollection())) {
throw new ObjectNotFoundException('Entity "Basket" not found');
}
if ($basket->getOrder() && $basket->getOrderId() > 0) {
$order = $basket->getOrder();
$basketProviderData['PAID'] = $order->isPaid();
}
}
$basketProviderMap[$basketIndex] = $basketProviderData;
}
return $basketProviderMap;
}
示例2: Delete
function Delete($ID)
{
global $DB;
$ID = intval($ID);
if (0 >= $ID) {
return false;
}
$rsBaskets = CSaleBasket::GetList(array(), array('ID' => $ID), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
if (!($arBasket = $rsBaskets->Fetch())) {
return false;
}
foreach (GetModuleEvents("sale", "OnBeforeBasketDelete", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
return false;
}
}
if (CSaleBasketHelper::isSetParent($arBasket)) {
$rsSetItems = CSaleBasket::GetList(array(), array("SET_PARENT_ID" => $ID, "TYPE" => ""), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
while ($arSetItem = $rsSetItems->GetNext()) {
CSaleBasket::Delete($arSetItem["ID"]);
}
}
if (0 < intval($arBasket["ORDER_ID"])) {
CSaleOrderChange::AddRecord($arBasket["ORDER_ID"], "BASKET_REMOVED", array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "NAME" => $arBasket["NAME"]));
}
$DB->Query("DELETE FROM b_sale_basket_props WHERE BASKET_ID = " . $ID, true);
if (intval($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]) > 0 && !CSaleBasketHelper::isSetItem($arBasket)) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
}
$DB->Query("DELETE FROM b_sale_store_barcode WHERE BASKET_ID = " . $ID, true);
$DB->Query("DELETE FROM b_sale_basket WHERE ID = " . $ID, true);
if ('Y' == $arBasket['SUBSCRIBE'] && array_key_exists('NOTIFY_PRODUCT', $_SESSION)) {
$intUserID = CSaleUser::GetUserID($arBasket['FUSER_ID']);
if ($intUserID && array_key_exists($intUserID, $_SESSION['NOTIFY_PRODUCT'])) {
if (array_key_exists($arBasket['PRODUCT_ID'], $_SESSION['NOTIFY_PRODUCT'][$intUserID])) {
unset($_SESSION['NOTIFY_PRODUCT'][$intUserID][$arBasket['PRODUCT_ID']]);
}
}
}
foreach (GetModuleEvents("sale", "OnBasketDelete", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID));
}
return true;
}
示例3: Delete
/**
* <p>Метод удаляет запись корзины с кодом ID. Метод динамичный.</p> <a name="examples"></a>
*
*
* @param int $ID
*
* @return bool
*
* <h4>Example</h4>
* <pre>
* <?
* if (CSaleBasket::Delete(22))
* echo "Запись успешно удалена";
* ?>
* </htmМетод может использоваться и для удаления записей корзин, которые уже превращены в заказы. То есть, мы можем удалить запись из состава заказа. Но следует помнить, что после использования метода необходимо обновлять итоговую сумму заказа, например, так:
*
*
* $contents = array();
* $dbBasketItems = CSaleBasket::GetList(
* array(
* "NAME" => "ASC",
* "ID" => "ASC"
* ),
* array(
* "LID" => SITE_ID,
* "ORDER_ID" => $order_id,
* )
* );
* while ($arItems = $dbBasketItems->Fetch()){
* $contents[] = $arItems;
* }
* $sum = 0;
* foreach($contents as $basket_item){
* if($basket_item['DISCOUNT_PRICE']>0){
* $sum += $basket_item['DISCOUNT_PRICE']*$basket_item['QUANTITY'];
* }else{
* $sum += $basket_item['PRICE']*$basket_item['QUANTITY'];
* }
* }
* $arFields = array(
* "PRICE" => $sum,
* );
* CSaleOrder::Update($order_id, $arFields);
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalebasket/csalebasket__delete.e0d06223.php
* @author Bitrix
*/
public static function Delete($ID)
{
global $DB, $APPLICATION;
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
$ID = intval($ID);
if (0 >= $ID) {
return false;
}
if ($isOrderConverted == "Y") {
/** @var \Bitrix\Sale\Result $r */
$r = \Bitrix\Sale\Compatible\BasketCompatibility::delete($ID);
if (!$r->isSuccess(true)) {
foreach ($r->getErrorMessages() as $error) {
$APPLICATION->ThrowException($error);
}
return false;
}
return true;
}
$rsBaskets = CSaleBasket::GetList(array(), array('ID' => $ID), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
if (!($arBasket = $rsBaskets->Fetch())) {
return false;
}
foreach (GetModuleEvents("sale", "OnBeforeBasketDelete", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
return false;
}
}
if (CSaleBasketHelper::isSetParent($arBasket)) {
$rsSetItems = CSaleBasket::GetList(array(), array("SET_PARENT_ID" => $ID, "TYPE" => ""), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
while ($arSetItem = $rsSetItems->GetNext()) {
CSaleBasket::Delete($arSetItem["ID"]);
}
}
if (0 < intval($arBasket["ORDER_ID"])) {
CSaleOrderChange::AddRecord($arBasket["ORDER_ID"], "BASKET_REMOVED", array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "NAME" => $arBasket["NAME"]));
}
$DB->Query("DELETE FROM b_sale_basket_props WHERE BASKET_ID = " . $ID, true);
if (intval($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]) > 0 && !CSaleBasketHelper::isSetItem($arBasket)) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
}
$DB->Query("DELETE FROM b_sale_store_barcode WHERE BASKET_ID = " . $ID, true);
$DB->Query("DELETE FROM b_sale_basket WHERE ID = " . $ID, true);
if ('Y' == $arBasket['SUBSCRIBE'] && array_key_exists('NOTIFY_PRODUCT', $_SESSION)) {
$intUserID = CSaleUser::GetUserID($arBasket['FUSER_ID']);
if ($intUserID && array_key_exists($intUserID, $_SESSION['NOTIFY_PRODUCT'])) {
if (array_key_exists($arBasket['PRODUCT_ID'], $_SESSION['NOTIFY_PRODUCT'][$intUserID])) {
unset($_SESSION['NOTIFY_PRODUCT'][$intUserID][$arBasket['PRODUCT_ID']]);
}
}
//.........这里部分代码省略.........
示例4: Delete
/**
* <p>Функция удаляет запись корзины с кодом ID. </p> <a name="examples"></a>
*
*
*
*
* @param int $ID
*
*
*
* @return bool
*
*
* <h4>Example</h4>
* <pre>
* <?
* if (CSaleBasket::Delete(22))
* echo "Запись успешно удалена";
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalebasket/csalebasket__delete.e0d06223.php
* @author Bitrix
*/
public static function Delete($ID)
{
global $DB;
$ID = intval($ID);
if (0 >= $ID)
return false;
$rsBaskets = CSaleBasket::GetList(
array(),
array('ID' => $ID),
false,
false,
array(
'ID',
'ORDER_ID',
'PRODUCT_ID',
'NAME',
'SUBSCRIBE',
'FUSER_ID'
)
);
if (!($arBasket = $rsBaskets->Fetch()))
return false;
foreach(GetModuleEvents("sale", "OnBeforeBasketDelete", true) as $arEvent)
if (ExecuteModuleEventEx($arEvent, array($ID))===false)
return false;
if (0 < intval($arBasket["ORDER_ID"]))
CSaleOrderChange::AddRecord($arBasket["ORDER_ID"], "BASKET_REMOVED", array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "NAME" => $arBasket["NAME"]));
$DB->Query("DELETE FROM b_sale_basket_props WHERE BASKET_ID = ".$ID, true);
if(intval($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]) > 0 )
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
$DB->Query("DELETE FROM b_sale_store_barcode WHERE BASKET_ID = ".$ID, true);
$DB->Query("DELETE FROM b_sale_basket WHERE ID = ".$ID, true);
if ('Y' == $arBasket['SUBSCRIBE'] && array_key_exists('NOTIFY_PRODUCT', $_SESSION))
{
$intUserID = CSaleUser::GetUserID($arBasket['FUSER_ID']);
if ($intUserID && array_key_exists($intUserID, $_SESSION['NOTIFY_PRODUCT']))
{
if (array_key_exists($arBasket['PRODUCT_ID'], $_SESSION['NOTIFY_PRODUCT'][$intUserID]))
{
unset($_SESSION['NOTIFY_PRODUCT'][$intUserID][$arBasket['PRODUCT_ID']]);
}
}
}
foreach(GetModuleEvents("sale", "OnBasketDelete", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array($ID));
return true;
}