本文整理汇总了PHP中CSaleBasket::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket::GetByID方法的具体用法?PHP CSaleBasket::GetByID怎么用?PHP CSaleBasket::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleBasket
的用法示例。
在下文中一共展示了CSaleBasket::GetByID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserDelay
function getUserDelay ($userId){
// Получаем список корзины
$arBasketItems = array();
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" =>$userId,
"LID" => SITE_ID,
"ORDER_ID" => "NULL"
),
false,
false,
array("ID", "CALLBACK_FUNC", "MODULE", "NAME",
"PRODUCT_ID", "QUANTITY", "DELAY",
"CAN_BUY", "PRICE", "DATE_INSERT", "DATE_UPDATE")
);
while ($arItems = $dbBasketItems->Fetch())
{
if (strlen($arItems["CALLBACK_FUNC"]) > 0)
{
CSaleBasket::UpdatePrice($arItems["ID"],
$arItems["CALLBACK_FUNC"],
$arItems["MODULE"],
$arItems["PRODUCT_ID"],
$arItems["QUANTITY"]);
$arItems = CSaleBasket::GetByID($arItems["ID"]);
}
$arBasketItems[] = $arItems;
}
// Печатаем массив, содержащий актуальную на текущий момент корзину
/* echo "<pre>";
print_r($arBasketItems);
echo "</pre>"; */
$whishlist="";
foreach ($arBasketItems as $delay){
$notBuy="Y"; // флаг для проверки покупался ли данный товар,
$difference = floor(intval(abs( time() - strtotime($delay[DATE_INSERT]) ))/(3600 * 24));
// перебираем отложенные элементы, срок которых менее 30 дней
if ($delay["DELAY"]=="Y" && $difference < 30){
foreach ($arBasketItems as $notDelay){
//перебираем купленные элементы и сравниваем с отложенными
if ($notDelay["DELAY"]!="Y" && $delay[PRODUCT_ID]==$notDelay[PRODUCT_ID] && $difference < 30){
$notBuy="N"; // товар уже покупался
}
}
if($notBuy=="Y"){
$whishlist .= ' '.$delay["NAME"].',';
}
}
}
$whishlist = trim($whishlist, ",");
return $whishlist;
}
示例2: GetBasketList
function GetBasketList($bSkipFUserInit = False)
{
$fUserID = CSaleBasket::GetBasketUserID($bSkipFUserInit);
$arRes = array();
if ($fUserID > 0) {
$db_res = CSaleBasket::GetList(array("NAME" => "ASC"), array("FUSER_ID" => $fUserID, "LID" => SITE_ID, "ORDER_ID" => "NULL"));
while ($res = $db_res->GetNext()) {
if (strlen($res["CALLBACK_FUNC"]) > 0 || strlen($res["PRODUCT_PROVIDER_CLASS"]) > 0) {
CSaleBasket::UpdatePrice($res["ID"], $res["CALLBACK_FUNC"], $res["MODULE"], $res["PRODUCT_ID"], $res["QUANTITY"], $res["PRODUCT_PROVIDER_CLASS"]);
$res = CSaleBasket::GetByID($res["ID"]);
}
$arRes[] = $res;
}
}
return $arRes;
}
示例3: json_decode
'content' => '{"api_auth_token": "'.$secret.'"}'
)
));
$api_answer = json_decode(file_get_contents($token_url, FALSE, $context));
if (!$api_answer) { throw new Exception(GetMessage("EXCEPTION_NO_API_ANSWER", array("#URL#" => $token_url))); }
if (!($arResult['WIDGET_TOKEN'] = $api_answer->token)) { throw new Exception(GetMessage("EXCEPTION_NO_WIDGET_TOKEN")); }
if (!($arResult['GP_DELIVERY_DESCRIPTION'] = $api_answer->description)) { throw new Exception(GetMessage("EXCEPTION_NO_DELIVERY_DESCRIPTION")); }
$arBasketItems = array();
$dbBasketItems = CSaleBasket::GetList(
array("NAME" => "ASC", "ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL")
);
while ($arItems = $dbBasketItems->Fetch()) {
if (strlen($arItems["CALLBACK_FUNC"]) > 0) {
CSaleBasket::UpdatePrice($arItems["ID"], $arItems["CALLBACK_FUNC"], $arItems["MODULE"], $arItems["PRODUCT_ID"], $arItems["QUANTITY"]);
$arItems = CSaleBasket::GetByID($arItems["ID"]);
}
$arBasketItems[] = $arItems;
}
$arResult['WIDGET_ITEMS'] = array();
$ESTIMATED_PRICE_TYPE_ID = 4;
foreach($arBasketItems as $index=>$item) {
$widgetItem = array();
$widgetItem['price'] = $item['PRICE'];
$widgetItem['shop_good_code'] = $item['PRODUCT_ID'];
$widgetItem['count'] = $item['QUANTITY'];
$widgetItem['weight'] = $item['WEIGHT'];
$widgetItem['name'] = $item['NAME'];
$rsPrices = CPrice::GetList(array(), array('PRODUCT_ID' => $item['PRODUCT_ID'], 'CATALOG_GROUP_ID' => $ESTIMATED_PRICE_TYPE_ID));
if ($arPrice = $rsPrices->Fetch()) {
示例4: array
if (count($arBasketIDs) > 0) {
?>
<table class="blank">
<tr>
<td align="center">№</td>
<td align="center">Наименование</td>
<td align="center">Количество</td>
<td align="center">Цена, руб</td>
<td align="center">Cумма, руб</td>
</tr>
<?php
$priceTotal = 0;
$bUseVat = false;
$arBasketOrder = array();
for ($i = 0, $countBasketIds = count($arBasketIDs); $i < $countBasketIds; $i++) {
$arBasketTmp = CSaleBasket::GetByID($arBasketIDs[$i]);
if (floatval($arBasketTmp["VAT_RATE"]) > 0) {
$bUseVat = true;
}
$priceTotal += $arBasketTmp["PRICE"] * $arBasketTmp["QUANTITY"];
$arBasketTmp["PROPS"] = array();
if (isset($_GET["PROPS_ENABLE"]) && $_GET["PROPS_ENABLE"] == "Y") {
$dbBasketProps = CSaleBasket::GetPropsList(array("SORT" => "ASC", "NAME" => "ASC"), array("BASKET_ID" => $arBasketTmp["ID"]), false, false, array("ID", "BASKET_ID", "NAME", "VALUE", "CODE", "SORT"));
while ($arBasketProps = $dbBasketProps->GetNext()) {
$arBasketTmp["PROPS"][$arBasketProps["ID"]] = $arBasketProps;
}
}
$arBasketOrder[] = $arBasketTmp;
}
//разбрасываем скидку на заказ по товарам
if (floatval($arOrder["DISCOUNT_VALUE"]) > 0) {
示例5: getBasketArray
/**
* get item params for view or cart push from basket id
*
* @param $id
* @return array|bool
*/
public static function getBasketArray($id)
{
$libBasket = new \CSaleBasket();
$item = $libBasket->GetByID($id);
return Data::getItemArray($item['PRODUCT_ID']);
}
示例6: intval
//$allproducts = explode("-", $_REQUEST["productid"]);
//foreach ($allproducts as $product) {
$product = intval($_REQUEST["productid"]);
//$product = intval($_POST["add2basket"]);
//проверим
$res = CIBlockElement::GetByID($product);
if ($ar_res = $res->GetNext()) {
$arProps = array();
$PRODUCT = $ar_res;
$ar_res = CPrice::GetBasePrice($PRODUCT[ID]);
$price = $ar_res["PRICE"];
if (intval($price) == 0) {
$price = 0;
$arFields = array("PRODUCT_ID" => $PRODUCT[ID], "QUANTITY" => $quantity, "PRODUCT_XML_ID" => $PRODUCT[ID], "PRICE" => $price, "CURRENCY" => "RUB", "LID" => "s1", "NAME" => $PRODUCT[NAME]);
$basket_id = CSaleBasket::Add($arFields);
$arItem = CSaleBasket::GetByID($basket_id);
if ($arItem["QUANTITY"] != $quantity) {
$arFields = array("QUANTITY" => $arItem["QUANTITY"] + $quantity);
CSaleBasket::Update($basket_id, $arFields);
}
} else {
$basket_id = Add2BasketByProductID($product, $quantity);
}
}
}
break;
case "update":
$arFields = array("QUANTITY" => $_REQUEST["quantity"]);
CSaleBasket::Update($_REQUEST["id"], $arFields);
break;
}
示例7: DeductBasketProduct
/**
* Method is called to deduct one product in the basket
* (it's a wrapper around product provider DeductProduct method to use for the single product)
*
* @param int $basketID
* @param float $deltaQuantity - quantity to reserve
* @param array $arStoreBarcodeData
* @return mixed array
*/
function DeductBasketProduct($basketID, $deltaQuantity, $arStoreBarcodeData = array())
{
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DeductBasketProduct", array("basketId" => $basketID, "deltaQuantity" => $deltaQuantity, "storeBarcodeData" => $arStoreBarcodeData), "DBP1");
}
global $APPLICATION;
$arResult = array();
$basketID = (int) $basketID;
if ($basketID <= 0) {
$arResult["RESULT"] = false;
return $arResult;
}
$deltaQuantity = (double) $deltaQuantity;
if ($deltaQuantity < 0) {
$deltaQuantity = abs($deltaQuantity);
$bUndoDeduction = true;
} else {
$bUndoDeduction = false;
}
$arBasket = CSaleBasket::GetByID($basketID);
if ($arBasket) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductProduct", array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "QUANTITY" => empty($arStoreBarcodeData) ? $deltaQuantity : 0, "UNDO_DEDUCTION" => $bUndoDeduction ? "Y" : "N", "EMULATE" => "N", "PRODUCT_RESERVED" => $arBasket["RESERVED"], "STORE_DATA" => $arStoreBarcodeData), "DBP2");
}
if ($bUndoDeduction) {
$dbStoreBarcode = CSaleStoreBarcode::GetList(array(), array("BASKET_ID" => $arBasket["ID"]), false, false, array("ID", "BASKET_ID", "BARCODE", "QUANTITY", "STORE_ID"));
while ($arRes = $dbStoreBarcode->GetNext()) {
$arStoreBarcodeData[] = $arRes;
}
}
$res = $productProvider::DeductProduct(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "QUANTITY" => empty($arStoreBarcodeData) ? $deltaQuantity : 0, "UNDO_DEDUCTION" => $bUndoDeduction ? "Y" : "N", "EMULATE" => "N", "PRODUCT_RESERVED" => $arBasket["RESERVED"], "STORE_DATA" => $arStoreBarcodeData));
$arResult["RESULT"] = $res["RESULT"];
if ($res["RESULT"]) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Product #" . $arBasket["PRODUCT_ID"] . " deducted successfully", array(), "DBP3");
}
} else {
$arResult["ERROR"]["PRODUCT_ID"] = $arBasket["PRODUCT_ID"];
if ($ex = $APPLICATION->GetException()) {
$arResult["ERROR"]["MESSAGE"] = $ex->GetString();
$arResult["ERROR"]["CODE"] = $ex->GetID();
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Product #" . $arBasket["PRODUCT_ID"] . " deduction error", array(), "DBP4");
}
}
}
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DeductBasketProduct result", array("arResult" => $arResult), "DBP5");
}
return $arResult;
}
示例8: removeFromCart
static function removeFromCart($id)
{
return true;
$arFields = CSaleBasket::GetByID($id);
$api_key = COption::GetOptionString(self::$MODULE_ID, "tracker_code", '');
if (!$api_key) {
return;
}
$visitor_uid = false;
$visitor_info = false;
if ($arFields["FUSER_ID"] && $arFields["FUSER_ID"] && ($visitor_info = self::getVisitorInfo($arFields["FUSER_ID"]))) {
$visitor_uid = $arFields["FUSER_ID"];
}
$guest_uid = self::getUid($visitor_uid);
$tracker = new ConveadTracker($api_key, SITE_SERVER_NAME, $guest_uid, $visitor_uid, $visitor_info, false, SITE_SERVER_NAME);
$product_id = $arFields["PRODUCT_ID"];
$qnt = $arFields["QUANTITY"];
$product_name = $arFields["NAME"];
$product_url = "http://" . SITE_SERVER_NAME . $arFields["DETAIL_PAGE_URL"];
$price = $arFields["PRICE"];
$result = $tracker->eventRemoveFromCart($product_id, $qnt);
return true;
}