本文整理匯總了PHP中Add2BasketByProductID函數的典型用法代碼示例。如果您正苦於以下問題:PHP Add2BasketByProductID函數的具體用法?PHP Add2BasketByProductID怎麽用?PHP Add2BasketByProductID使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Add2BasketByProductID函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: AddToBasket
function AddToBasket($pid, $quantity)
{
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
$ar_res = CCatalogProduct::GetByIDEx($pid);
if ($ar_res) {
$result = Add2BasketByProductID($pid, $quantity);
// если ошибки - $ex = $APPLICATION->GetException();
if ($result) {
$arrSendResult['ERROR'] = 'N';
$arrSendResult['TEXT'] = 'OK';
echo json_encode($arrSendResult);
} else {
$arrSendResult['ERROR'] = 'Y';
$arrSendResult['TEXT'] = 'Error';
echo json_encode($arrSendResult);
}
} else {
if (Add2BasketByProductID($pid, $quantity)) {
$arrSendResult['ERROR'] = 'N';
$arrSendResult['TEXT'] = 'OK';
echo json_encode($arrSendResult);
}
}
}
}
示例2: addToBascket
function addToBascket($arItems){
$num = 0;
foreach($arItems as $item){
$tovar=CCatalogProduct::GetByIDEx($item["ID"]);
if(intval($item["COUNT"])<=$tovar["PRODUCT"]["QUANTITY"]&&intval($item["COUNT"])>0){
Add2BasketByProductID($item["ID"],intval($item["COUNT"]));
$num++;
}
}
?>
<script>
$(".CartLink span").text('(<?php
echo $num;
?>
)');
$('body,html').animate({scrollTop: 0}, 2);
</script>
<?
}
示例3: intval
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
/**
* $_GET["action"] = ADD2BASKET or DEL2BASKET or UPDATE2BASKET
* $_GET["QUANTITY"] = count products add on basket
* $_GET["id"] = id product
*/
if (CModule::IncludeModule("catalog") && CModule::IncludeModule("sale")) {
$action = $_GET["action"];
if ($action == "ADD2BASKET") {
$PRODUCT_ID = intval($_GET["id"]);
$QUANTITY = intval($_GET["QUANTITY"]);
if ($action == "ADD2BASKET" && intval($PRODUCT_ID) > 0 && intval($QUANTITY) > 0) {
$arPropItem = getItemCart($arItem["PRODUCT_ID"]);
$arProps = array();
$arProps = array(array("NAME" => "Артикул", "CODE" => "ARTIKUL", "VALUE" => $arPropItem["PROPERTY_ARTIKUL_VALUE"], "SORT" => 100), array("NAME" => "Наличие", "CODE" => "DEPOSIT", "VALUE" => $arPropItem["CATALOG_PROP"]["QUANTITY"] < 2 ? "N" : "Y", "SORT" => 200));
if (!Add2BasketByProductID($PRODUCT_ID, $QUANTITY, array(), $arProps)) {
exit;
}
}
} elseif ($action == "UPDATE2BASKET") {
if (is_array($_GET["items"])) {
foreach ($_GET["items"] as $key => $arItems) {
$PRODUCT_ID = intval($arItems["id"]);
$QUANTITY = intval($arItems["count"]);
$arFields = array("QUANTITY" => $QUANTITY);
if (!CSaleBasket::Update($PRODUCT_ID, $arFields)) {
exit;
}
}
}
} elseif ($action == "DEL2BASKET") {
示例4: define
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
}
if ($_REQUEST["is_ajax_call"] === "y") {
$sid = $_REQUEST['site_id'];
$sid .= "";
define("SITE_ID", $sid);
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php";
include_once 'iblocks.php';
require_once "lang/" . LANGUAGE_ID . "/template.php";
if ($_REQUEST["add2basket_srch"] === "y") {
$APPLICATION->RestartBuffer();
$message = "error";
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
if (Add2BasketByProductID($_REQUEST['id'])) {
$message = GetMessage("INBASKET");
}
}
echo $message;
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
die;
}
}
$save_param = new CPHPCache();
if ($_REQUEST["is_ajax_call"] === "y") {
$lifetime = 60 * 60 * 24;
} else {
$lifetime = $arParams['CACHE_TIME'] ? intval($arParams['CACHE_TIME']) : 60 * 60 * 24;
if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
CPHPCache::Clean("cache_wf_prms" . SITE_ID, "/");
示例5: array
//get props sku
$product_properties = array();
$arPropsSku = array();
$arParentSku = CCatalogSku::GetProductInfo($productID);
if ($arParentSku && count($arParentSku) > 0) {
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $productID), false, false, array('IBLOCK_ID', 'IBLOCK_SECTION_ID'));
$arProduct = $dbProduct->Fetch();
$dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
while ($arOfferProperties = $dbOfferProperties->Fetch()) {
$arPropsSku[] = $arOfferProperties["CODE"];
}
$product_properties = CIBlockPriceTools::GetOfferProperties($productID, $arParentSku["IBLOCK_ID"], $arPropsSku);
}
if (($action == "ADD2BASKET" || $action == "BUY") && $productID > 0) {
if (CModule::IncludeModule('catalog')) {
Add2BasketByProductID($productID, 1, array(), $product_properties);
}
if ($action == "BUY") {
LocalRedirect($arParams["BASKET_URL"]);
} else {
LocalRedirect($APPLICATION->GetCurPageParam("", array($arParams["PRODUCT_ID_VARIABLE"], $arParams["ACTION_VARIABLE"])));
}
}
}
//end add to basket
$arViewed = array();
$arViewedId = array();
$db_res = CSaleViewedProduct::GetList(array("DATE_VISIT" => "DESC"), $arFilter, false, array("nTopCount" => $arParams["VIEWED_COUNT"]), array('ID', 'IBLOCK_ID', 'PRICE', 'CURRENCY', 'CAN_BUY', 'PRODUCT_ID', 'DATE_VISIT', 'DETAIL_PAGE_URL', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'NAME', 'NOTES'));
while ($arItems = $db_res->Fetch()) {
$arViewedId[] = $arItems["PRODUCT_ID"];
$arViewed[$arItems["PRODUCT_ID"]] = $arItems;
示例6: array
$mxResult = CCatalogSku::GetProductInfo($id);
if (is_array($mxResult)) {
$parentid = $mxResult['ID'];
} else {
$parentid = $id;
}
$dbBasketItems = CSaleBasket::GetList(array(), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "DELAY" => 'Y', "LID" => $site, "ORDER_ID" => "NULL"), false, false, array("ID", "PRODUCT_ID"));
while ($arItems = $dbBasketItems->Fetch()) {
$mxResult = CCatalogSku::GetProductInfo($arItems['PRODUCT_ID']);
if (is_array($mxResult) && $mxResult['ID'] == $parentid || $arItems['PRODUCT_ID'] == $parentid) {
CSaleBasket::Delete($arItems['ID']);
$bool = true;
}
}
if (!$bool) {
Add2BasketByProductID($id, 1, array('DELAY' => 'Y'), array());
}
}
} elseif ($action == 'DELETE_FROM_DELAY' && intval($_REQUEST['id']) > 0) {
$dbBasketItems = CSaleBasket::GetList(array(), array("PRODUCT_ID" => $id, "FUSER_ID" => CSaleBasket::GetBasketUserID(), "DELAY" => 'Y', "LID" => $site, "ORDER_ID" => "NULL"), false, false, array("ID"));
if ($arItems = $dbBasketItems->Fetch()) {
CSaleBasket::Delete($arItems['ID']);
}
} elseif ($action == 'DELETEALL_FROM_DELAY') {
$dbBasketItems = CSaleBasket::GetList(array(), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "DELAY" => 'Y', "LID" => $site, "ORDER_ID" => "NULL"), false, false, array("ID"));
while ($arItems = $dbBasketItems->Fetch()) {
CSaleBasket::Delete($arItems['ID']);
}
} elseif ($action == 'DELETEFROMCART' && intval($_REQUEST['id']) > 0) {
$dbBasketItems = CSaleBasket::GetList(array(), array("ID" => $id, "FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => $site, "ORDER_ID" => "NULL"), false, false, array("ID"));
if ($arItems = $dbBasketItems->Fetch()) {
示例7: strtoupper
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
//file_put_contents("test.txt",print_r($_SERVER,true));
$action = strtoupper($_REQUEST["action"]);
$id = intval($_REQUEST["id"]);
$backurl = $_REQUEST["backurl"];
$quantity = doubleval($_REQUEST["quantity"]);
$delay = strtoupper($_REQUEST["delay"]) == "Y" ? true : false;
if ($quantity <= 0) {
$quantity = 1;
}
if (CModule::IncludeModule("catalog")) {
if (($action == "ADD2BASKET" || $action == "BUY") && $id > 0) {
$r_id = Add2BasketByProductID($id, $quantity, array());
if ($delay) {
CSaleBasket::Update($r_id, array("DELAY" => "Y"));
}
// if ajax return some info about cart
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
/* special ajax here */
//header('Content-Type: application/json');
$cntBasketItems = CSaleBasket::GetList(array(), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), array());
echo "{'id': {$r_id} , 'count': {$cntBasketItems}}";
exit(0);
}
if ($action == "BUY") {
LocalRedirect("/personal/cart");
}
if ($backurl) {
LocalRedirect($backurl);
示例8: bxModifySaleMails
//.........這裏部分代碼省略.........
* формируем новый пустой заказ
*/
if(!$i){
if (!$ORDER_ID = CSaleOrder::Add(array(
"LID" => SITE_ID,
"PERSON_TYPE_ID" => 1,
"PAYED" => "N",
"CANCELED" => "N",
"STATUS_ID" => "N",
"PRICE" => 0,
"CURRENCY" => CSaleLang::GetLangCurrency(SITE_ID),
"USER_ID" => $arUser['ID'],
"PAY_SYSTEM_ID" => $arFieldsorder_old['PAY_SYSTEM_ID'],
"PRICE_DELIVERY" => 0,
"DELIVERY_ID" => $arFieldsorder_old['DELIVERY_ID'],
"DISCOUNT_VALUE" => $arFieldsorder_old['DISCOUNT_VALUE'],
"TAX_VALUE" => $arFieldsorder_old['TAX_VALUE'],
"USER_DESCRIPTION" => $post['INFO']
))){
$rows['msg'] = 'Ошибка создания заказа';
$fail = true;
}else{
$rows['msg']=$ORDER_ID;
//continue;
}
}
/**
* добавляем по id заказа в корзину товары партнера
*/
if (!Add2BasketByProductID($item_price['PRODUCT_ID'], $item_price['QUANTITY'], array(
'ORDER_ID' => $ORDER_ID,
), $basket_props)) {
$rows['err'] = 'Ошибка добавления товара в заказ';
$fail = true;
}
/*$price_product+=$item_price['PRICE']*$item_price['QUANTITY'];
$products_descriptions.=$item_price['NAME']." - ".$item_price['QUANTITY']." шт: ".intval($item_price['PRICE'])." руб <br/>";
*/
$i++;
/**
* обновляем параметры нового заказа на актуальные
*/
if($size_of_productpartner==$i){
if (!$fail) {
$dbBasketItems = CSaleBasket::GetList(
array("NAME" => "ASC", "ID" => "ASC"), array(
"LID" => SITE_ID,
"ORDER_ID" => $ORDER_ID
), false, false, array(
"ID", "NAME", "QUANTITY", "CURRENCY", "CAN_BUY", "PRICE", "WEIGHT", "DISCOUNT_PRICE"
)
);
$summ = $weight = 0;
$strOrderList = "";
$arBasket = array();
while ($arBasketItems = $dbBasketItems->GetNext()) {
示例9: Add2BasketByProductID
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
?>
<?php
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// Если к нам идёт Ajax запрос, то ловим его
if (isset($_POST["ajax_filter"]) && $_POST["ajax_filter"] == "y") {
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
Add2BasketByProductID($_POST["productId"], 1, array());
$arBasketItems = array();
$productsCount = 0;
$dbBasketItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "QUANTITY", "PRICE"));
while ($arItems = $dbBasketItems->Fetch()) {
if (strlen($arItems["CALLBACK_FUNC"]) > 0) {
CSaleBasket::UpdatePrice($arItems["ID"], $arItems["QUANTITY"]);
$arItems = CSaleBasket::GetByID($arItems["ID"]);
}
$arBasketItems[] = $arItems;
}
$productsCount = count($arBasketItems);
$summ = 0;
for ($i = 0; $i <= $productsCount; $i++) {
$summ = $summ + $arBasketItems[$i]["PRICE"] * $arBasketItems[$i]["QUANTITY"];
}
// Склонение "товаров"
$goods_title = declOfNum($productsCount, array('товар', 'товара', 'товаров'));
?>
<span class="hc-icon"><i class="icon-cart"></i></span><span class="hidden-xs">В корзине</span> <b><?php
echo $productsCount;
示例10: AddProduct
public static function AddProduct ($idProduct, $quantity, $arRewriteFields, $arProductParams, $userId, $currency, $personType, $clearCart) {
if (CModule::IncludeModule("catalog")) {
global $DB;
global $USER;
if ($clearCart == "Y" && (int)$idProduct > 0) {
CSaleBasket::DeleteAll(CSaleBasket::GetBasketUserID());
}
if (Add2BasketByProductID( $idProduct, $quantity, $arRewriteFields, $arProductParams)) { // В корзину
// Получаю параметры корзины
$dbBasketItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "ORDER_ID" => "NULL"), false, false, array("ID", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "NAME"));
while ($arItems = $dbBasketItems->Fetch()) {
$arBasketItems[] = $arItems;
}
foreach ($arBasketItems as $valBasketItems) {
$productPriceSumm = $productPriceSumm + ((int)$valBasketItems["QUANTITY"]*(int)$valBasketItems["PRICE"]);
}
$strOrderList = "";
foreach ($arBasketItems as $arItem)
{
$measureText = (isset($arItem["MEASURE_TEXT"]) && strlen($arItem["MEASURE_TEXT"])) ? $arItem["MEASURE_TEXT"] : GetMessage("SOA_SHT");
$strOrderList .= $arItem["NAME"]." - ".$arItem["QUANTITY"]." ".$measureText.": ".SaleFormatCurrency($arItem["PRICE"], $arItem["CURRENCY"]);
$strOrderList .= "\n";
}
// Создаю заказ
$arOrderFields = array(
"LID" => SITE_ID,
"PERSON_TYPE_ID" => $personType,
"PAYED" => "N",
"CANCELED" => "N",
"STATUS_ID" => "N",
"PRICE" => $productPriceSumm,
"CURRENCY" => $currency,
"USER_ID" => $userId,
"USER_DESCRIPTION" => "",
"ADDITIONAL_INFO" => ""
);
$ORDER_ID = CSaleOrder::Add($arOrderFields);
// Привязываем товары из корзины текущего пользователя к заказу
CSaleBasket::OrderBasket($ORDER_ID, CSaleBasket::GetBasketUserID(), SITE_ID, false);
$rsUser = CUser::GetByID($userId);
$arUser = $rsUser->Fetch();
$arFields = Array(
"ORDER_ID" => $ORDER_ID,
"ORDER_DATE" => Date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT", SITE_ID))),
"ORDER_USER" => $arUser["NAME"],
"PRICE" => $productPriceSumm,
"BCC" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME),
"EMAIL" => (strlen($arUserResult["USER_EMAIL"])>0 ? $arUserResult["USER_EMAIL"] : $USER->GetEmail()),
"ORDER_LIST" => $strOrderList,
"SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME),
);
$eventName = "SALE_NEW_ORDER";
$event = new CEvent;
$event->Send($eventName, SITE_ID, $arFields, "N");
return $ORDER_ID;
}
} else {
return false;
}
}
示例11: htmlspecialcharsEx
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
CModule::IncludeModule('sale');
CModule::IncludeModule('catalog');
$cmd = htmlspecialcharsEx($_POST['action']);
$elementId = intval($_POST['id']);
$count = intval($_POST['quantity']);
//Add functional
if ($elementId && $cmd == 'ADD2BASKET') {
if ($count) {
$res = Add2BasketByProductID($elementId, $count, array());
} else {
$res = Add2BasketByProductID($elementId, 1, array());
}
}
//Delete functional
/*if($elementId && $cmd == 'delete'){
$res = CSaleBasket::Delete($elementId);
}
//Update functional
if($elementId && $count && $cmd == 'update'){
$arFields = array(
'QUANTITY' => $count
);
$res = CSaleBasket::Update($elementId, $arFields);
}*/
$APPLICATION->IncludeComponent("bitrix:sale.basket.basket.small", "basket_top", array("PATH_TO_BASKET" => "/personal/basket.php", "PATH_TO_ORDER" => "/personal/order.php", "SHOW_DELAY" => "Y", "SHOW_NOTAVAIL" => "Y", "SHOW_SUBSCRIBE" => "Y"), false);
?>
示例12: strtolower
<?
if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'))
{
header('HTTP/1.0 403 Forbidden');
die();
}
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
global $APPLICATION;
$productId = intval($_POST['PRODUCT_ID']);
$quantity = intval($_POST['QUANTITY']);
if ($productId > 0 && \Bitrix\Main\Loader::includeModule("sale") && \Bitrix\Main\Loader::includeModule("catalog") && $quantity >= 1)
{
if(!Add2BasketByProductID($productId, $quantity, $arRewriteFields, $product_properties))
{
if ($ex = $APPLICATION->GetException())
{
$strError = $ex->GetString();
}
}
}
$APPLICATION->IncludeComponent("bitrix:sale.basket.basket.small","small",Array(
"PATH_TO_BASKET" => "/basket/",
"PATH_TO_ORDER" => "/basket/order.php",
"SHOW_DELAY" => "Y",
"SHOW_NOTAVAIL" => "Y",
"SHOW_SUBSCRIBE" => "Y"
)
);
示例13: orderHistory
//.........這裏部分代碼省略.........
unset($r['BASKET_ID']);
$p['PROPS'][] = $r;
}
}
$arProduct = array();
if (isset($item['created']) && $item['created'] == true) {
$productPrice = GetCatalogProductPrice($item['offer']['externalId'], COption::GetOptionString(self::$MODULE_ID, self::$CRM_CATALOG_BASE_PRICE, 0));
$arProduct = array('FUSER_ID' => $userId, 'ORDER_ID' => $order['externalId'], 'QUANTITY' => $item['quantity'], 'CURRENCY' => $productPrice['CURRENCY'], 'LID' => $LID, 'PRODUCT_ID' => $item['offer']['externalId'], 'PRODUCT_PRICE_ID' => $p['PRODUCT_PRICE_ID'], 'WEIGHT' => $p['WEIGHT'], 'DELAY' => $p['DELAY'], 'CAN_BUY' => $p['CAN_BUY'], 'MODULE' => $p['MODULE'], 'NOTES' => $item['comment'] ?: $p['NOTES'], 'PRODUCT_PROVIDER_CLASS' => $p['PRODUCT_PROVIDER_CLASS'], 'DETAIL_PAGE_URL' => $p['DETAIL_PAGE_URL'], 'CATALOG_XML_ID' => $p['CATALOG_XML_ID'], 'PRODUCT_XML_ID' => $p['PRODUCT_XML_ID'], 'CUSTOM_PRICE' => 'Y');
}
if (isset($item['isCanceled']) == false) {
if (isset($item['initialPrice']) && $item['initialPrice']) {
$arProduct['PRICE'] = (double) $item['initialPrice'];
}
if (isset($item['discount'])) {
$arProduct['DISCOUNT_PRICE'] = $item['discount'];
}
if (isset($item['discountPercent'])) {
$arProduct['DISCOUNT_VALUE'] = $item['discountPercent'];
$newPrice = round($arProduct['PRICE'] / 100 * (100 - $arProduct['DISCOUNT_VALUE']), 2);
$arProduct['DISCOUNT_PRICE'] = $arProduct['DISCOUNT_PRICE'] + $arProduct['PRICE'] - $newPrice;
}
if (isset($item['discount']) || isset($item['discountPercent'])) {
$arProduct['PRICE'] -= $arProduct['DISCOUNT_PRICE'];
}
if (isset($item['offer']['name']) && $item['offer']['name']) {
$arProduct['NAME'] = self::fromJSON($item['offer']['name']);
}
$arProduct = self::updateCancelProp($arProduct, 0);
} elseif (isset($item['isCanceled'])) {
$arProduct['PRICE'] = 0;
$arProduct = self::updateCancelProp($arProduct, 1);
}
if (isset($item['created']) && $item['created'] == true) {
if (!Add2BasketByProductID($item['offer']['externalId'], $item['quantity'], $arProduct, $p['PROPS'])) {
self::eventLog('ICrmOrderActions::orderHistory', 'Add2BasketByProductID', 'Error element add');
}
continue;
}
if (count($p['PROPS']) > 0) {
$arProduct['PROPS'] = $p['PROPS'];
}
if (isset($item['quantity']) && $item['quantity']) {
$arProduct['QUANTITY'] = $item['quantity'];
}
if (isset($item['offer']['name']) && $item['offer']['name']) {
$arProduct['NAME'] = self::fromJSON($item['offer']['name']);
}
if (!CSaleBasket::Update($p['ID'], $arProduct)) {
self::eventLog('ICrmOrderActions::orderHistory', 'CSaleBasket::Update', 'Error element update');
}
CSaleBasket::DeleteAll($userId);
} else {
$arProduct = array();
if (isset($item['created']) && $item['created'] == true) {
$arProduct = array('FUSER_ID' => $userId, 'ORDER_ID' => $order['externalId'], 'LID' => $LID, 'NOTES' => $item['comment']);
}
if (isset($item['isCanceled']) == false) {
if (isset($item['initialPrice']) && $item['initialPrice']) {
$arProduct['PRICE'] = (double) $item['initialPrice'];
}
if (isset($item['discount'])) {
$arProduct['DISCOUNT_PRICE'] = $item['discount'];
}
if (isset($item['discountPercent'])) {
$arProduct['DISCOUNT_VALUE'] = $item['discountPercent'];
$newPrice = round($arProduct['PRICE'] / 100 * (100 - $arProduct['DISCOUNT_VALUE']), 2);
示例14: intval
//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;
}
$APPLICATION->IncludeComponent("bitrix:sale.basket.basket.small", "hiding_basket", array("PATH_TO_BASKET" => "/personal/basket.php", "PATH_TO_ORDER" => "/personal/order.php", "SHOW_DELAY" => "Y", "SHOW_NOTAVAIL" => "Y", "SHOW_SUBSCRIBE" => "Y"), false);
示例15: Add2BasketByProductID
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
?>
<?php
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
/* Addition of the goods in a basket at addition in a basket */
if ($_POST["ajaxaddid"] && $_POST["ajaxaction"] == 'add') {
Add2BasketByProductID($_POST["ajaxaddid"], 1, array());
$arFields = array("QUANTITY" => $_POST["ajaxbasketcount"]);
CSaleBasket::Update($_POST["ajaxbasketcountid"], $arFields);
}
/* Changes of quantity of the goods after receipt of inquiry from a small basket */
if ($_POST["ajaxbasketcountid"] && $_POST["ajaxbasketcount"] && $_POST["ajaxaction"] == 'update') {
$arFields = array("QUANTITY" => $_POST["ajaxbasketcount"]);
CSaleBasket::Update($_POST["ajaxbasketcountid"], $arFields);
}
?>
<?php
$APPLICATION->IncludeComponent("bitrix:sale.basket.basket.line", "agray_basket_line_template", array("COMPONENT_TEMPLATE" => ".default", "PATH_TO_BASKET" => SITE_DIR . "personal/cart/", "PATH_TO_PERSONAL" => SITE_DIR . "personal/", "PATH_TO_PROFILE" => SITE_DIR . "personal/", "PATH_TO_REGISTER" => SITE_DIR . "login/", "POSITION_FIXED" => "N", "SHOW_AUTHOR" => "N", "SHOW_EMPTY_VALUES" => "Y", "SHOW_NUM_PRODUCTS" => "Y", "SHOW_PERSONAL_LINK" => "N", "SHOW_PRODUCTS" => "N", "SHOW_TOTAL_PRICE" => "Y"));
?>