L
L
lie22020-06-15 11:14:39
1C-Bitrix
lie2, 2020-06-15 11:14:39

How to make a loan calculator for trade offers?

Good day! reworked the old question :
1) the site has set up a credit / installment block / found it cheaper, but trade offers do not have it ... I
ran into a problem that in the basket_btn.php file (I think) there is no passage cycle for each price separately and he does not want to take the values ​​​​of the prices of the TP by trial and error; no price pass ... I think it's related to "$qtyMax".
made a product with different prices for this: product
stock file basket_btn.php:

<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
if ($arResult['CATALOG_SUBSCRIBE'] == 'Y')
    $showSubscribeBtn = true;
else
    $showSubscribeBtn = false;
$usePriceCount = ('Y' == $arParams['USE_PRICE_COUNT']);

if (count($arResult["OFFERS"]) > 0) {
    foreach ($arResult["OFFERS"] as $offer) :?>
        <div class="offers-btn-wrap" style="display: none" data-item="<?= $offer["ID"] ?>">
            <? if ($offer["CATALOG_QUANTITY"] <= 0 && $offer["CATALOG_CAN_BUY_ZERO"] == "N" || !$offer["PRICES"]) :
                if ($showSubscribeBtn) { ?>
///текст кнопки для ТП
                <? } else { ?>
///кнопка подписки для ТП
                <?
                }
            else:
                $qtyMax = ($offer["CATALOG_CAN_BUY_ZERO"] == "Y") ? 0 : $offer["CATALOG_QUANTITY"]; ?>
/// форма ТП
                <? if ($useOneClick):
                //--one click buy block--
                ?>
/// вызов кнопки
            <? endif; ?>
                <div class="clearfix"></div>
            <? endif; ?>
        </div>
    <? endforeach;
} else { ?>
///тут шляпа скрипт. не знаю зачем он

    <?
    if ($arResult["CATALOG_QUANTITY"] <= 0 && $arResult["CATALOG_CAN_BUY_ZERO"] == "N"
        || (!$arResult["PRICES"] && !$usePriceCount) || ((!$arResult["PRICE_MATRIX"] || !$arResult['PRICE_MATRIX']['ROWS']) && $usePriceCount)) {
        if ($showSubscribeBtn) { ?>
///текст кнопки для Т
        <? } else { ?>
///кнопка подписки для Т
        <?
        }
    } else {
        $qtyMax = ($arResult["CATALOG_CAN_BUY_ZERO"] == "Y") ? 0 : $arResult["CATALOG_QUANTITY"]; ?>
        <?
        if ($arResult["BASKET_PROPS"]["REQUIRED_CHECK"] || $arResult["BASKET_PROPS"]["OPTIONAL_CHECK"]) { ?>
            <table id="bxr-bprop-table">
                <?
                foreach ($arResult["BASKET_PROPS"]["REQUIRED_CHECK"] as $pCode) { ?>
                    <tr>
                        <td class="bxr-bprop-name"><?= $pCode["NAME"] ?>:</td>
                        <td class="bxr-bprop-value">
                            <div class="bxr-bprop-tooltip"><?= GetMessage('SELECT_BPROP') ?> <?= $pCode["NAME"] ?>
                                <i class="fa fa-caret-down"></i></div>
                            <select class="bxr-bprop-required bxr-bprop-select" id="bxr-bprop-required-<?= $pCode["ID"] ?>" data-required="Y" data-code="<?= $pCode["CODE"] ?>" data-name="<?= $pCode["NAME"] ?>" data-sort="<?= $pCode["SORT"] ?>">
                                <option value="false"><?= GetMessage("BPROP_NOT_SELECT") ?></option>
                                <?
                                foreach ($pCode["VALUE"] as $val) { ?>
                                    <option value="<?= $val ?>"><?= $val ?></option>
                                <?
                                } ?>
                            </select>
                        </td>
                    </tr>
                <?
                }
                foreach ($arResult["BASKET_PROPS"]["OPTIONAL_CHECK"] as $pCode) { ?>
                <tr>
                    <td class="bxr-bprop-name"><?= $pCode["NAME"] ?>:</td>
                    <td class="bxr-bprop-value">
                        <select class="bxr-bprop-optional bxr-bprop-select" data-required="N" data-code="<?= $pCode["CODE"] ?>" data-name="<?= $pCode["NAME"] ?>" data-sort="<?= $pCode["SORT"] ?>">
                            <option value="<?= GetMessage("BPROP_NOT_SELECT") ?>"><?= GetMessage("BPROP_NOT_SELECT") ?></option>
                            <?
                            foreach ($pCode["VALUE"] as $val) { ?>
                                <option value="<?= $val ?>"><?= $val ?></option>
                            <?
                            } ?>
                        </select>
                    </td>
                    <?
                    } ?>
            </table>
        <?
        } ?>
/// форма Т
        <?
        if ($useOneClick):
            //--one click buy block--
            ?>
/// вызов кнопки
        <?endif; ?>


        <?php
        CModule::IncludeModule('iblock');
        $IBLOCK_ID = 40;
        ?>        
                ///код html на формы

        <?php if ($arResult["PROPERTIES"]["DISABLE_INSTALLMENT"]["VALUE"]): ?>
        <style>.credit__modal .nav-tabs>li{width: 100% !important;}</style>
        <?php endif; ?>

/// скрипт на рассчет
/// вызов кнопок
        
<div style="display: none">
    <?php var_dump($arResult);?>
</div>        <div class="clearfix"></div>
    <?
    }
}

