本文整理汇总了PHP中CSaleOrderPropsValue::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrderPropsValue::Add方法的具体用法?PHP CSaleOrderPropsValue::Add怎么用?PHP CSaleOrderPropsValue::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrderPropsValue
的用法示例。
在下文中一共展示了CSaleOrderPropsValue::Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddOrderProperty
function AddOrderProperty($prop_id, $value, $order)
{
if (!strlen($prop_id)) {
return false;
}
if (CModule::IncludeModule('sale')) {
if ($arOrderProps = CSaleOrderProps::GetByID($prop_id)) {
$db_vals = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $order, 'ORDER_PROPS_ID' => $arOrderProps['ID']));
if ($arVals = $db_vals->Fetch()) {
return CSaleOrderPropsValue::Update($arVals['ID'], array('NAME' => $arVals['NAME'], 'CODE' => $arVals['CODE'], 'ORDER_PROPS_ID' => $arVals['ORDER_PROPS_ID'], 'ORDER_ID' => $arVals['ORDER_ID'], 'VALUE' => $value));
} else {
return CSaleOrderPropsValue::Add(array('NAME' => $arOrderProps['NAME'], 'CODE' => $arOrderProps['CODE'], 'ORDER_PROPS_ID' => $arOrderProps['ID'], 'ORDER_ID' => $order, 'VALUE' => $value));
}
}
}
}
示例2: bxModifySaleMails
//.........这里部分代码省略.........
$delivery_sum = null;
$arSelect2 = Array("ID", "IBLOCK_ID", "NAME","PROPERTY_*");
$arFilter2 = Array("IBLOCK_ID"=>9, "ACTIVE"=>"Y","ID"=>$id_partner,);
$res2 = CIBlockElement::GetList(Array(), $arFilter2, false, false, $arSelect2);
/**
* eсли в выборке корзине в продуктах больше чем один партнер
* то разбиваем заказ по количеству партнеров
*/
if (intval($res2->SelectedRowsCount())>0){
while($ob2 = $res2->GetNextElement()){
$arFields_partners = $ob2->GetFields();
$arProperties_partners = $ob2->GetProperties();
//_debug($arProperties_partners);
//$price_product=0;
//$products_descriptions="";
$arEventFields=array();
//echo $arFields_partners['ID'];
if($partner_product[$arFields_partners['ID']]){
$i=0;
$size_of_productpartner=sizeof($partner_product[$arFields_partners['ID']]);
foreach($partner_product[$arFields_partners['ID']] as $key_price=>$item_price){
//_debug($item_price);
$quantity=1;
/**
* формируем новый пустой заказ
*/
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;
示例3: __MakeOrder
function __MakeOrder($prdCnt=1, $arData = Array())
{
global $APPLICATION, $USER, $DB;
CModule::IncludeModule("iblock");
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
$arPrd = Array();
$dbItem = CIBlockElement::GetList(Array("PROPERTY_MORE_PHOTO" => "DESC", "ID" => "ASC"), Array("IBLOCK_TYPE" => "offers", "IBLOCK_SITE_ID" => WIZARD_SITE_ID, "PROPERTY_NEWPRODUCT" => false), false, Array("nTopCount" => 10), Array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL", "IBLOCK_XML_ID"));
while($arItem = $dbItem->GetNext())
$arPrd[] = $arItem;
if(!empty($arPrd))
{
for($i=0; $i<$prdCnt;$i++)
{
$prdID = $arPrd[mt_rand(0, 9)];
$arProduct = CCatalogProduct::GetByID($prdID["ID"]);
$CALLBACK_FUNC = "";
$arCallbackPrice = CSaleBasket::ReReadPrice($CALLBACK_FUNC, "catalog", $prdID["ID"], 1);
$arFields = array(
"PRODUCT_ID" => $prdID["ID"],
"PRODUCT_PRICE_ID" => $arCallbackPrice["PRODUCT_PRICE_ID"],
"PRICE" => $arCallbackPrice["PRICE"],
"CURRENCY" => $arCallbackPrice["CURRENCY"],
"WEIGHT" => $arProduct["WEIGHT"],
"QUANTITY" => 1,
"LID" => WIZARD_SITE_ID,
"DELAY" => "N",
"CAN_BUY" => "Y",
"NAME" => $prdID["NAME"],
"CALLBACK_FUNC" => $CALLBACK_FUNC,
"MODULE" => "catalog",
"PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider",
"ORDER_CALLBACK_FUNC" => "",
"CANCEL_CALLBACK_FUNC" => "",
"PAY_CALLBACK_FUNC" => "",
"DETAIL_PAGE_URL" => $prdID["DETAIL_PAGE_URL"],
"CATALOG_XML_ID" => $prdID["IBLOCK_XML_ID"],
"PRODUCT_XML_ID" => $prdID["XML_ID"],
"VAT_RATE" => $arCallbackPrice['VAT_RATE'],
);
$addres = CSaleBasket::Add($arFields);
}
$arOrder = Array(
"LID" => $arData["SITE_ID"],
"PERSON_TYPE_ID" => $arData["PERSON_TYPE_ID"],
"PAYED" => "N",
"CANCELED" => "N",
"STATUS_ID" => "N",
"PRICE" => 1,
"CURRENCY" => $arData["CURRENCY"],
"USER_ID" => $arData["USER_ID"],
"PAY_SYSTEM_ID" => $arData["PAY_SYSTEM_ID"],
//"PRICE_DELIVERY" => $arData["PRICE_DELIVERY"],
//"DELIVERY_ID" => $arData["DELIVERY_ID"],
);
$dbFUserListTmp = CSaleUser::GetList(array("USER_ID" => $arData["USER_ID"]));
if(empty($dbFUserListTmp))
{
$arFields = array(
"=DATE_INSERT" => $DB->GetNowFunction(),
"=DATE_UPDATE" => $DB->GetNowFunction(),
"USER_ID" => $arData["USER_ID"]
);
$ID = CSaleUser::_Add($arFields);
}
$orderID = CSaleOrder::Add($arOrder);
CSaleBasket::OrderBasket($orderID, CSaleBasket::GetBasketUserID(), WIZARD_SITE_ID);
$dbBasketItems = CSaleBasket::GetList(
array("NAME" => "ASC"),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => WIZARD_SITE_ID,
"ORDER_ID" => $orderID
),
false,
false,
array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "NAME")
);
$ORDER_PRICE = 0;
while ($arBasketItems = $dbBasketItems->GetNext())
{
$ORDER_PRICE += roundEx($arBasketItems["PRICE"], SALE_VALUE_PRECISION) * DoubleVal($arBasketItems["QUANTITY"]);
}
$totalOrderPrice = $ORDER_PRICE + $arData["PRICE_DELIVERY"];
CSaleOrder::Update($orderID, Array("PRICE" => $totalOrderPrice));
foreach($arData["PROPS"] as $val)
{
$arFields = Array(
"ORDER_ID" => $orderID,
"ORDER_PROPS_ID" => $val["ID"],
"NAME" => $val["NAME"],
"CODE" => $val["CODE"],
"VALUE" => $val["VALUE"],
//.........这里部分代码省略.........
示例4: DoSaveOrderProps
static function DoSaveOrderProps($orderId, $personTypeId, $arOrderProps, &$arErrors)
{
$arIDs = array();
$dbResult = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "ORDER_PROPS_ID"));
while ($arResult = $dbResult->Fetch()) {
$arIDs[$arResult["ORDER_PROPS_ID"]] = $arResult["ID"];
}
$dbOrderProperties = CSaleOrderProps::GetList(array("SORT" => "ASC"), array("PERSON_TYPE_ID" => $personTypeId, "ACTIVE" => "Y"), false, false, array("ID", "TYPE", "NAME", "CODE", "USER_PROPS", "SORT"));
while ($arOrderProperty = $dbOrderProperties->Fetch()) {
$curVal = $arOrderProps[$arOrderProperty["ID"]];
if ($arOrderProperty["TYPE"] == "MULTISELECT" && is_array($curVal)) {
$curVal = implode(",", $curVal);
}
if (strlen($curVal) > 0) {
$arFields = array("ORDER_ID" => $orderId, "ORDER_PROPS_ID" => $arOrderProperty["ID"], "NAME" => $arOrderProperty["NAME"], "CODE" => $arOrderProperty["CODE"], "VALUE" => $curVal);
if (array_key_exists($arOrderProperty["ID"], $arIDs)) {
CSaleOrderPropsValue::Update($arIDs[$arOrderProperty["ID"]], $arFields);
unset($arIDs[$arOrderProperty["ID"]]);
} else {
CSaleOrderPropsValue::Add($arFields);
}
}
}
foreach ($arIDs as $id) {
CSaleOrderPropsValue::Delete($id);
}
}
示例5: DoSaveOrderProps
static function DoSaveOrderProps($orderId, $personTypeId, $arOrderProps, &$arErrors, $paysystemId = 0, $deliveryId = "")
{
$arIDs = array();
$dbResult = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "ORDER_PROPS_ID"));
while ($arResult = $dbResult->Fetch()) {
$arIDs[$arResult["ORDER_PROPS_ID"]] = $arResult["ID"];
}
$arFilter = array("PERSON_TYPE_ID" => $personTypeId, "ACTIVE" => "Y");
if ($paysystemId != 0) {
$arFilter["RELATED"]["PAYSYSTEM_ID"] = $paysystemId;
$arFilter["RELATED"]["TYPE"] = "WITH_NOT_RELATED";
}
if (strlen($deliveryId) > 0) {
$arFilter["RELATED"]["DELIVERY_ID"] = $deliveryId;
$arFilter["RELATED"]["TYPE"] = "WITH_NOT_RELATED";
}
$dbOrderProperties = CSaleOrderProps::GetList(array("SORT" => "ASC"), $arFilter, false, false, array("ID", "TYPE", "NAME", "CODE", "USER_PROPS", "SORT"));
while ($arOrderProperty = $dbOrderProperties->Fetch()) {
$curVal = $arOrderProps[$arOrderProperty["ID"]];
if ($arOrderProperty["TYPE"] == "MULTISELECT" && is_array($curVal)) {
$curVal = implode(",", $curVal);
}
if ($arOrderProperty["TYPE"] == "FILE" && is_array($curVal)) {
$tmpVal = "";
foreach ($curVal as $index => $fileData) {
$bModify = true;
if (isset($fileData["file_id"])) {
if (isset($fileData["del"])) {
$arFile = CFile::MakeFileArray($fileData["file_id"]);
$arFile["del"] = $fileData["del"];
$arFile["old_file"] = $fileData["file_id"];
} else {
$bModify = false;
if (strlen($tmpVal) > 0) {
$tmpVal .= ", " . $fileData["file_id"];
} else {
$tmpVal = $fileData["file_id"];
}
}
} else {
// new file array
$arFile = $fileData;
}
if (isset($arFile["name"]) && strlen($arFile["name"]) > 0 && $bModify) {
$arFile["MODULE_ID"] = "sale";
$fid = CFile::SaveFile($arFile, "sale");
if (intval($fid) > 0) {
if (strlen($tmpVal) > 0) {
$tmpVal .= ", " . $fid;
} else {
$tmpVal = $fid;
}
}
}
}
$curVal = $tmpVal;
}
if (strlen($curVal) > 0) {
$arFields = array("ORDER_ID" => $orderId, "ORDER_PROPS_ID" => $arOrderProperty["ID"], "NAME" => $arOrderProperty["NAME"], "CODE" => $arOrderProperty["CODE"], "VALUE" => $curVal);
if (array_key_exists($arOrderProperty["ID"], $arIDs)) {
CSaleOrderPropsValue::Update($arIDs[$arOrderProperty["ID"]], $arFields);
unset($arIDs[$arOrderProperty["ID"]]);
} else {
CSaleOrderPropsValue::Add($arFields);
}
}
}
foreach ($arIDs as $id) {
CSaleOrderPropsValue::Delete($id);
}
}
示例6: array
if ($arOrderProperties["TYPE"] == "CHECKBOX" && strlen($curVal) <= 0 && $arOrderProperties["REQUIED"] != "Y")
{
$curVal = "N";
}
if (strlen($curVal) > 0)
{
$arFields = array(
"ORDER_ID" => $arResult["ORDER_ID"],
"ORDER_PROPS_ID" => $arOrderProperties["ID"],
"NAME" => $arOrderProperties["NAME"],
"CODE" => $arOrderProperties["CODE"],
"VALUE" => $curVal
);
CSaleOrderPropsValue::Add($arFields);
if ( $arOrderProperties["USER_PROPS"] == "Y" && IntVal($arUserResult["PROFILE_ID"])<=0 && IntVal($arUserResult["PROFILE_ID_new"])<=0)
{
if (strlen($arUserResult["PROFILE_NAME"]) <= 0)
$arUserResult["PROFILE_NAME"] = GetMessage("SOA_PROFILE")." ".Date("Y-m-d");
$arFields = array(
"NAME" => $arUserResult["PROFILE_NAME"],
"USER_ID" => IntVal($USER->GetID()),
"PERSON_TYPE_ID" => $arUserResult["PERSON_TYPE_ID"]
);
$arUserResult["PROFILE_ID_new"] = CSaleOrderUserProps::Add($arFields);
$arUserResult["PROFILE_ID_new"] = IntVal($arUserResult["PROFILE_ID_new"]);
}
示例7: str_replace
} else {
$errorMessage .= str_replace("#NAME#", $arTaxList[$j]["TAX_NAME"], GetMessage("SOE_ERROR_SAVE_TAX")) . ". ";
}
}
}
}
foreach ($arOldTaxList as $key => $value) {
CSaleOrderTax::Delete($key);
}
}
if (strlen($errorMessage) <= 0) {
for ($i = 0; $i < count($arIDs); $i++) {
CSaleOrderPropsValue::DeleteByOrder($arIDs[$i]);
for ($j = 0; $j < count($arPropsList); $j++) {
$arFields = array("ORDER_ID" => $arIDs[$i], "ORDER_PROPS_ID" => $arPropsList[$j]["ORDER_PROPS_ID"], "NAME" => $arPropsList[$j]["NAME"], "CODE" => $arPropsList[$j]["CODE"], "VALUE" => $arPropsList[$j]["VALUE"]);
$res = CSaleOrderPropsValue::Add($arFields) > 0;
if (!$res) {
if ($ex = $APPLICATION->GetException()) {
$errorMessage .= $ex->GetString();
} else {
$errorMessage .= str_replace("#NAME#", $arPropsList[$j]["NAME"], GetMessage("SOE_ERROR_SAVE_PROP")) . ". ";
}
}
}
}
}
if (strlen($errorMessage) <= 0) {
if (!$customTabber->Action()) {
if ($ex = $APPLICATION->GetException()) {
$errorMessage .= $ex->GetString();
} else {
示例8: array
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("sale");
if (isset($_GET['order_basket'])) {
$dbBasketItems = CSaleBasket::GetList(false, array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "QUANTITY", "PRICE"));
$price = 0;
while ($item = $dbBasketItems->Fetch()) {
$price += intval($item['QUANTITY']) * $item['PRICE'];
}
$arFields = array("LID" => 's1', "PERSON_TYPE_ID" => 1, "PAYED" => "N", "CANCELED" => "N", "STATUS_ID" => "N", "PRICE" => $price, "CURRENCY" => "RUB", "USER_ID" => intval($USER->GetId()), "PAY_SYSTEM_ID" => 1, "USER_DESCRIPTION" => "");
$orderId = CSaleOrder::Add($arFields);
if (false === $orderId) {
return false;
}
$user = CUser::GetByID($USER->GetId())->Fetch();
$ar = array('ORDER_ID' => $orderId, 'ORDER_PROPS_ID' => 2, "NAME" => "Адрес доставки", "CODE" => "delivery_address", 'VALUE' => $user['PERSONAL_STREET']);
CSaleOrderPropsValue::Add($ar);
CSaleBasket::OrderBasket($orderId, $_SESSION["SALE_USER_ID"], SITE_ID);
$tmp = explode(',', $user['NAME']);
$eventFields = array('NAME' => $tmp[0], 'EMAIL' => $user['EMAIL']);
$eventName = $user['PERSONAL_CITY'] == 'Москва' ? 'NEW_ORDER_MOSCOW' : 'NEW_ORDER_RUSSIA';
CEvent::Send($eventName, 's1', $eventFields);
CEvent::Send('NEW_ORDER_ADMIN', 's1', array());
return true;
}
示例9: NextPayment
//.........这里部分代码省略.........
{
$arTaxSums[$arTaxList[$di]["TAX_ID"]]["VALUE"] = $arTaxList[$di]["VALUE_MONEY"];
$arTaxSums[$arTaxList[$di]["TAX_ID"]]["NAME"] = $arTaxList[$di]["NAME"];
if ($arTaxList[$di]["IS_IN_PRICE"] != "Y")
{
$taxPrice += $arTaxList[$di]["VALUE_MONEY"];
}
}
}
else
{
$arTaxList[0]["VALUE_MONEY"] = (($discountPrice / ($vatRate +1)) * $vatRate) * DoubleVal($arProduct["QUANTITY"]);
$taxVatPrice = $arTaxList[0]["VALUE_MONEY"];
}
}
// Changed by Sigurd, 2007-08-16
$totalOrderPrice = $discountPrice * DoubleVal($arProduct["QUANTITY"]) + $deliveryPrice + $taxPrice;
$arProduct["WITHOUT_ORDER"] = (($arProduct["WITHOUT_ORDER"]=="Y") ? "Y" : "N");
if ($arProduct["WITHOUT_ORDER"] == "N")
{
$DB->StartTransaction();
// Saving
$arSaleUser = CSaleUser::GetList(Array(), Array("USER_ID" => $arOrder["USER_ID"]));
if(!empty($arSaleUser))
{
$currentFUser = $arSaleUser["ID"];
}
else
{
$currentFUser = CSaleUser::_Add(
array(
"=DATE_INSERT" => $DB->GetNowFunction(),
"=DATE_UPDATE" => $DB->GetNowFunction(),
"USER_ID" => $arOrder["USER_ID"]
)
);
}
$arFields = array(
"FUSER_ID" => $currentFUser,
"PRODUCT_ID" => $arProduct["PRODUCT_ID"],
"PRODUCT_NAME" => $arProduct["PRODUCT_NAME"],
"PRODUCT_URL" => $arProduct["PRODUCT_URL"],
"PRODUCT_PRICE_ID" => $arProduct["PRODUCT_PRICE_ID"],
"PRICE" => $arProduct["PRICE"],
"CURRENCY" => $arProduct["CURRENCY"],
"WEIGHT" => $arProduct["WEIGHT"],
"QUANTITY" => $arProduct["QUANTITY"],
"LID" => $arOrder["LID"],
"DELAY" => "N",
"CAN_BUY" => "Y",
"NAME" => $arProduct["NAME"],
"CALLBACK_FUNC" => $arProduct["CALLBACK_FUNC"],
"ORDER_CALLBACK_FUNC" => $arProduct["ORDER_CALLBACK_FUNC"],
"CANCEL_CALLBACK_FUNC" => $arProduct["CANCEL_CALLBACK_FUNC"],
"PAY_CALLBACK_FUNC" => $arProduct["PAY_CALLBACK_FUNC"],
"PRODUCT_PROVIDER_CLASS" => $arProduct["PRODUCT_PROVIDER_CLASS"],
"MODULE" => $arRecur["MODULE"],
"NOTES" => $arProduct["CATALOG_GROUP_NAME"],
"DETAIL_PAGE_URL" => $arProduct["DETAIL_PAGE_URL"],
"VATE_RATE" => $arProduct["VATE_RATE"],
"PRODUCT_XML_ID" => $arProduct["PRODUCT_XML_ID"],
示例10: array
foreach ($order_props as $prop) {
$props4[] = 'ORDER_PROP_'.$prop['ORDER_PROPS_ID'] . ' || ' . $code;
if ('ORDER_PROP_'.$prop['ORDER_PROPS_ID'] == $code) {
$is_code_found = true;
$props2[] = $prop['VALUE'] . ' | ' . $json['order'][$v];
if ($prop['VALUE'] != $json['order'][$v]) {
if (CSaleOrderPropsValue::Update($prop['ID'], array("ORDER_ID" => $order['ID'], "VALUE" => $json['order'][$v]))) {
$message[] = 'order prop '.$v.' is updated';
} else { $error[] = 'could not update order property for '.$v; }
}
}
}
if (!$is_code_found && $json['order'][$v] && $new_prop_id = intVal(str_replace("ORDER_PROP_", "", $code))) {
$new_prop_res = CSaleOrderProps::GetList(array(), array("ID" => $new_prop_id));
if ($new_prop_ar = $new_prop_res->Fetch()) {
if ($new_prop_add_result = CSaleOrderPropsValue::Add(array("ORDER_ID" => $order['ID'], "ORDER_PROPS_ID" => $new_prop_id, "VALUE" => $json['order'][$v], "NAME" => $new_prop_ar['NAME'], "CODE" => $new_prop_ar['CODE']))) {
$message[] = 'order prop '.$v.' is added';
} else { $error[] = 'could not add order property for '.$v; }
}
}
}
if ($order['USER_DESCRIPTION'] != $json['order']['comments']) {
if (CSaleOrder::Update($order['ID'], array('USER_DESCRIPTION' => $json['order']['comments']), true)) {
$message[] = 'order user_description is updated';
} else { $error[] = 'could not update order user_description'; }
}
/*
foreach ($json['order']['goods'] as $good) {
$goods[$good['shop_good_code']] = $good;
示例11: __MakeOrder
function __MakeOrder($prdCnt = 1, $arData = array())
{
global $APPLICATION, $USER, $DB;
CModule::IncludeModule("iblock");
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
$arPrd = array();
$dbItem = CIBlockElement::GetList(array(), array("IBLOCK_TYPE" => "offers", "IBLOCK_SITE_ID" => WIZARD_SITE_ID, "PROPERTY_NEWPRODUCT" => false), false, array("nTopCount" => 100), array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL", "IBLOCK_XML_ID"));
while ($arItem = $dbItem->GetNext()) {
$arPrd[] = $arItem;
}
if (!empty($arPrd)) {
$arOrder = array("LID" => $arData["SITE_ID"], "PERSON_TYPE_ID" => $arData["PERSON_TYPE_ID"], "PAYED" => "N", "CANCELED" => "N", "STATUS_ID" => "N", "PRICE" => 1, "CURRENCY" => $arData["CURRENCY"], "USER_ID" => $arData["USER_ID"], "PAY_SYSTEM_ID" => $arData["PAY_SYSTEM_ID"]);
$fuserID = 0;
$dbFUserListTmp = CSaleUser::GetList(array("USER_ID" => $arData["USER_ID"]));
if (empty($dbFUserListTmp)) {
$arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => $arData["USER_ID"]);
$fuserID = CSaleUser::_Add($arFields);
} else {
$fuserID = $dbFUserListTmp['ID'];
}
$orderID = CSaleOrder::Add($arOrder);
CCatalogProduct::setPriceVatIncludeMode(true);
CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency(WIZARD_SITE_ID));
CCatalogProduct::setUseDiscount(true);
for ($i = 0; $i < $prdCnt; $i++) {
$prdID = $arPrd[mt_rand(20, 99)];
$arProduct = CCatalogProduct::GetByID($prdID["ID"]);
$arPrice = CCatalogProduct::GetOptimalPrice($prdID["ID"], 1, array(2), 'N', array(), WIZARD_SITE_ID, array());
$arFields = array("IGNORE_CALLBACK_FUNC" => "Y", "PRODUCT_ID" => $prdID["ID"], "PRODUCT_PRICE_ID" => $arPrice['PRICE']['ID'], "BASE_PRICE" => $arPrice['RESULT_PRICE']['BASE_PRICE'], "PRICE" => $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'], "VAT_RATE" => $arPrice['PRICE']['VAT_RATE'], "CURRENCY" => $arPrice['RESULT_PRICE']['CURRENCY'], "WEIGHT" => $arProduct["WEIGHT"], "DIMENSIONS" => serialize(array("WIDTH" => $arProduct["WIDTH"], "HEIGHT" => $arProduct["HEIGHT"], "LENGTH" => $arProduct["LENGTH"])), "QUANTITY" => 1, "LID" => WIZARD_SITE_ID, "DELAY" => "N", "CAN_BUY" => "Y", "NAME" => $prdID["NAME"], "CALLBACK_FUNC" => "", "MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "ORDER_CALLBACK_FUNC" => "", "CANCEL_CALLBACK_FUNC" => "", "PAY_CALLBACK_FUNC" => "", "DETAIL_PAGE_URL" => $prdID["DETAIL_PAGE_URL"], "CATALOG_XML_ID" => $prdID["IBLOCK_XML_ID"], "PRODUCT_XML_ID" => $prdID["XML_ID"], "NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "FUSER_ID" => $fuserID, "ORDER_ID" => $orderID);
$addres = CSaleBasket::Add($arFields);
}
$dbBasketItems = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderID), false, false, array("ID", "QUANTITY", "PRICE"));
$ORDER_PRICE = 0;
while ($arBasketItems = $dbBasketItems->GetNext()) {
$ORDER_PRICE += roundEx($arBasketItems["PRICE"], SALE_VALUE_PRECISION) * DoubleVal($arBasketItems["QUANTITY"]);
}
$totalOrderPrice = $ORDER_PRICE + $arData["PRICE_DELIVERY"];
CSaleOrder::Update($orderID, array("PRICE" => $totalOrderPrice));
foreach ($arData["PROPS"] as $val) {
$arFields = array("ORDER_ID" => $orderID, "ORDER_PROPS_ID" => $val["ID"], "NAME" => $val["NAME"], "CODE" => $val["CODE"], "VALUE" => $val["VALUE"]);
CSaleOrderPropsValue::Add($arFields);
}
return $orderID;
}
}
示例12: formAndSendDataToGP
//.........这里部分代码省略.........
}
}
}
// send data to GP server
if ($options["URL"]) {
$arConfig = self::$CONFIG;
$stop_send = false;
$ch = curl_init();
if (intVal($_POST[$post_key['gp_order_id']]) == 0) {
$type = "POST";
//$options["URL"] = COption::GetOptionString(self::$MODULE_ID, 'POST_url');
$options["URL"] = COption::GetOptionString(self::$MODULE_ID, 'gp_script_url') . $arConfig["POST_URL"];
}
if ($type == "POST" && !empty($post_data['widget_token'])) {
$post_data['with_draft'] = true;
}elseif($type == "POST" && empty($post_data['widget_token'])){
$post_data['with_draft'] = false;
}
// set data for sending to GP server
$send_data = json_encode($post_data);
if ($type == "POST") {
curl_setopt($ch, CURLOPT_POST, true);
} elseif ($type == "PATCH") {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
} else {
$stop_send = true;
}
curl_setopt($ch, CURLOPT_URL, $options["URL"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $send_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!$stop_send) {
$result = json_decode(curl_exec($ch), true);
}
curl_close($ch);
if (is_array($result['error_message']) && count($result['error_message']) == 1) {
$comment = implode("\r\n", $result['error_message']);
$comment = CGPWidget::Translate($comment);
CSaleOrder::SetMark($ID, $comment);
} elseif (is_array($result['error_message']) && count($result['error_message']) > 1) {
$comment = $result['error_message'];
$ar_comment = "";
foreach($comment as $com){
$ar_comment .= CGPWidget::Translate($com).". ";
}
CSaleOrder::SetMark($ID, $ar_comment);
} elseif ($result) {
if ($order_is_marked) {
CSaleOrder::UnsetMark($ID);
}
if (intVal($_POST[$post_key['gp_order_id_0']]) == 0 && $result['id']/* && intVal($_POST[$post_key['gp_order_id']]) != $result['id']*/) {
// $_POST[$post_key['gp_order_id']] = $result['id'];
if ($gp_order_id_prop_id = intVal(str_replace("ORDER_PROP_", "", $post_key['gp_order_id_0']))) {
$gp_order_id_res = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "ORDER_PROPS_ID" => $gp_order_id_prop_id));
if ($gp_order_id_ar = $gp_order_id_res->Fetch()) {
$gp_order_id_prop_value_id = $gp_order_id_ar['ID'];
if ($gp_order_id_prop_value_id) {
$gp_order_id_add_result = CSaleOrderPropsValue::Update($gp_order_id_prop_value_id, array("ORDER_ID" => $ID, "VALUE" => $result['id']));
}
} else {
$gp_order_id_prop_res = CSaleOrderProps::GetList(array(), array("ID" => $gp_order_id_prop_id));
if ($gp_order_id_prop_ar = $gp_order_id_prop_res->Fetch()) {
$gp_order_id_add_result = CSaleOrderPropsValue::Add(array("ORDER_ID" => $ID, "ORDER_PROPS_ID" => $gp_order_id_prop_id, "VALUE" => $result['id'], "NAME" => $gp_order_id_prop_ar['NAME'], "CODE" => $gp_order_id_prop_ar['CODE']));
}
}
}
}
}
/*
echo "<pre>";
var_dump($_POST);
var_dump($post_data);
var_dump($result);
echo "</pre>";
die();*/
}
// log everything
$filename = $_SERVER['DOCUMENT_ROOT'] . '/templog.log';
$data = array($type, date('d.m.Y h:i:s'), "ORDER" => $ID, "URL" => $options["URL"], "SEND" => $send_data, "RESULT" => $result, "ARFIELDS" => $arFields);
// $data = array($type, date('d.m.Y h:i:s'), "ORDER" => $ID, "URL" => $options["URL"], "SEND" => $send_data, "gpid" => array('add' => $m, 'res' => $gp_order_id_add_result, '1' => array($gp_order_id_prop_value_id, array("ORDER_ID" => $ID, "VALUE" => $result['id'])), 'ar' => $gp_order_id_ar, 'val' => $gp_order_id_prop_value_id, 'post_gpoid' => $result['id'], "ORDER_ID" => $ID, 'ORDER_PROPS_ID' => str_replace("ORDER_PROP_", "", $post_key['gp_order_id'])), array($_POST[$post_key['gp_order_id']], $post_key['gp_order_id']), "RESULT" => $result);
// $data = array($type, date('d.m.Y h:i:s'), $ID, $send_data, $result, $city_name, $city_id, $post_key, $_POST);
file_put_contents($filename, var_export($data, true), FILE_APPEND | LOCK_EX);
}
示例13: updateProps
protected static function updateProps($value, $code, $param)
{
if ($value == '' || !CModule::IncludeModule('sale')) {
return false;
}
$add = false;
if (isset($param['update'][$param['options'][$param['type']][$code]]) == false) {
if ($arProp = CSaleOrderProps::GetList(array(), array('CODE' => $param['options'][$param['type']][$code]))->Fetch()) {
$param['update'][$param['options'][$param['type']][$code]] = array('NAME' => $arProp['NAME'], 'CODE' => $arProp['CODE'], 'ORDER_PROPS_ID' => $arProp['ID'], 'TYPE' => $arProp['TYPE'], 'ORDER_ID' => $param['orderId'], 'VALUE' => '');
$add = true;
} else {
return false;
}
}
if ($param['update'][$param['options'][$param['type']][$code]]['TYPE'] == 'LOCATION') {
$value = self::getLocation($value);
if ($value == false) {
return false;
}
}
if ($param['update'][$param['options'][$param['type']][$code]]['VALUE'] != $value) {
if ($add === true) {
$param['update'][$param['options'][$param['type']][$code]]['VALUE'] = $value;
CSaleOrderPropsValue::Add($param['update'][$param['options'][$param['type']][$code]]);
} else {
CSaleOrderPropsValue::Update($param['update'][$param['options'][$param['type']][$code]]['ID'], array('VALUE' => $value));
}
}
}
示例14: AddOrderProperty
function AddOrderProperty($code, $value, $order)
{
if (!strlen($code)) {
return false;
}
if (CModule::IncludeModule('sale')) {
if ($arProp = CSaleOrderProps::GetList(array(), array('CODE' => $code))->Fetch()) {
return CSaleOrderPropsValue::Add(array('NAME' => $arProp['NAME'], 'CODE' => $arProp['CODE'], 'ORDER_PROPS_ID' => $arProp['ID'], 'ORDER_ID' => $order, 'VALUE' => $value));
}
}
}