Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'core/init.php';
- include 'includes/head.php';
- include 'includes/navigation.php';
- include 'includes/headerpartial.php';
- if($cart_id != '') {
- $cartQ = $db->query("SELECT * FROM cart WHERE id = '{$cart_id}'");
- $result = mysqli_fetch_assoc($cartQ);
- $items = json_decode($result['items'],true);
- $i = 1;
- $sub_total = 0;
- $item_count = 0;
- }
- ?>
- <div class="col-md-12">
- <div class="row">
- <h2 class="text-center">Моя корзина</h2><hr>
- <?php if($cart_id == ''): ?>
- <div class="bg-danger">
- <p class="text-center text-danger">
- Ваша корзина пуста!
- </p>
- </div>
- <?php else: ?>
- <table class="table table-bordered table-condensed table-striped">
- <thead><th>#</th><th>Наименование</th><th>Цена</th><th>Количество</th><th>Общая стоимость</th></thead>
- <tbody>
- <?php
- foreach($items as $item) {
- $product_id = $item['id'];
- $productQ = $db->query("SELECT * FROM products WHERE id = '{$product_id}'");
- $product = mysqli_fetch_array($productQ);
- ?>
- <tr>
- <td><?=$i; ?></td>
- <td><?=$product['title'];?></td>
- <td><?=number_format($product['list_price']).' рублей'; ?></td>
- <td>
- <button class="btn btn-xs btn-default" onclick="update_cart('removeone','<?=$product['id']; ?>');">-</button>
- <?=$item['quantity']; ?>
- <?php if($item['quantity'] < 999): ?>
- <button class="btn btn-xs btn-default" onclick="update_cart('addone','<?=$product['id']; ?>');">+</button>
- <?php else: ?>
- <span class="text-danger">Max!</span>
- <?php endif; ?>
- </td>
- <td><?=number_format($item['quantity'] * $product['list_price']).' рублей'; ?></td>
- </tr>
- <?php
- $i++;
- $item_count += $item['quantity'];
- $sub_total += ($product['list_price'] * $item['quantity']);
- }
- $grand_total = $sub_total;
- ?>
- </tbody>
- </table>
- <legend>Итог:</legend>
- <table class="table table-bordered table-condensed text-right">
- <thead class="totals-table-header"><th>Всего товаров</th><th>К оплате</th></thead>
- <tbody>
- <tr>
- <td><?=$item_count.' ед.'; ?></td>
- <td class="bg-success"><?=number_format($grand_total).' рублей'; ?></td>
- </tr>
- </tbody>
- </table>
- <!-- Оформление заказа -->
- <button type="button" class="btn btn-primary pull-right" data-toggle="modal" data-target="#checkoutModal">
- <span class="glyphicon glyphicon-shopping-cart"></span> Оформить заказ >>
- </button>
- <!-- Modal -->
- <div class="modal fade" id="checkoutModal" tabindex="-1" role="dialog" aria-labelledby="checkoutModalLabel">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- <h4 class="modal-title" id="checkoutModalLabel">Оформление заказа</h4>
- </div>
- <div class="modal-body">
- <script type='text/javascript'>
- <!--
- function showhideBlocks(val){
- if (val == 0){
- document.getElementById('i1').style.display='none';
- }
- else{
- document.getElementById('i1').style.display='none';
- document.getElementById('i'+val).style.display='block';
- }
- }
- -->
- </script>
- <style type='text/css'>
- #i1,#i2,#i3{display:none}
- </style>
- <div class="row">
- <form action="https://demomoney.yandex.ru/eshop.xml" method="post" id="payment-form">
- <span id="payment-errors"></span>
- <input type="hidden" name="sub_total" value="<?=$sub_total;?>">
- <input type="hidden" name="grand_total" value="<?=$grand_total;?>">
- <input type="hidden" name="cart_id" value="<?=$cart_id;?>">
- <input name="shopId" value="129299" type="hidden">
- <input name="scid" value="551452" type="hidden">
- <input name="customerNumber" value="<?=$cart_id?>" type="hidden">
- <input name="sum" value="<?=$sub_total;?>" type="hidden">
- <input type="hidden" name="items" value="<?=$result['items']; ?>">
- <input type="hidden" name="description" value="<?=$item_count.' item'.(($item_count>1)?'s':'').' from Florentis.';?>">
- <div id="step1" style="display:block">
- <div class="form-group col-md-6">
- <label for="full_name">ФИО<span class="redStar">*</span>:</label>
- <input type="text" class="form-control" id="full_name" name="full_name">
- </div>
- <div class="form-group col-md-6">
- <label for="email">Email<span class="redStar">*</span>:</label>
- <input type="email" class="form-control" id="email" name="email">
- </div>
- <div class="form-group col-md-6">
- <label for="phone">Телефон<span class="redStar">*</span>:</label>
- <input type="text" class="form-control" id="phone" name="phone">
- </div>
- <div class="form-group col-md-6">
- <label for="notation">Комментарий:</label>
- <input type="text" class="form-control" id="notation" name="notation">
- </div>
- <div class="form-group col-md-6">
- <label for="delivery">Способ доставки<span class="redStar">*</span>:</label>
- <select class="form-control" id="delivery" name="delivery" onchange="showhideBlocks(this.value)">
- <option>-Выберите способ доставки-</option>
- <option value="1">Самовывоз</option>
- <option value="1">Доставка курьером</option>
- </select>
- </div>
- <div class="form-group col-md-6">
- <label for="recipient">Получатель<span class="redStar">*</span>:</label>
- <select class="form-control" id="recipient" name="recipient">
- <option>-Выберите получателя-</option>
- <option>Получаю сам(а)</option>
- <option>Получает другой человек</option>
- </select><br><br>
- </div>
- <div id="i1">
- <div class="modal-header">
- <h4 class="modal-title" id="checkoutModalLabel">Информация о получателе</h4>
- </div>
- <div class="modal-body">
- <div class="form-group col-md-6">
- <label for="full_name2">ФИО получателя<span class="redStar">*</span>:</label>
- <input type="text" class="form-control" id="full_name2" name="full_name2">
- </div>
- <div class="form-group col-md-6">
- <label for="phone2">Телефон получателя<span class="redStar">*</span>:</label>
- <input type="text" class="form-control" id="phone2" name="phone2">
- </div>
- <div class="form-group col-md-6">
- <label for="street">Адрес доставки<span class="redStar">*</span>:</label>
- <input type="text" class="form-control" id="street" name="street">
- </div>
- </div>
- </div>
- </div>
- <div id="step2" style="display:none">
- <div class="form-group col-md-3">
- <label for="name">Выберите способ оплаты:<span class="redStar">*</span>:</label>
- <input type="radio" name="pay-method" id="pay-method" value="Оплата при получении"> Оплата при получении<br>
- <input type="radio" name="pay-method" id="pay-method" value="Оплата через платежную систему"> Оплата по карте<br>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
- <button type="button" class="btn btn-primary" onclick="check_address();" id="next_button">Далее >></button>
- <button type="button" class="btn btn-primary" onclick="back_address();" id="back_button" style="display:none;">Назад</button>
- <button type="submit" class="btn btn-primary" id="checkout_button" style="display:none;">Отправить заказ >></button>
- </form>
- </div>
- </div>
- </div>
- </div>
- <?php endif; ?>
- </div>
- </div>
- <script>
- function back_address() {
- jQuery('#payment-errors').html("");
- jQuery('#payment-errors').html("");
- jQuery('#step1').css("display","block");
- jQuery('#step2').css("display","none");
- jQuery('#next_button').css("display","inline-block");
- jQuery('#back_button').css("display","none");
- jQuery('#checkout_button').css("display","none");
- jQuery('#checkoutModalLabel').html("Оформление заказа");
- }
- function check_address(){
- var data = {
- 'full_name' : jQuery('#full_name').val(),
- 'full_name2' : jQuery('#full_name2').val(),
- 'email' : jQuery('#email').val(),
- 'phone' : jQuery('#phone').val(),
- 'phone2' : jQuery('#phone2').val(),
- 'street' : jQuery('#street').val(),
- };
- jQuery.ajax({
- url : 'admin/parsers/check_address.php',
- method : 'POST',
- data : data,
- success : function(data){
- if(data != true){
- jQuery('#payment-errors').html(data);
- }
- if(data == true) {
- jQuery('#payment-errors').html("");
- jQuery('#step1').css("display","none");
- jQuery('#step2').css("display","block");
- jQuery('#next_button').css("display","none");
- jQuery('#back_button').css("display","inline-block");
- jQuery('#checkout_button').css("display","inline-block");
- jQuery('#checkoutModalLabel').html("Проверка данных и оплата");
- }
- },
- error : function(){alert("Произошло что-то непредвиденное...");},
- });
- }
- </script>
- <br><br><br>
- <?php
- include 'includes/footer.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement