本文整理汇总了PHP中CSaleOrder::CalculateOrderPrices方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrder::CalculateOrderPrices方法的具体用法?PHP CSaleOrder::CalculateOrderPrices怎么用?PHP CSaleOrder::CalculateOrderPrices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrder
的用法示例。
在下文中一共展示了CSaleOrder::CalculateOrderPrices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeOrderArray
/**
* @param $siteId
* @param null $userId
* @param $shoppingCart
* @param array $options
*
* @return array
*/
static function makeOrderArray($siteId, $userId = null, array $shoppingCart, array $options = array())
{
// calculate weight for set parent
$parentWeight = array();
foreach ($shoppingCart as $item) {
if (CSaleBasketHelper::isSetItem($item)) {
$parentWeight[$item["SET_PARENT_ID"]]["WEIGHT"] += $item["WEIGHT"] * $item["QUANTITY"];
}
}
foreach ($shoppingCart as &$item) {
if (CSaleBasketHelper::isSetParent($item) && isset($parentWeight[$item["SET_PARENT_ID"]])) {
$item["WEIGHT"] = $parentWeight[$item["SET_PARENT_ID"]]["WEIGHT"];
}
}
unset($item);
$currency = isset($options['CURRENCY']) && is_string($options['CURRENCY']) ? $options['CURRENCY'] : '';
if ($currency === '') {
$currency = CSaleLang::GetLangCurrency($siteId);
}
$arOrder = array("ORDER_PRICE" => 0, "ORDER_WEIGHT" => 0, "CURRENCY" => $currency, "WEIGHT_UNIT" => htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', false, $siteId)), "WEIGHT_KOEF" => htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, $siteId)), "BASKET_ITEMS" => $shoppingCart, "SITE_ID" => $siteId, "LID" => $siteId, "USER_ID" => $userId, "USE_VAT" => false, "VAT_RATE" => 0, "VAT_SUM" => 0, "DELIVERY_ID" => false);
if (isset($options["DELIVERY_EXTRA_SERVICES"])) {
$arOrder["DELIVERY_EXTRA_SERVICES"] = $options["DELIVERY_EXTRA_SERVICES"];
}
$orderPrices = CSaleOrder::CalculateOrderPrices($shoppingCart);
$arOrder['ORDER_PRICE'] = $orderPrices['ORDER_PRICE'];
$arOrder['ORDER_WEIGHT'] = $orderPrices['ORDER_WEIGHT'];
$arOrder['VAT_RATE'] = $orderPrices['VAT_RATE'];
$arOrder['VAT_SUM'] = $orderPrices['VAT_SUM'];
$arOrder["USE_VAT"] = $orderPrices['USE_VAT'] == "Y";
return $arOrder;
}
示例2: array
$arCols["DETAIL_PICTURE"] = CSaleHelper::getFileInfo($arItem["DETAIL_PICTURE"], array("WIDTH" => 110, "HEIGHT" => 110));
}
if (isset($arItem["MEASURE_TEXT"]) && strlen($arItem["MEASURE_TEXT"]) > 0) {
$arCols["QUANTITY"] = $arItem["QUANTITY"] . " " . $arItem["MEASURE_TEXT"];
}
foreach ($arItem as $tmpKey => $value) {
if (strpos($tmpKey, "PROPERTY_", 0) === 0 && strrpos($tmpKey, "_VALUE") == strlen($tmpKey) - 6) {
$code = str_replace(array("PROPERTY_", "_VALUE"), "", $tmpKey);
$propData = $arIblockProps[$code];
$arCols[$tmpKey] = getIblockProps($value, $propData, array("WIDTH" => 110, "HEIGHT" => 110));
}
}
$arResult["GRID"]["ROWS"][$arItem["ID"]] = array("id" => $arItem["ID"], "data" => $arItem, "actions" => array(), "columns" => $arCols, "editable" => true);
}
unset($arItem);
$oldOrder = CSaleOrder::CalculateOrderPrices($arResult["BASKET_ITEMS"]);
if (!empty($oldOrder)) {
$arResult['ORDER_PRICE'] = $oldOrder['ORDER_PRICE'];
$arResult["ORDER_PRICE_FORMATED"] = SaleFormatCurrency($arResult["ORDER_PRICE"], $arResult["BASE_LANG_CURRENCY"]);
$arResult["ORDER_WEIGHT"] = $oldOrder["ORDER_WEIGHT"];
$arResult['VAT_SUM'] = $oldOrder['VAT_SUM'];
$arResult["USE_VAT"] = $oldOrder['USE_VAT'] == "Y";
$arResult["VAT_SUM_FORMATED"] = SaleFormatCurrency($arResult["VAT_SUM"], $arResult["BASE_LANG_CURRENCY"]);
}
unset($oldOrder);
}
} else {
$arResult["ORDER_PRICE"] = $arOrderDat['ORDER_PRICE'];
$arResult["ORDER_PRICE_FORMATED"] = SaleFormatCurrency($arResult["ORDER_PRICE"], $arResult["BASE_LANG_CURRENCY"]);
$arResult["USE_VAT"] = $arOrderDat['USE_VAT'];
$arResult["VAT_SUM"] = $arOrderDat["VAT_SUM"];
示例3: DoCalculateOrder
/**
* @param $siteId
* @param $userId
* @param $arShoppingCart
* @param $personTypeId
* @param $arOrderPropsValues
* @param $deliveryId
* @param $paySystemId
* @param $arOptions
* @param $arErrors
* @param $arWarnings
* @return array|null
*/
static function DoCalculateOrder($siteId, $userId, $arShoppingCart, $personTypeId, $arOrderPropsValues,
$deliveryId, $paySystemId, $arOptions, &$arErrors, &$arWarnings)
{
if(!is_array($arOptions))
{
$arOptions = array();
}
$siteId = trim($siteId);
if (empty($siteId))
{
$arErrors[] = array("CODE" => "PARAM", "TEXT" => GetMessage('SKGO_CALC_PARAM_ERROR'));
return null;
}
$userId = intval($userId);
if (!is_array($arShoppingCart) || (count($arShoppingCart) <= 0))
{
$arErrors[] = array("CODE" => "PARAM", "TEXT" => GetMessage('SKGO_SHOPPING_CART_EMPTY'));
return null;
}
// calculate weight for set parent
$arParentWeight = array();
foreach ($arShoppingCart as $arItem)
{
if (CSaleBasketHelper::isSetItem($arItem))
$arParentWeight[$arItem["SET_PARENT_ID"]]["WEIGHT"] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
}
foreach ($arShoppingCart as &$arItem)
{
if (CSaleBasketHelper::isSetParent($arItem) && isset($arParentWeight[$arItem["SET_PARENT_ID"]]))
$arItem["WEIGHT"] = $arParentWeight[$arItem["SET_PARENT_ID"]]["WEIGHT"];
}
unset($arItem);
$currency = isset($arOptions['CURRENCY']) && is_string($arOptions['CURRENCY']) ? $arOptions['CURRENCY'] : '';
if($currency === '')
{
$currency = CSaleLang::GetLangCurrency($siteId);
}
$arOrder = array(
"ORDER_PRICE" => 0,
"ORDER_WEIGHT" => 0,
"CURRENCY" => $currency,
"WEIGHT_UNIT" => htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', false, $siteId)),
"WEIGHT_KOEF" => htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, $siteId)),
"BASKET_ITEMS" => $arShoppingCart,
"SITE_ID" => $siteId,
"LID" => $siteId,
"USER_ID" => $userId,
"USE_VAT" => false,
"VAT_RATE" => 0,
"VAT_SUM" => 0,
"DELIVERY_ID" => false,
);
$arOrderPrices = CSaleOrder::CalculateOrderPrices($arShoppingCart);
if (sizeof($arOrderPrices)>0 && isset($arOrderPrices['BASKET_ITEMS']))
$arShoppingCart = $arOrderPrices['BASKET_ITEMS'];
$arOrder['ORDER_PRICE'] = $arOrderPrices['ORDER_PRICE'];
$arOrder['ORDER_WEIGHT'] = $arOrderPrices['ORDER_WEIGHT'];
$arOrder['VAT_RATE'] = $arOrderPrices['VAT_RATE'];
$arOrder['VAT_SUM'] = $arOrderPrices['VAT_SUM'];
$arOrder["USE_VAT"] = ($arOrderPrices['USE_VAT'] == "Y"?true:false);
foreach(GetModuleEvents("sale", "OnSaleCalculateOrderShoppingCart", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array(&$arOrder));
CSalePersonType::DoProcessOrder($arOrder, $personTypeId, $arErrors);
if (count($arErrors) > 0)
return null;
foreach(GetModuleEvents("sale", "OnSaleCalculateOrderPersonType", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array(&$arOrder));
CSaleOrderProps::DoProcessOrder($arOrder, $arOrderPropsValues, $arErrors, $arWarnings, $paySystemId, $deliveryId);
if (count($arErrors) > 0)
return null;
foreach(GetModuleEvents("sale", "OnSaleCalculateOrderProps", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array(&$arOrder));
//.........这里部分代码省略.........