Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- .zcontent{width:950px;}
- </style>
- <div class="cartview">
- <div class="head_block min">
- <span><?=lg(272)?></span>
- </div>
- <? if($auth->status){ ?>
- <div class="production_filter_wrap"><div class="production_filter">
- <a class="act"><?=lg(226)?></a>
- <a class="z" href="/z/<?=$u?>cart_orders"><?=lg(232)?></a>
- <div class="clear"></div>
- </div></div>
- <? }
- $total_price=0;
- $oplata_price=0;
- if ($cartlist != '' && $cartlist != '{}'){
- $cart_ids = "";
- foreach($cart_obj as $key => $val){
- $cart_ids .= ",".$key;
- }
- $cart_ids = trim($cart_ids,',');
- ?>
- <div class="best_price itemsblock view4">
- <form id="order_form" onsubmit="return false">
- <?
- $result = mysql_query("SELECT * FROM `items` WHERE `code` IN ($cart_ids)");
- while($myrow = mysql_fetch_assoc($result)){
- /////////////// блок товара
- $topshop = $cityrow['topshop'];
- $item_patch="upload/items/".$myrow['code']."/poster/min.jpg";
- if(!file_exists(ROOT_FOLDER.$item_patch)){$item_patch="images/nophoto.jpg";}
- $actual = "";
- $act_price = $myrow["act_price".$topshop];
- $price = $myrow['m'.$topshop]>0?$myrow["now_price".$topshop]:0;
- if($myrow["act_price".$topshop] > 0){
- $act_arr = explode('¿',$myrow["act_date".$topshop]);
- $act_start = $act_arr[0];
- $act_stop = $act_arr[1];
- $time = time();
- if(intval($act_stop) > intval($time)){$actual = "<div class='sale_info'>".lg(91)." ".time2date_min($act_stop)."</div>";} else {$act_price = 0;}
- } else {
- $act_price = 0;
- }
- $settings = mysql_fetch_assoc(mysql_query("SELECT * FROM settings WHERE id=1 LIMIT 1"));
- $block_cats = explode(PHP_EOL, $settings['discont_block_cats']);
- $block_items = explode(PHP_EOL, $settings['discont_block_items']);
- $block_discont=0;
- if(in_array($myrow['code'], $block_items)){
- $block_discont=1;
- } else {
- foreach($block_cats as $val){
- $val = rtrim($val,'0');
- if(stripos($myrow['cat'], $val)!== false){
- $block_discont=1;
- }
- }
- }
- $fact_price=$price;
- if(!$block_discont && $fact_price){
- $fact_price=$fact_price-(($fact_price/100)*10);
- }
- //if(!$auth->status || $auth->reg_user['id']!=1){$block_discont=1;} //////////////////// delete
- if(!$settings['discont_block_is']){$block_discont=1;} //////////////////// delete
- $all_price = $myrow["now_price".$topshop]*$cart_obj[$myrow['code']];
- $all_price_fact = $fact_price*$cart_obj[$myrow['code']];
- ?>
- <div class="cartitem_wrap<?=($act_price>0?" action":"")?>" id="itm_<?=$myrow['code']?>" price="<?=$price?>" >
- <div class="itemblock" cat="<?=$myrow['cat']?>">
- <a href="<?=$u?>item/<?=$myrow['code']?>"><img src="<?=$item_patch?>"/></a>
- <div class="cont">
- <a href="<?=$u?>item/<?=$myrow['code']?>" class="title"><?=($myrow['name_'.$lang]!=""?$myrow['name_'.$lang]:$myrow['name_ru']).(!$block_discont && $act_price>0?"<br/><span class='sale_info'>".lg(312)."</span>":(!$block_discont?"<br/><span class='sale_info'>".lg(311)."</span>":"<br/><span class='sale_info'>".lg(309)."</span>"))?></a>
- <? if($myrow['m'.$topshop]>0 && $myrow['now_price'.$topshop]>0) { $total_price=$total_price+$all_price; $oplata_price=$total_price-$all_price_fact; ?>
- <div class="price_wrap">
- <? if($act_price > 0){echo "<div class='old_price'>".echo_price($price)."</div><div class='price'>".echo_price($act_price)."</div>";} else {echo "<div class='price'>".echo_price($price)."</div>";} ?><div class="mera"> x </div>
- <div class="item_num_wrap">
- <input ident="<?=$myrow['code']?>" class="item_num" type="number" step="<?=($myrow['ed']=='кг'?"0.1":"1")?>" min="<?=($myrow['ed']=='кг'?"0.1":"1")?>" max="<?=$myrow['m'.$topshop]?>" value="<?=$cart_obj[$myrow['code']]?>" title="Количество" />
- </div>
- <div class="mera"><?="<span>".$myrow['ed'].". = </span>"?></div>
- <div class='all_price'><?=echo_price($fact_price)?></div>
- <? if($act_price > 0){ echo "<div style='width:40px; display:inline-block;'></div>"; } ?>
- <div class="clear"></div>
- </div>
- <? } else { ?>
- <div class="price_wrap">
- <div class="itm_empty"><?=lg(236)?></div>
- </div>
- <? } ?>
- </div>
- <? echo "
- <div class='sale_wrap'>
- ".$actual."
- ".($act_price>0?"<div class='sale'>-".$myrow["percent".$topshop]."%</div>":"")."
- ".(!$block_discont?"<div class='sale' style:'right:57px;'>-10%</div>":"")."
- </div>";
- ?>
- </div>
- <a onclick="item_remove('<?=$myrow['code']?>')" class="remove_cart_item" title="<?=lg(227)?>"><i class="icon fa-times"></i></a>
- <div class="clear"></div>
- </div>
- <?
- /////////////
- }
- ?>
- <div class="clear"></div>
- <div class='total_price'><span id="del_price"><?=lg(244)?>: <span>0 тг.</span></span> <span id="total_price"><?=lg(245)?>: <span><?=echo_price($total_price)?></span></span></div>
- <? if($settings['discont_block_is']){ ?>
- <div id='skidos_price'>Скидка при покупке в интернет-магазине: <span><?=echo_price()?></span></div>
- <div id='oplata_price'>Итого к оплате: <span><?=echo_price()?></span></div>
- <? } ?>
- <div class="order_block">
- <div class="order_zag"><?=lg(253)?>:</div>
- <div class="short"><div class="row fio"><input type="text" placeholder="<?=lg(247)?>" name="fio" value="<?=($auth->status?$auth->reg_user['name']:"")?>"/></div></div>
- <div class="short"><div class="row tel"><input type="text" placeholder="<?=($auth->status?"+7".$auth->reg_user['tel']:lg(248))?>" id="order_phone" name="tel" /></div></div>
- <div class="short"><div class="row email"><input type="email" placeholder="email" name="email" value="<?=($auth->status?$auth->reg_user['email']:"")?>"/></div></div>
- <div class="radio_w">
- <div class="radio_l">
- <div><input type="radio" value="1" name="is_deliv" id="deliv_y" checked /><label for="deliv_y"><?=lg(288)?></label></div>
- <div><input type="radio" value="0" name="is_deliv" id="deliv_n" /><label for="deliv_n"><?=lg(289)?></label></div>
- </div>
- <div class="radio_r">
- <span>Оплата:</span>
- <div><input type="radio" value="1" name="pay" id="pay_1" checked /><label for="pay_1"><?=lg(290)?></label></div>
- <!-- div><input type="radio" value="2" name="pay" id="pay_2" /><label for="pay_2"><?=lg(291)?></label></div -->
- <div><input type="radio" value="3" name="pay" id="pay_3" /><label for="pay_3"><?=lg(292)?></label></div>
- </div>
- <div class="clear"></div>
- </div>
- <div class="short0">
- <div id="samovyvoz">
- <div class="descr sam">г. Актобе, пр. Санкибай-батыра 14/5; Ежедневно с 9:00 до 21:00; Инфо-центр: 8 (7132) 74-90-10</div>
- </div>
- </div>
- <div id="dostavka">
- <div class="short1">
- <div class="row district">
- <select id="district" name="district">
- <option value="0=0=0"><?=lg(254)?></option>
- <?
- $qry = mysql_query("SELECT * FROM `delivery` WHERE `public`=1 ORDER BY `code` ASC");
- while($drow = mysql_fetch_assoc($qry)){
- echo "<option value='".$drow['code']."=".$drow['price']."=".$drow['id']."'>".$drow['name_'.$lang]."</option>";
- }
- ?>
- </select>
- </div>
- </div>
- <div class="short1"><div class="row sadress"><input type="text" placeholder="<?=lg(250)?>" name="address" value=""/></div></div>
- </div>
- <div class="clear"></div>
- <div class="short0"><div class="descr"><input type="text" placeholder="<?=lg(255)?>" name="descr" value=""/></div></div>
- <p>
- <input type="checkbox" id="agree" style="margin:0 10px; vertical-align:middle;"><label for="agree"><?=lg(238)?></label>
- </p>
- </div>
- <!--div class='cart_ok_wrap'><input class="button_red" type="button" onclick="cart_order(); ym(85041187,'reachGoal','target1')" value="<?=lg(256)?>" /></div-->
- </form>
- <div id="return_msg"></div>
- </div>
- <script>
- var totalPrice = <?=$total_price?>;
- var delivPrice = 0;
- var delivFree = 3000;
- function cart_clear(){
- cart = {};
- setCookie('cart', '{}');
- $('#count_cart').html('(0)');
- $('.like_btn.act').removeClass('act');
- $('#order_form').hide();
- $('#return_msg').html("<div class='cart_empty' style='width:100%'><?=lg(237)?></div>");
- }
- function cart_order(){
- $('#order_form').hide();
- $('#return_msg').html("<div class='cart_empty' style='width:100%'><img style='border:20px solid #fff;border-radius:20%;' src = 'view/home/images/load.gif'/></div>");
- //alert($('#order_form input[name=is_deliv]').val());
- var sendData = {
- fio: $('#order_form input[name=fio]').val(),
- tel: $('#order_form input[name=tel]').val(),
- address: $('#order_form input[name=address]').val(),
- descr: $('#order_form input[name=descr]').val(),
- delivery: $('#order_form select[name=district]').val(),
- is_deliv: $('#order_form input[name=is_deliv]:checked').val(),
- pay: $('#order_form input[name=pay]:checked').val(),
- items: {}
- };
- for (var key in cart) {
- sendData['items'][key]={};
- sendData['items'][key]['price'] = parseFloat($('#itm_'+key).attr('price_fact'));
- sendData['items'][key]['qty'] = cart[key];
- }
- //if($("#agree").prop("checked")){best=1;} else {best=0;}
- $.post("action/ajax.php?act=cart_order", { data: JSON.stringify(sendData), agree:$("#agree").prop("checked"), email:$('#order_form input[name=email]').val() }).done(function(data) {
- var dataArr = data.split('|');
- if(dataArr[0]=="ok"){
- $('#order_form').hide();
- $('#return_msg').html("<div><span>Заказ № "+dataArr[1]+" оформлен!</span><br>Ожидайте звонка оператора.<?=($auth->status?'<br><br><a href=\"'.$u.'orders\">Перейти в «Мои заказы»</a>':'')?></div>");
- cart = {};
- setCookie('cart', '{}');
- $('#count_cart').html('(0)');
- } else {
- alert(data);
- $('#order_form').show();
- $('#return_msg').empty();
- }
- });
- }
- function cart_price_update(){ //console.log(cart);
- totalPrice = 0; oplataPrice = 0;
- for (var key in cart) {
- var newPrice = parseFloat($('#itm_'+key).attr('price'))*cart[key];
- var newPriceFact = parseFloat($('#itm_'+key).attr('price_fact'))*cart[key];
- totalPrice = totalPrice + newPrice;
- oplataPrice = oplataPrice + newPriceFact;
- //$('#itm_'+key+' .all_price').html(newPrice.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ')+" тг.");
- $('#itm_'+key+' .all_price').html(Math.round(newPrice).toLocaleString()+" тг.");
- }
- if(totalPrice>=delivFree && delivArr[1]=='1500'){delivPrice=0;}else{delivPrice = parseInt(delivArr[1]);}
- $('#del_price span').html(Math.round(delivPrice).toLocaleString()+" тг.");
- let newttl = Math.round(totalPrice+delivPrice);
- let newttl_fact = Math.round(oplataPrice+delivPrice);
- $('#total_price span').html(newttl.toLocaleString()+" тг.");
- $('#oplata_price span').html(newttl_fact.toLocaleString()+" тг.");
- $('#skidos_price span').html(Math.round(newttl-newttl_fact).toLocaleString()+" тг.");
- }
- var delivArr = $('#district').val().split("=");
- function item_remove(ident){
- delete cart[ident];
- setCookie('cart', JSON.stringify(cart));
- cart_price_update();
- $('#itm_'+ident).remove();
- $('#count_cart').html('('+Object.keys(cart).length+')');
- $('.like_btn.act[item='+ident+']').removeClass('act');
- }
- jQuery(function($){
- $("#order_phone").mask("+7(999) 999-9999");
- $('.item_num').change(function(){
- cart[$(this).attr('ident')] = parseFloat($(this).val());
- setCookie('cart', JSON.stringify(cart));
- //cart[$(this).attr('ident')];
- cart_price_update();
- // $('#skidos_price span').html(Math.round(newttl/10).toLocaleString()+" тг.");
- // $('#oplata_price span').html(Math.round(newttl-(newttl/10)).toLocaleString()+" тг.");
- });
- $('#district').change(function(){ //alert(JSON.stringify(cart));
- delivArr = $(this).val().split("=");
- $('#del_price').css('display','inline');
- cart_price_update();
- });
- $("input[name='is_deliv']").change(function() {
- if ($(this).val()==1) {
- $('#samovyvoz').hide();
- $('#dostavka').show();
- } else {
- $('#dostavka').hide();
- $('#samovyvoz').show();
- }
- });
- });
- </script>
- <?
- } else {echo "<div class='cart_empty'>".lg(237)."</div>";} ?>
- </div>
- <a id="zclear_btn" title="<?=lg(257)?>" onclick="cart_clear();"><i style="font-size:29px;" class="fa fa-trash"></i></a>
Advertisement
Add Comment
Please, Sign In to add comment