本文整理汇总了PHP中CSaleBasket::getRoundFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket::getRoundFields方法的具体用法?PHP CSaleBasket::getRoundFields怎么用?PHP CSaleBasket::getRoundFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleBasket
的用法示例。
在下文中一共展示了CSaleBasket::getRoundFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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" => Loc::getMessage('SKGO_CALC_PARAM_ERROR'));
return null;
}
$userId = intval($userId);
if (!is_array($arShoppingCart) || count($arShoppingCart) <= 0) {
$arErrors[] = array("CODE" => "PARAM", "TEXT" => Loc::getMessage('SKGO_SHOPPING_CART_EMPTY'));
return null;
}
$arOrder = static::makeOrderArray($siteId, $userId, $arShoppingCart, $arOptions);
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, $arOptions);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderProps", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
CSaleDelivery::DoProcessOrder($arOrder, $deliveryId, $arErrors);
if (count($arErrors) > 0) {
return null;
}
$arOrder["PRICE_DELIVERY"] = $arOrder["DELIVERY_PRICE"];
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderDelivery", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
CSalePaySystem::DoProcessOrder($arOrder, $paySystemId, $arErrors);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderPaySystem", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
if (!array_key_exists('CART_FIX', $arOptions) || 'Y' != $arOptions['CART_FIX']) {
CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderDiscount", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
if (isset($arOrder['ORDER_PRICE'])) {
$roundOrderFields = static::getRoundFields();
foreach ($arOrder as $fieldName => $fieldValue) {
if (in_array($fieldName, $roundOrderFields)) {
$arOrder[$fieldName] = PriceMaths::roundPrecision($arOrder[$fieldName]);
}
}
}
if (!empty($arOrder['BASKET_ITEMS']) && is_array($arOrder['BASKET_ITEMS'])) {
$arOrder['ORDER_PRICE'] = 0;
$roundBasketFields = CSaleBasket::getRoundFields();
foreach ($arOrder['BASKET_ITEMS'] as &$basketItem) {
foreach ($basketItem as $fieldName => $fieldValue) {
if (in_array($fieldName, $roundBasketFields)) {
if (isset($basketItem[$fieldName])) {
$basketItem[$fieldName] = PriceMaths::roundPrecision($basketItem[$fieldName]);
}
}
}
if (CSaleBasketHelper::isSetItem($basketItem)) {
continue;
}
$arOrder['ORDER_PRICE'] += CSaleBasketHelper::getFinalPrice($basketItem);
}
}
}
CSaleTax::DoProcessOrderBasket($arOrder, $arOptions, $arErrors);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderShoppingCartTax", true) as $arEvent) {
//.........这里部分代码省略.........
示例2: getBasketItems
//.........这里部分代码省略.........
}
$arItem['FULL_PRICE_FORMATED'] = CCurrencyLang::CurrencyFormat($arItem['FULL_PRICE'], $arItem['CURRENCY'], true);
if ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "N") {
$allSum += $arItem["PRICE"] * $arItem["QUANTITY"];
$allWeight += $arItem["WEIGHT"] * $arItem["QUANTITY"];
$allVATSum += roundEx($arItem["PRICE_VAT_VALUE"] * $arItem["QUANTITY"], SALE_VALUE_PRECISION);
$bShowReady = true;
if ($arItem["DISCOUNT_PRICE"] > 0) {
$DISCOUNT_PRICE_ALL += $arItem["DISCOUNT_PRICE"] * $arItem["QUANTITY"];
}
$arResult["ITEMS"]["AnDelCanBuy"][] = $arItem;
} elseif ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "Y") {
$bShowDelay = true;
$arResult["ITEMS"]["DelDelCanBuy"][] = $arItem;
} elseif ($arItem["CAN_BUY"] == "N" && $arItem["SUBSCRIBE"] == "Y") {
$bShowSubscribe = true;
$arResult["ITEMS"]["ProdSubscribe"][] = $arItem;
} else {
$bShowNotAvail = true;
$arItem["NOT_AVAILABLE"] = true;
$arResult["ITEMS"]["nAnCanBuy"][] = $arItem;
}
}
unset($arItem);
$arResult["ShowReady"] = $bShowReady ? "Y" : "N";
$arResult["ShowDelay"] = $bShowDelay ? "Y" : "N";
$arResult["ShowNotAvail"] = $bShowNotAvail ? "Y" : "N";
$arResult["ShowSubscribe"] = $bShowSubscribe ? "Y" : "N";
$arOrder = array('SITE_ID' => SITE_ID, 'USER_ID' => $GLOBALS["USER"]->GetID(), 'ORDER_PRICE' => $allSum, 'ORDER_WEIGHT' => $allWeight, 'BASKET_ITEMS' => $arResult["ITEMS"]["AnDelCanBuy"]);
$arOptions = array('COUNT_DISCOUNT_4_ALL_QUANTITY' => $this->countDiscount4AllQuantity);
$arErrors = array();
CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
if (isset($arOrder['ORDER_PRICE'])) {
$roundOrderFields = CSaleOrder::getRoundFields();
foreach ($arOrder as $fieldName => $fieldValue) {
if (in_array($fieldName, $roundOrderFields)) {
$arOrder[$fieldName] = roundEx($arOrder[$fieldName], SALE_VALUE_PRECISION);
}
}
}
if (!empty($arOrder['BASKET_ITEMS']) && is_array($arOrder['BASKET_ITEMS'])) {
$arOrder['ORDER_PRICE'] = 0;
$roundBasketFields = CSaleBasket::getRoundFields();
foreach ($arOrder['BASKET_ITEMS'] as &$basketItem) {
foreach ($basketItem as $fieldName => $fieldValue) {
if (in_array($fieldName, $roundBasketFields)) {
if (isset($basketItem[$fieldName])) {
$basketItem[$fieldName] = roundEx($basketItem[$fieldName], SALE_VALUE_PRECISION);
}
}
}
$arOrder['ORDER_PRICE'] += $basketItem['PRICE'] * $basketItem['QUANTITY'];
}
$arOrder['ORDER_PRICE'] = roundEx($arOrder['ORDER_PRICE'], SALE_VALUE_PRECISION);
}
$allSum = 0;
$allWeight = 0;
$allVATSum = 0;
$DISCOUNT_PRICE_ALL = 0;
$priceWithoutDiscount = 0;
foreach ($arOrder["BASKET_ITEMS"] as &$arOneItem) {
$allWeight += $arOneItem["WEIGHT"] * $arOneItem["QUANTITY"];
$allSum += $arOneItem["PRICE"] * $arOneItem["QUANTITY"];
if (array_key_exists('VAT_VALUE', $arOneItem)) {
$arOneItem["PRICE_VAT_VALUE"] = $arOneItem["VAT_VALUE"];
}
示例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" => Loc::getMessage('SKGO_CALC_PARAM_ERROR'));
return null;
}
$userId = intval($userId);
if (!is_array($arShoppingCart) || count($arShoppingCart) <= 0) {
$arErrors[] = array("CODE" => "PARAM", "TEXT" => Loc::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);
if (isset($arOptions["DELIVERY_EXTRA_SERVICES"])) {
$arOrder["DELIVERY_EXTRA_SERVICES"] = $arOptions["DELIVERY_EXTRA_SERVICES"];
}
$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, $arOptions);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderProps", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
CSaleDelivery::DoProcessOrder($arOrder, $deliveryId, $arErrors);
if (count($arErrors) > 0) {
return null;
}
$arOrder["PRICE_DELIVERY"] = $arOrder["DELIVERY_PRICE"];
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderDelivery", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
CSalePaySystem::DoProcessOrder($arOrder, $paySystemId, $arErrors);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderPaySystem", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
if (!array_key_exists('CART_FIX', $arOptions) || 'Y' != $arOptions['CART_FIX']) {
CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
if (count($arErrors) > 0) {
return null;
}
foreach (GetModuleEvents("sale", "OnSaleCalculateOrderDiscount", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arOrder));
}
if (isset($arOrder['ORDER_PRICE'])) {
$roundOrderFields = static::getRoundFields();
//.........这里部分代码省略.........