本文整理汇总了PHP中CSaleBasket类的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket类的具体用法?PHP CSaleBasket怎么用?PHP CSaleBasket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSaleBasket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isBarCodeValid
public static function isBarCodeValid($arParams)
{
$bResult = false;
$arBasket = array();
if (intval($arParams["basketItemId"]) > 0) {
$dbBasket = CSaleBasket::GetList(array("ID" => "DESC"), array("ID" => $arParams["basketItemId"]), false, false, array("ID", "PRODUCT_ID", "PRODUCT_PROVIDER_CLASS", "MODULE", "BARCODE_MULTI"));
$arBasket = $dbBasket->GetNext();
} else {
$arBasket = array("PRODUCT_PROVIDER_CLASS" => $arParams["productProvider"], "MODULE" => $arParams["moduleName"], "PRODUCT_ID" => $arParams["productId"], "BARCODE_MULTI" => $arParams["barcodeMult"]);
}
if (!empty($arBasket) && is_array($arBasket)) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$arCheckBarcodeFields = array("BARCODE" => $arParams["barcode"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "ORDER_ID" => $arParams["orderId"]);
if ($arBasket["BARCODE_MULTI"] == "Y") {
$arCheckBarcodeFields["STORE_ID"] = $arParams["storeId"];
}
$res = $productProvider::CheckProductBarcode($arCheckBarcodeFields);
if ($res) {
$bResult = true;
}
}
}
return $bResult;
}
示例2: GetBasketList
function GetBasketList($bSkipFUserInit = true)
{
$fUserID = (int) CSaleBasket::GetBasketUserID($bSkipFUserInit);
$arRes = array();
if ($fUserID > 0) {
$basketID = array();
$db_res = CSaleBasket::GetList(array(), array("FUSER_ID" => $fUserID, "LID" => SITE_ID, "ORDER_ID" => false), false, false, array('ID', 'CALLBACK_FUNC', 'PRODUCT_PROVIDER_CLASS', 'MODULE', 'PRODUCT_ID', 'QUANTITY', 'NOTES'));
while ($res = $db_res->Fetch()) {
$res['CALLBACK_FUNC'] = (string) $res['CALLBACK_FUNC'];
$res['PRODUCT_PROVIDER_CLASS'] = (string) $res['PRODUCT_PROVIDER_CLASS'];
if ($res['CALLBACK_FUNC'] != '' || $res['PRODUCT_PROVIDER_CLASS'] != '') {
CSaleBasket::UpdatePrice($res["ID"], $res["CALLBACK_FUNC"], $res["MODULE"], $res["PRODUCT_ID"], $res["QUANTITY"], 'N', $res["PRODUCT_PROVIDER_CLASS"], $res['NOTES']);
}
$basketID[] = $res['ID'];
}
unset($res, $db_res);
if (!empty($basketID)) {
$basketIterator = CSaleBasket::GetList(array('NAME' => 'ASC'), array('ID' => $basketID));
while ($basket = $basketIterator->GetNext()) {
$arRes[] = $basket;
}
unset($basket, $basketIterator);
}
unset($basketID);
}
return $arRes;
}
示例3: OrderBasket
/**
*
* return array() BasketList - experation - Send Order
**/
public static function OrderBasket($experation = NULL,$sort = array("ID" => "ASC"), $limit = NULL){
global $DB;
$arItems = array();
if(! $experation){
$experation = 30*24*60*60;
}
$time = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), time() - $experation);
$arPages = false;
if(! empty($limit)){
$arPages = array('nTopCount' => $limit);
}
$arFilter = array('>=DATE_UPDATE' => $time,
"ORDER_ID" => true,
"CAN_BUY" => "Y");
$arSelect = array("ID", "USER_ID", "PRODUCT_ID", "CAN_BUY", "DELAY", "SUBSCRIBE", "QUANTITY","DATE_UPDATE","DETAIL_PAGE_URL");
$dbBasketList = CSaleBasket::GetList(
$sort,
$arFilter,
false,
$arPages,
$arSelect
);
while($_arItems = $dbBasketList->Fetch()){
$arItems[] = $_arItems;
}
return $arItems;
}
示例4: AddGoogleAnaliticsEcommerceCode
function AddGoogleAnaliticsEcommerceCode($orderId, $arOrder, $arParams){
global $APPLICATION;
if(isset($_SESSION['GA_ORDER_ID']) && $_SESSION['GA_ORDER_ID'] == $orderId) return;
$gaOutput = array();
$arSite = CSite::GetByID($arOrder['LID'])->Fetch();
$gaOutput[] = "<script>";
$gaOutput[] = "ga('require', 'ecommerce', 'ecommerce.js');";
$gaOutput[] = sprintf(
"ga('ecommerce:addTransaction', {
'id': '%s',
'affiliation': '%s',
'revenue': '%s',
'shipping': '%s',
'tax': ''
});",
$orderId,
$arSite['NAME'],
$arOrder['PRICE'],
$arOrder['PRICE_DELIVERY']
);
$dbBasket = CSaleBasket::GetList(
array("NAME" => "ASC"),
array("ORDER_ID" => $orderId)
);
while($basketItem = $dbBasket->fetch()){
$gaOutput[] = sprintf(
"ga('ecommerce:addItem', {
'id': '%s',
'name': '%s',
'sku': '%s',
'category': '',
'price': '%s',
'quantity': '%s'
});",
$orderId,
$basketItem['NAME'],
$basketItem['PRODUCT_ID'],
$basketItem['PRICE'],
$basketItem['QUANTITY']
);
}
$gaOutput[] = "ga('ecommerce:send');";
$gaOutput[] = "</script>";
$APPLICATION->AddHeadString(implode("\n", $gaOutput), true);
$_SESSION['GA_ORDER_ID'] = $orderId;
}
示例5: 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;
}
示例6: OnBeforeBasketAdd
public static function OnBeforeBasketAdd(array $fields)
{
if (Loader::includeModule('conversion')) {
if ($row = \CSaleBasket::GetList(array(), array('LID' => $fields['LID'], 'FUSER_ID' => $fields['FUSER_ID'], 'PRODUCT_ID' => $fields['PRODUCT_ID'], 'ORDER_ID' => 'NULL'), false, false, array('PRICE', 'QUANTITY'))->Fetch()) {
self::$cartSum = $row['PRICE'] * $row['QUANTITY'];
} else {
self::$cartSum = 0;
}
}
}
示例7: addProductToCart
public function addProductToCart(Product $product, $quantity)
{
Loader::includeModule('sale');
$price = reset($product['PRICES']);
$properties = array();
foreach ($product->getShopParameters() as $name => $value) {
$properties[] = array('NAME' => $name, 'VALUE' => $value);
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
\CSaleBasket::Add(array('PRODUCT_ID' => $product['ID'], 'PRODUCT_PRICE_ID' => $price['ID'], 'PRICE' => $price['PRICE'], 'CURRENCY' => $price['CURRENCY'], 'QUANTITY' => $quantity, 'LID' => SITE_ID, 'NAME' => $product['NAME'], 'NOTES' => $product['DETAIL_TEXT'], 'PROPS' => $properties));
}
示例8: getProductInBasketParams
/**
* Returns quantity of product in current user's basket
*
* @param integer $productID
* @return float
*/
public static function getProductInBasketParams($productID)
{
global $DB;
CModule::IncludeModule('sale');
$id = intval($productID);
$fuserID = CSaleBasket::GetBasketUserID();
$strSql = "SELECT ID, QUANTITY " . "FROM b_sale_basket " . "WHERE PRODUCT_ID = " . $id . " AND FUSER_ID = " . $fuserID . " AND ORDER_ID IS NULL";
$rsBasket = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arBasket = $rsBasket->Fetch()) {
return array("ID" => $arBasket["ID"], "QUANTITY" => floatval($arBasket["QUANTITY"]));
}
return false;
}
示例9: 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;
}
示例10: onGenerateInitialData
public static function onGenerateInitialData(Date $from, Date $to)
{
$data = array();
// 1. Payments
$result = \CSaleOrder::GetList(array(), array('PAYED' => 'Y', 'CANCELED' => 'N', '>=DATE_PAYED' => $from, '<=DATE_PAYED' => $to), false, false, array('LID', 'DATE_PAYED', 'PRICE', 'CURRENCY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_PAYED']);
$sum = Utils::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_payment_add_day'] += 1;
$counters['sale_payment_sum_add'] += $sum;
} else {
$counters = array('sale_payment_add_day' => 1, 'sale_payment_sum_add' => $sum);
}
}
// 2. Orders
$result = \CSaleOrder::GetList(array(), array('CANCELED' => 'N', '>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_INSERT']);
$sum = Utils::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_order_add_day'] += 1;
$counters['sale_order_sum_add'] += $sum;
} else {
$counters = array('sale_order_add_day' => 1, 'sale_order_sum_add' => $sum);
}
}
// 3. Cart
$result = \CSaleBasket::GetList(array(), array('>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY', 'QUANTITY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_INSERT']);
$sum = Utils::convertToBaseCurrency($row['PRICE'] * $row['QUANTITY'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_cart_add_day'] += 1;
$counters['sale_cart_sum_add'] += $sum;
} else {
$counters = array('sale_cart_add_day' => 1, 'sale_cart_sum_add' => $sum);
}
}
// Result
unset($counters);
$result = array();
foreach ($data as $siteId => $dayCounters) {
$result[] = array('ATTRIBUTES' => array('conversion_site' => $siteId), 'DAY_COUNTERS' => $dayCounters);
}
return $result;
}
示例11: getNmuBasket
function getNmuBasket(){
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"ORDER_ID" => "NULL"
),
false,
false,
array()
);
$num=0;
while($basket=$dbBasketItems->Fetch()) $num++;
return $num;
}
示例12: OnBasketChange
public static function OnBasketChange($ID, $arFields = false)
{
if(isset($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]))
{
$num_products = $_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID];
}
else
{
if(!CModule::IncludeModule("sale"))
{
return;
}
$fUserID = CSaleBasket::GetBasketUserID(True);
$fUserID = IntVal($fUserID);
$num_products = 0;
if ($fUserID > 0)
{
$dbRes = CSaleBasket::GetList(
array(),
array(
"FUSER_ID" => $fUserID,
"LID" => SITE_ID,
"ORDER_ID" => "NULL",
"CAN_BUY" => "Y",
"DELAY" => "N",
"SUBSCRIBE" => "N"
)
);
while ($arItem = $dbRes->GetNext())
{
if (!CSaleBasketHelper::isSetItem($arItem))
$num_products++;
}
}
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = intval($num_products);
}
echo "<script>
if (document.getElementById('bx_cart_num'))
document.getElementById('bx_cart_num').innerHTML = '".(($num_products > 0) ? " (".$num_products.")" : "")."';
</script>";
}
示例13: OnSalePayOrder
public static function OnSalePayOrder($ID, $val)
{
$ID = intval($ID);
if ($ID > 0 && $val == 'Y') {
$arOrder = array();
$dbBasketItems = CSaleBasket::GetList(array(), array('ORDER_ID' => $ID), false, false, array('ID', 'MODULE', 'CATALOG_XML_ID', 'QUANTITY'));
while ($arItems = $dbBasketItems->Fetch()) {
if ($arItems['MODULE'] == 'asd.money' && !empty($arItems['CATALOG_XML_ID']) && strpos($arItems['CATALOG_XML_ID'], '@') !== false) {
if (empty($arOrder)) {
$rsOrders = CSaleOrder::GetList(array(), array('ID' => $ID), false, false, array('ID', 'USER_ID'));
$arOrder = $rsOrders->Fetch();
if (empty($arOrder)) {
return;
}
}
list($amount, $curr) = explode('@', $arItems['CATALOG_XML_ID']);
CSaleUserAccount::UpdateAccount($arOrder['USER_ID'], doubleval($amount) * doubleval($arItems['QUANTITY']), $curr, GetMessage('ASD_MODULE_TRANSACT_PREPAID'), $ID);
}
}
}
}
示例14: getProductDataToFillBasket
//.........这里部分代码省略.........
// ratio
$arElementInfo["RATIO"] = 1;
$dbratio = CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
if ($arRatio = $dbratio->Fetch())
$arElementInfo["RATIO"] = $arRatio["RATIO"];
// image
if ($arElementInfo["PREVIEW_PICTURE"] > 0)
$imgCode = $arElementInfo["PREVIEW_PICTURE"];
elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
$imgCode = $arElementInfo["DETAIL_PICTURE"];
if ($imgCode == "" && count($arParent) > 0)
{
if ($arParent["PREVIEW_PICTURE"] > 0)
$imgCode = $arParent["PREVIEW_PICTURE"];
elseif ($arParent["DETAIL_PICTURE"] > 0)
$imgCode = $arParent["DETAIL_PICTURE"];
}
if ($imgCode > 0)
{
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct))
$imgUrl = $arImgProduct["src"];
}
$arSetInfo = array();
$arStores = array();
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
{
// get set items if it is set
if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
{
if (method_exists($productProvider, "GetSetItems"))
{
$arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);
if ($tmpId == "")
$tmpId = randString(7);
if (!empty($arSets))
{
foreach ($arSets as $arSetData)
{
foreach ($arSetData["ITEMS"] as $setItem)
{
$arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call
// re-define some fields with set data values
$arSetItemParams["id"] = $setItem["PRODUCT_ID"];
$arSetItemParams["name"] = $setItem["NAME"];
$arSetItemParams["module"] = $setItem["MODULE"];
$arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
$arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
$arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
$arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
$arSetItemParams["productType"] = $setItem["TYPE"];
$arSetItemParams["weight"] = $setItem["WEIGHT"];
$arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
$arSetItemParams["setItems"] = "";
示例15: obtainBasketProps
public function obtainBasketProps(&$arBasketItems)
{
// prepare some indexes
$arElementIds = array();
// a collection of PRODUCT_IDs and parent PRODUCT_IDs
$arSku2Parent = array();
// a mapping SKU PRODUCT_IDs to PARENT PRODUCT_IDs
$arParents = array();
// also
$arSkuProps = array();
if (self::isNonemptyArray($arBasketItems)) {
foreach ($arBasketItems as &$arItem) {
// get sale properties: which was added with CSaleBasket::Add(array('PROP' => array(...)))
$arItem["PROPS"] = array();
$dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
while ($arProp = $dbProp->GetNext()) {
$arItem["PROPS"][] = $arProp;
}
// catalog-specific logic farther: iblocks, catalogs and other friends
if (!$this->cameFromCatalog($arItem)) {
continue;
}
$arElementIds[] = $arItem["PRODUCT_ID"];
if ($arItem['PARENT']) {
$arElementIds[] = $arItem['PARENT']["ID"];
$arSku2Parent[$arItem["PRODUCT_ID"]] = $arItem['PARENT']["ID"];
$arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"] = $arItem['PARENT']["ID"];
$arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"] = $arItem['PARENT']["IBLOCK_ID"];
}
if (self::isNonemptyArray($arItem['PROPS'])) {
foreach ($arItem['PROPS'] as $prop) {
$arSkuProps[$prop['CODE']] = 1;
}
}
}
$arSkuProps = array_keys($arSkuProps);
// fetching iblock props
$this->obtainBasketPropsElement($arBasketItems, $arElementIds, $arSku2Parent);
// fetching sku props, if any
$this->obtainBasketPropsSKU($arBasketItems, $arSkuProps, $arParents);
}
return $arBasketItems;
}