if ($useShare || $useCompare || $useFavorites):?>
    <div class="bxr-detail-torg-btn">
        <? if ($useShare):
            //--share block--
            ?>
            <div class="bxr-share-group">
            <span class="fa fa-share-alt hidden-md"></span>
            <?
            if (strlen($arParams["USE_SHARE_TEXT"]) > 0):
                echo $arParams["USE_SHARE_TEXT"];
            else:
                echo GetMessage("SHARE");
            endif; ?>
            </div>
        <?endif;
        if ($useCompare):
            //--compare block--
            ?>
///кнопка сравнения
        <?endif;
        if ($useFavorites):
            //--favor block--
            ?>
///форма сравнения
        <? endif; ?>
        <div class="clearfix"></div>
    </div>
<? endif; ?>


<?php if ( is_array($arResult["PROPERTIES"]["GIFTS"]["VALUE"]) ? count($arResult["PROPERTIES"]["GIFTS"]["VALUE"]) : 0 > 0): ?>
    <h4 class="titgle__gift">Подарки при покупке</h4>
    <? $APPLICATION->IncludeComponent(
  "bitrix:catalog.recommended.products", 
  "gift", 
  array(
    "ACTION_VARIABLE" => "action_crp",
    "ADDITIONAL_PICT_PROP_11" => "MORE_PHOTO",
    "ADDITIONAL_PICT_PROP_12" => "",
    "ADDITIONAL_PICT_PROP_33" => "MORE_PHOTO",
    "ADD_PROPERTIES_TO_BASKET" => "Y",
    "BASKET_URL" => "/personal/basket.php",
    "CACHE_TIME" => "86400",
    "CACHE_TYPE" => "A",
    "CART_PROPERTIES_11" => array(
      0 => "",
      1 => ",",
      2 => "",
    ),
    "CART_PROPERTIES_12" => array(
      0 => "",
      1 => ",",
      2 => "",
    ),
    "CART_PROPERTIES_33" => array(
      0 => "",
      1 => "",
    ),
    "COMPONENT_TEMPLATE" => "gift",
    "COMPOSITE_FRAME_MODE" => "A",
    "COMPOSITE_FRAME_TYPE" => "AUTO",
    "CONVERT_CURRENCY" => "N",
    "DETAIL_URL" => "",
    "HIDE_NOT_AVAILABLE" => "N",
    "IBLOCK_ID" => "11",
    "IBLOCK_TYPE" => "catalog",
    "ID" => $arResult["ID"],
    "LABEL_PROP_11" => "-",
    "LABEL_PROP_12" => "-",
    "LINE_ELEMENT_COUNT" => "3",
    "MESS_BTN_BUY" => "Купить",
    "MESS_BTN_DETAIL" => "Подробнее",
    "MESS_BTN_SUBSCRIBE" => "Подписаться",
    "MESS_NOT_AVAILABLE" => "Нет в наличии",
    "OFFERS_PROPERTY_LINK" => "GIFTS",
    "OFFER_TREE_PROPS_33" => array(
    ),
    "PAGE_ELEMENT_COUNT" => "30",
    "PARTIAL_PRODUCT_PROPERTIES" => "N",
    "PRICE_CODE" => array(
    ),
    "PRICE_VAT_INCLUDE" => "Y",
    "PRODUCT_ID_VARIABLE" => "id",
    "PRODUCT_PROPS_VARIABLE" => "prop",
    "PRODUCT_QUANTITY_VARIABLE" => "quantity",
    "PRODUCT_SUBSCRIPTION" => "N",
    "PROPERTY_CODE_11" => array(
      0 => "",
      1 => ",",
      2 => "",
    ),
    "PROPERTY_CODE_12" => array(
      0 => "",
      1 => ",",
      2 => "",
    ),
    "PROPERTY_CODE_33" => array(
      0 => "",
      1 => "",
    ),
    "PROPERTY_LINK" => "GIFTS",
    "SHOW_DISCOUNT_PERCENT" => "N",
    "SHOW_IMAGE" => "Y",
    "SHOW_NAME" => "Y",
    "SHOW_OLD_PRICE" => "N",
    "SHOW_PRICE_COUNT" => "1",
    "SHOW_PRODUCTS_11" => "Y",
    "SHOW_PRODUCTS_12" => "Y",
    "TEMPLATE_THEME" => "blue",
    "USE_PRODUCT_QUANTITY" => "N",
    "CODE" => $_REQUEST["PRODUCT_CODE"]
  ),
  false
); ?>
<?php endif; ?>

<?php if ($useShare): ?>
    <div class="bxr-share-icon-wrap">
        <? $APPLICATION->IncludeComponent(
            "bitrix:main.share",
            "element_detail",
            Array(
                "COMPONENT_TEMPLATE" => ".default",
                "HANDLERS" => $arParams["HANDLERS"],
                "HIDE" => "N",
                "PAGE_TITLE" => $arResult["NAME"],
                "PAGE_URL" => $arResult["DETAIL_PAGE_URL"],
                "SHORTEN_URL_KEY" => "",
                "SHORTEN_URL_LOGIN" => ""
            ),
            false,
            array("HIDE_ICONS" => "Y")
        ); ?>
    </div>
<? endif;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question