Answer the question
In order to leave comments, you need to log in
How to add a property about the availability of goods, or about its deliveries?
Good afternoon.
It is known that in Bitrix there is a check for the availability of goods in warehouses and as a result you get "In stock" and "Out of stock", but this is not enough for everyone, right?
My question is this, there is a quantity file:
<?
$showCatalogQty = ('Y' == $arParams["SHOW_CATALOG_QUANTITY"]);
$showCatalogQtyCnt = ('Y' == $arParams["SHOW_CATALOG_QUANTITY_CNT"]);
if (!function_exists('printAvailHtml'))
{
function printAvailHtml($qty, $measure, $params, $showCatalogQtyCnt) {
$html = '<div class="bxr-instock-wrap">';
if ($qty > 0) {
$html .= "<i class='fa fa-check'></i>";
} else {
$html .= "<i class='fa fa-times'></i>";
};
if ($qty > 0) {
$html .= $params["IN_STOCK"];
} else {
$html .= $params["NOT_IN_STOCK"];
};
if ($showCatalogQtyCnt && $qty > 0) {
if ($params["QTY_SHOW_TYPE"] == "NUM") {
$qtyText = $qty." ".$measure;
} elseif ($qty > $params["QTY_MANY_GOODS_INT"]) {
$qtyText = $params["QTY_MANY_GOODS_TEXT"];
} else {
$qtyText = $params["QTY_LESS_GOODS_TEXT"];
}
$html .= ' ('.$qtyText.')';
}
$html .= '</div>';
return $html;
}
}
if ($showCatalogQty) {
$params = array(
"IN_STOCK" => $arParams["IN_STOCK"],
"NOT_IN_STOCK" => $arParams["NOT_IN_STOCK"],
"QTY_SHOW_TYPE" => $arParams["QTY_SHOW_TYPE"],
"QTY_MANY_GOODS_INT" => $arParams["QTY_MANY_GOODS_INT"],
"QTY_MANY_GOODS_TEXT" => $arParams["QTY_MANY_GOODS_TEXT"],
"QTY_LESS_GOODS_TEXT" => $arParams["QTY_LESS_GOODS_TEXT"]
);
if (count($arResult["OFFERS"]) > 0) {?>
<div class="bxr-main-avail-wrap">
<?}
echo printAvailHtml($arResult["CATALOG_QUANTITY"], $arResult["CATALOG_MEASURE_NAME"], $params, $showCatalogQtyCnt);
if (count($arResult["OFFERS"]) > 0) {?>
</div>
<? foreach ($arResult["OFFERS"] as $offer) {?>
<div class="bxr-offer-avail-wrap" data-item="<?=$offer["ID"]?>" style="display: none;">
<?echo printAvailHtml($offer["CATALOG_QUANTITY"], $offer["CATALOG_MEASURE_NAME"], $params, $showCatalogQtyCnt);?>
</div>
<?}
}
}
Answer the question
In order to leave comments, you need to log in
Resolved:
2 options were implemented:
1) a product property was added - the delivery date, I compare it with the present date, and if the difference is less than 14 days, the status changes
2) (simpler) property of the list type - select the item "delivery expected" and the status changes .
Important!
Let's go through the code step by step:
1) do a check (by the way, not necessarily) , the main thing is to assign a value
if ($arResult["PROPERTIES"]["ojidaetsya_dostavka"]["VALUE"] !== '') $ojidaetsya_dostavka = $arResult["PROPERTIES"]["ojidaetsya_dostavka"]["VALUE"];
echo printAvailHtml($arResult["CATALOG_QUANTITY"], $arResult["CATALOG_MEASURE_NAME"], $params, $showCatalogQtyCnt, $ojidaetsya_dostavka);
if ($ojidaetsya_dostavka =='да') $params["NOT_IN_STOCK"]="Уточнить наличие";
$html .= $params["NOT_IN_STOCK"];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question