Guest User

Untitled

a guest
Nov 28th, 2022
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.96 KB | None | 0 0
  1. <style>
  2. .zcontent{width:950px;}
  3. </style>
  4. <div class="cartview">
  5. <div class="head_block min">
  6. <span><?=lg(272)?></span>
  7. </div>
  8.  
  9. <? if($auth->status){ ?>
  10. <div class="production_filter_wrap"><div class="production_filter">
  11. <a class="act"><?=lg(226)?></a>
  12. <a class="z" href="/z/<?=$u?>cart_orders"><?=lg(232)?></a>
  13. <div class="clear"></div>
  14. </div></div>
  15. <? }
  16.  
  17.  
  18. $total_price=0;
  19. $oplata_price=0;
  20. if ($cartlist != '' && $cartlist != '{}'){
  21. $cart_ids = "";
  22. foreach($cart_obj as $key => $val){
  23. $cart_ids .= ",".$key;
  24. }
  25. $cart_ids = trim($cart_ids,',');
  26.  
  27. ?>
  28.  
  29. <div class="best_price itemsblock view4">
  30.  
  31. <form id="order_form" onsubmit="return false">
  32. <?
  33.  
  34. $result = mysql_query("SELECT * FROM `items` WHERE `code` IN ($cart_ids)");
  35. while($myrow = mysql_fetch_assoc($result)){
  36.  
  37. /////////////// блок товара
  38. $topshop = $cityrow['topshop'];
  39. $item_patch="upload/items/".$myrow['code']."/poster/min.jpg";
  40. if(!file_exists(ROOT_FOLDER.$item_patch)){$item_patch="images/nophoto.jpg";}
  41. $actual = "";
  42. $act_price = $myrow["act_price".$topshop];
  43. $price = $myrow['m'.$topshop]>0?$myrow["now_price".$topshop]:0;
  44.  
  45. if($myrow["act_price".$topshop] > 0){
  46. $act_arr = explode('¿',$myrow["act_date".$topshop]);
  47. $act_start = $act_arr[0];
  48. $act_stop = $act_arr[1];
  49. $time = time();
  50.  
  51. if(intval($act_stop) > intval($time)){$actual = "<div class='sale_info'>".lg(91)." ".time2date_min($act_stop)."</div>";} else {$act_price = 0;}
  52.  
  53. } else {
  54. $act_price = 0;
  55. }
  56.  
  57. $settings = mysql_fetch_assoc(mysql_query("SELECT * FROM settings WHERE id=1 LIMIT 1"));
  58. $block_cats = explode(PHP_EOL, $settings['discont_block_cats']);
  59. $block_items = explode(PHP_EOL, $settings['discont_block_items']);
  60. $block_discont=0;
  61. if(in_array($myrow['code'], $block_items)){
  62. $block_discont=1;
  63. } else {
  64. foreach($block_cats as $val){
  65. $val = rtrim($val,'0');
  66. if(stripos($myrow['cat'], $val)!== false){
  67. $block_discont=1;
  68. }
  69. }
  70. }
  71.  
  72. $fact_price=$price;
  73. if(!$block_discont && $fact_price){
  74. $fact_price=$fact_price-(($fact_price/100)*10);
  75. }
  76.  
  77. //if(!$auth->status || $auth->reg_user['id']!=1){$block_discont=1;} //////////////////// delete
  78. if(!$settings['discont_block_is']){$block_discont=1;} //////////////////// delete
  79.  
  80. $all_price = $myrow["now_price".$topshop]*$cart_obj[$myrow['code']];
  81. $all_price_fact = $fact_price*$cart_obj[$myrow['code']];
  82. ?>
  83. <div class="cartitem_wrap<?=($act_price>0?" action":"")?>" id="itm_<?=$myrow['code']?>" price="<?=$price?>" >
  84. <div class="itemblock" cat="<?=$myrow['cat']?>">
  85. <a href="<?=$u?>item/<?=$myrow['code']?>"><img src="<?=$item_patch?>"/></a>
  86. <div class="cont">
  87. <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>
  88. <? if($myrow['m'.$topshop]>0 && $myrow['now_price'.$topshop]>0) { $total_price=$total_price+$all_price; $oplata_price=$total_price-$all_price_fact; ?>
  89. <div class="price_wrap">
  90. <? 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>
  91. <div class="item_num_wrap">
  92. <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="Количество" />
  93. </div>
  94. <div class="mera"><?="<span>".$myrow['ed'].". = </span>"?></div>
  95. <div class='all_price'><?=echo_price($fact_price)?></div>
  96. <? if($act_price > 0){ echo "<div style='width:40px; display:inline-block;'></div>"; } ?>
  97. <div class="clear"></div>
  98.  
  99. </div>
  100. <? } else { ?>
  101. <div class="price_wrap">
  102. <div class="itm_empty"><?=lg(236)?></div>
  103. </div>
  104. <? } ?>
  105. </div>
  106. <? echo "
  107. <div class='sale_wrap'>
  108. ".$actual."
  109. ".($act_price>0?"<div class='sale'>-".$myrow["percent".$topshop]."%</div>":"")."
  110. ".(!$block_discont?"<div class='sale' style:'right:57px;'>-10%</div>":"")."
  111. </div>";
  112. ?>
  113. </div>
  114. <a onclick="item_remove('<?=$myrow['code']?>')" class="remove_cart_item" title="<?=lg(227)?>"><i class="icon fa-times"></i></a>
  115. <div class="clear"></div>
  116. </div>
  117. <?
  118. /////////////
  119. }
  120. ?>
  121. <div class="clear"></div>
  122. <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>
  123. <? if($settings['discont_block_is']){ ?>
  124. <div id='skidos_price'>Скидка при покупке в интернет-магазине: <span><?=echo_price()?></span></div>
  125. <div id='oplata_price'>Итого к оплате: <span><?=echo_price()?></span></div>
  126. <? } ?>
  127. <div class="order_block">
  128. <div class="order_zag"><?=lg(253)?>:</div>
  129. <div class="short"><div class="row fio"><input type="text" placeholder="<?=lg(247)?>" name="fio" value="<?=($auth->status?$auth->reg_user['name']:"")?>"/></div></div>
  130. <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>
  131. <div class="short"><div class="row email"><input type="email" placeholder="email" name="email" value="<?=($auth->status?$auth->reg_user['email']:"")?>"/></div></div>
  132.  
  133. <div class="radio_w">
  134. <div class="radio_l">
  135. <div><input type="radio" value="1" name="is_deliv" id="deliv_y" checked /><label for="deliv_y"><?=lg(288)?></label></div>
  136. <div><input type="radio" value="0" name="is_deliv" id="deliv_n" /><label for="deliv_n"><?=lg(289)?></label></div>
  137. </div>
  138. <div class="radio_r">
  139. <span>Оплата:</span>
  140. <div><input type="radio" value="1" name="pay" id="pay_1" checked /><label for="pay_1"><?=lg(290)?></label></div>
  141. <!-- div><input type="radio" value="2" name="pay" id="pay_2" /><label for="pay_2"><?=lg(291)?></label></div -->
  142. <div><input type="radio" value="3" name="pay" id="pay_3" /><label for="pay_3"><?=lg(292)?></label></div>
  143. </div>
  144. <div class="clear"></div>
  145. </div>
  146. <div class="short0">
  147. <div id="samovyvoz">
  148. <div class="descr sam">г. Актобе, пр. Санкибай-батыра 14/5; Ежедневно с 9:00 до 21:00; Инфо-центр: 8 (7132) 74-90-10</div>
  149. </div>
  150. </div>
  151. <div id="dostavka">
  152. <div class="short1">
  153. <div class="row district">
  154. <select id="district" name="district">
  155. <option value="0=0=0"><?=lg(254)?></option>
  156. <?
  157. $qry = mysql_query("SELECT * FROM `delivery` WHERE `public`=1 ORDER BY `code` ASC");
  158. while($drow = mysql_fetch_assoc($qry)){
  159. echo "<option value='".$drow['code']."=".$drow['price']."=".$drow['id']."'>".$drow['name_'.$lang]."</option>";
  160. }
  161. ?>
  162.  
  163. </select>
  164. </div>
  165. </div>
  166. <div class="short1"><div class="row sadress"><input type="text" placeholder="<?=lg(250)?>" name="address" value=""/></div></div>
  167. </div>
  168. <div class="clear"></div>
  169. <div class="short0"><div class="descr"><input type="text" placeholder="<?=lg(255)?>" name="descr" value=""/></div></div>
  170. <p>
  171. <input type="checkbox" id="agree" style="margin:0 10px; vertical-align:middle;"><label for="agree"><?=lg(238)?></label>
  172. </p>
  173. </div>
  174. <!--div class='cart_ok_wrap'><input class="button_red" type="button" onclick="cart_order(); ym(85041187,'reachGoal','target1')" value="<?=lg(256)?>" /></div-->
  175. </form>
  176. <div id="return_msg"></div>
  177. </div>
  178.  
  179.  
  180.  
  181. <script>
  182. var totalPrice = <?=$total_price?>;
  183. var delivPrice = 0;
  184. var delivFree = 3000;
  185.  
  186. function cart_clear(){
  187. cart = {};
  188. setCookie('cart', '{}');
  189. $('#count_cart').html('(0)');
  190. $('.like_btn.act').removeClass('act');
  191. $('#order_form').hide();
  192. $('#return_msg').html("<div class='cart_empty' style='width:100%'><?=lg(237)?></div>");
  193. }
  194.  
  195. function cart_order(){
  196. $('#order_form').hide();
  197. $('#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>");
  198. //alert($('#order_form input[name=is_deliv]').val());
  199. var sendData = {
  200. fio: $('#order_form input[name=fio]').val(),
  201. tel: $('#order_form input[name=tel]').val(),
  202. address: $('#order_form input[name=address]').val(),
  203. descr: $('#order_form input[name=descr]').val(),
  204. delivery: $('#order_form select[name=district]').val(),
  205. is_deliv: $('#order_form input[name=is_deliv]:checked').val(),
  206. pay: $('#order_form input[name=pay]:checked').val(),
  207. items: {}
  208. };
  209.  
  210. for (var key in cart) {
  211. sendData['items'][key]={};
  212. sendData['items'][key]['price'] = parseFloat($('#itm_'+key).attr('price_fact'));
  213. sendData['items'][key]['qty'] = cart[key];
  214. }
  215.  
  216. //if($("#agree").prop("checked")){best=1;} else {best=0;}
  217.  
  218. $.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) {
  219. var dataArr = data.split('|');
  220. if(dataArr[0]=="ok"){
  221. $('#order_form').hide();
  222. $('#return_msg').html("<div><span>Заказ № "+dataArr[1]+" оформлен!</span><br>Ожидайте звонка оператора.<?=($auth->status?'<br><br><a href=\"'.$u.'orders\">Перейти в «Мои заказы»</a>':'')?></div>");
  223. cart = {};
  224. setCookie('cart', '{}');
  225. $('#count_cart').html('(0)');
  226. } else {
  227. alert(data);
  228. $('#order_form').show();
  229. $('#return_msg').empty();
  230. }
  231. });
  232.  
  233. }
  234.  
  235.  
  236. function cart_price_update(){ //console.log(cart);
  237. totalPrice = 0; oplataPrice = 0;
  238. for (var key in cart) {
  239. var newPrice = parseFloat($('#itm_'+key).attr('price'))*cart[key];
  240. var newPriceFact = parseFloat($('#itm_'+key).attr('price_fact'))*cart[key];
  241. totalPrice = totalPrice + newPrice;
  242. oplataPrice = oplataPrice + newPriceFact;
  243.  
  244. //$('#itm_'+key+' .all_price').html(newPrice.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ')+" тг.");
  245. $('#itm_'+key+' .all_price').html(Math.round(newPrice).toLocaleString()+" тг.");
  246. }
  247. if(totalPrice>=delivFree && delivArr[1]=='1500'){delivPrice=0;}else{delivPrice = parseInt(delivArr[1]);}
  248. $('#del_price span').html(Math.round(delivPrice).toLocaleString()+" тг.");
  249. let newttl = Math.round(totalPrice+delivPrice);
  250. let newttl_fact = Math.round(oplataPrice+delivPrice);
  251. $('#total_price span').html(newttl.toLocaleString()+" тг.");
  252. $('#oplata_price span').html(newttl_fact.toLocaleString()+" тг.");
  253. $('#skidos_price span').html(Math.round(newttl-newttl_fact).toLocaleString()+" тг.");
  254. }
  255.  
  256.  
  257. var delivArr = $('#district').val().split("=");
  258. function item_remove(ident){
  259. delete cart[ident];
  260. setCookie('cart', JSON.stringify(cart));
  261. cart_price_update();
  262. $('#itm_'+ident).remove();
  263. $('#count_cart').html('('+Object.keys(cart).length+')');
  264. $('.like_btn.act[item='+ident+']').removeClass('act');
  265. }
  266.  
  267. jQuery(function($){
  268. $("#order_phone").mask("+7(999) 999-9999");
  269.  
  270. $('.item_num').change(function(){
  271. cart[$(this).attr('ident')] = parseFloat($(this).val());
  272. setCookie('cart', JSON.stringify(cart));
  273. //cart[$(this).attr('ident')];
  274. cart_price_update();
  275. // $('#skidos_price span').html(Math.round(newttl/10).toLocaleString()+" тг.");
  276. // $('#oplata_price span').html(Math.round(newttl-(newttl/10)).toLocaleString()+" тг.");
  277. });
  278.  
  279.  
  280. $('#district').change(function(){ //alert(JSON.stringify(cart));
  281. delivArr = $(this).val().split("=");
  282. $('#del_price').css('display','inline');
  283. cart_price_update();
  284. });
  285.  
  286. $("input[name='is_deliv']").change(function() {
  287. if ($(this).val()==1) {
  288. $('#samovyvoz').hide();
  289. $('#dostavka').show();
  290. } else {
  291. $('#dostavka').hide();
  292. $('#samovyvoz').show();
  293. }
  294.  
  295. });
  296. });
  297. </script>
  298.  
  299. <?
  300. } else {echo "<div class='cart_empty'>".lg(237)."</div>";} ?>
  301. </div>
  302. <a id="zclear_btn" title="<?=lg(257)?>" onclick="cart_clear();"><i style="font-size:29px;" class="fa fa-trash"></i></a>
  303.  
Advertisement
Add Comment
Please, Sign In to add comment