function AddToBasket($pid, $quantity) { if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) { $ar_res = CCatalogProduct::GetByIDEx($pid); if ($ar_res) { $result = Add2BasketByProductID($pid, $quantity); // если ошибки - $ex = $APPLICATION->GetException(); if ($result) { $arrSendResult['ERROR'] = 'N'; $arrSendResult['TEXT'] = 'OK'; echo json_encode($arrSendResult); } else { $arrSendResult['ERROR'] = 'Y'; $arrSendResult['TEXT'] = 'Error'; echo json_encode($arrSendResult); } } else { if (Add2BasketByProductID($pid, $quantity)) { $arrSendResult['ERROR'] = 'N'; $arrSendResult['TEXT'] = 'OK'; echo json_encode($arrSendResult); } } } }
public function editContent(&$content) { $replaced_template = "<!--Mneniya.pro-->"; if (strpos($content, $replaced_template) !== false) { if (CModule::IncludeModule("catalog")) { $product_id = 0; if (isset($_SESSION['VIEWED_PRODUCT']) && $_SESSION['VIEWED_PRODUCT']) { $product_id = $_SESSION['VIEWED_PRODUCT']; } else { $product_id = $_SESSION['LAST_VIEW_ID']; } $product_info = CCatalogProduct::GetByIDEx($product_id); $settings = unserialize(COption::GetOptionString("pimentos.mneniyapro", "settings")); if (isset($settings["code"]) && $settings["code"]) { $content = str_replace($replaced_template, '<div class="mp-prod_id" style="display:none">' . $product_id . '</div>' . '<div class="mp-prod_name" style="display:none">' . $product_info['NAME'] . '</div>' . $settings["code"], $content); } } } }
function addToBascket($arItems){ $num = 0; foreach($arItems as $item){ $tovar=CCatalogProduct::GetByIDEx($item["ID"]); if(intval($item["COUNT"])<=$tovar["PRODUCT"]["QUANTITY"]&&intval($item["COUNT"])>0){ Add2BasketByProductID($item["ID"],intval($item["COUNT"])); $num++; } } ?> <script> $(".CartLink span").text('(<?php echo $num; ?> )'); $('body,html').animate({scrollTop: 0}, 2); </script> <? }
function GetCatalogProductEx($PRODUCT_ID, $boolAllValues = false) { $PRODUCT_ID = intval($PRODUCT_ID); return CCatalogProduct::GetByIDEx($PRODUCT_ID, $boolAllValues); }
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?> <? foreach($arResult["ITEMS"]["AnDelCanBuy"] as &$item){ $ar_res = CCatalogProduct::GetByIDEx($item['PRODUCT_ID']); $item['DETAIL_PAGE_URL'] = $ar_res['DETAIL_PAGE_URL']; $item['TOTAL'] = $item['PRICE']*$item['QUANTITY']; $item['BASE_PRICE'] = CPrice::GetBasePrice($item['PRODUCT_ID']); $item["BASE_PRICE"]['PRICE'] = ceil($item["BASE_PRICE"]['PRICE']); $item['PRICE'] = ceil($item['PRICE']); if($ar_res['IBLOCK_CODE']=='tyres'){ $rsProp = CIBlockProperty::GetByID('model', false, 'tyres'); if($arProp = $rsProp->GetNext()){ $rsElement = CIBlockElement::GetList(array(), array('IBLOCK_ID'=>$arProp['LINK_IBLOCK_ID'], 'ID'=>$ar_res['PROPERTIES']['model']['VALUE'], 'ACTIVE'=>'Y'), false, array('nTopCount'=>1), array('ID', 'IBLOCK_ID', 'PREVIEW_PICTURE')); if ($obElement = $rsElement->GetNextElement()) { $arFields = $obElement->GetFields(); $arProps = $obElement->GetProperties(false, array('CODE'=>array('model_season', 'model_type', 'model_pin'))); $item['IBLOCK_CODE']='tyres'; $item['PREVIEW_PICTURE'] = CFile::ResizeImageGet($arFields['PREVIEW_PICTURE'], array('width'=>43, 'height'=>60), BX_RESIZE_IMAGE_PROPORTIONAL, true); $item['PROPERTIES'] = $arProps; } } }elseif($ar_res['IBLOCK_CODE']=='wheels'){ $rsProp = CIBlockProperty::GetByID('model', false, 'wheels'); if($arProp = $rsProp->GetNext()){ $rsElement = CIBlockElement::GetList(array(), array('IBLOCK_ID'=>$arProp['LINK_IBLOCK_ID'], 'ID'=>$ar_res['PROPERTIES']['model']['VALUE'], 'ACTIVE'=>'Y'), false, array('nTopCount'=>1), array('ID', 'IBLOCK_ID', 'PREVIEW_PICTURE')); if ($obElement = $rsElement->GetNextElement()) { $arFields = $obElement->GetFields(); $item['IBLOCK_CODE']='wheels';
<p class="cost"><?php echo $superobl_v["PRICES"][11]['PRICE']; ?> руб.</p></a> <?php $arFile = CFile::GetFileArray($superobl_v["DETAIL_PICTURE"]); ?> </div> <?php } ?> <?php if (!empty($arResult["PROPERTIES"]["audio_v"]['VALUE'])) { ?> <?php $superobl_v = CCatalogProduct::GetByIDEx($arResult["PROPERTIES"]["audio_v"]['VALUE']); ?> <div class="productType" onclick="dataLayer.push({event: 'otherFormatsBlock', action: 'clickAudio', label: '<?php echo $arResult['NAME']; ?> '});"> <a href="<?php echo $superobl_v[DETAIL_PAGE_URL]; ?> "><p class="title">Аудиокнига</p> <p class="cost"><?php echo $superobl_v["PRICES"][11]['PRICE']; ?> руб.</p></a> <?php $arFile = CFile::GetFileArray($superobl_v["DETAIL_PICTURE"]);
static function productViewCustom($id, $arFields) { if ($arFields["PRODUCT_ID"]) { $arResult["PRODUCT_ID"] = $arFields["PRODUCT_ID"]; } else { if ($id["PRODUCT_ID"]) { $arResult["PRODUCT_ID"] = $id["PRODUCT_ID"]; } else { return true; } } if (self::contains($_SERVER["HTTP_USER_AGENT"], "facebook.com")) { return; } $api_key = COption::GetOptionString(self::$MODULE_ID, "tracker_code", ''); if (!$api_key) { return; } global $APPLICATION; global $USER; $visitor_uid = false; if (!$user_id) { $user_id = $USER->GetID(); } $visitor_info = false; if ($user_id && ($visitor_info = self::getVisitorInfo($user_id))) { $visitor_uid = (int) $user_id; } $guest_uid = self::getUid($visitor_uid); $tracker = new ConveadTracker($api_key, SITE_SERVER_NAME, $guest_uid, $visitor_uid, $visitor_info, false, SITE_SERVER_NAME); $arProduct = CCatalogProduct::GetByIDEx($arResult["PRODUCT_ID"]); $product_id = $arResult["PRODUCT_ID"]; $product_name = str_replace("'", ''', $arProduct["NAME"]); $product_url = "http://" . SITE_SERVER_NAME . $arProduct["DETAIL_PAGE_URL"]; $result = $tracker->eventProductView($product_id, $product_name, $product_url); return true; }
<?php if (CModule::IncludeModule("sale")) { $ar_res = CCatalogProduct::GetByIDEx($pid); if ($ar_res) { $result = Add2BasketByProductID($pid, $quantity, array(array("NAME" => $ar_res['PROPERTIES']['COLOR']['NAME'], "VALUE" => $ar_res['PROPERTIES']['COLOR']['VALUE']), array("NAME" => $ar_res['PROPERTIES']['SIZE']['NAME'], "VALUE" => $ar_res['PROPERTIES']['SIZE']['VALUE']))); if ($result) { echo 'OK'; } else { echo "Error"; } } else { $result = Add2BasketByProductID($pid, $quantity); echo "OK"; } }