当前位置: 首页>>代码示例>>PHP>>正文


PHP Basket::countItem方法代码示例

本文整理汇总了PHP中Basket::countItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Basket::countItem方法的具体用法?PHP Basket::countItem怎么用?PHP Basket::countItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Basket的用法示例。


在下文中一共展示了Basket::countItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
				<!-- Collect the nav links, forms, and other content for toggling -->
					<ul class="nav navbar-nav">
						<li>
							<a class="navbar-brand" href="/">Главная</a>
						</li>
						<li>
							<a class="navbar-brand" href="/catalog/">Каталог</a>
						</li>
						<li>
							<a class="navbar-brand" href="/basket/">Корзина
							<span id="basket-count"> <?php 
echo Basket::countItem();
?>
 </span>
							</a>
						</li>
						<?php 
if (User::isGuest()) {
    ?>
						<li>
							<a class="navbar-brand" href="/user/login/">Вход</a>
						</li>
						<li>
							<a class="navbar-brand" href="/user/register/">Регистрация</a>
						</li>
						<?php 
} else {
开发者ID:AlexGryban,项目名称:Eshop_for_example,代码行数:31,代码来源:header.php

示例2: actionOrder

 public function actionOrder()
 {
     $platform = array();
     $errors = array();
     $userName = '';
     $userEmail = '';
     $userPhone = '';
     $userComment = '';
     $platform = Platform::getPlatformList();
     $result = false;
     if (isset($_POST['submit'])) {
         $userName = $_POST['name'];
         $userEmail = $_POST['email'];
         $userPhone = $_POST['phone'];
         $userComment = $_POST['message'];
         $errors = false;
         if (!User::validateUsername($userName)) {
             $errors[] = "Неверное имя";
         }
         if (!User::validateEmail($userEmail)) {
             $errors[] = "Неверный Email";
         }
         if (!User::validatePhone($userPhone)) {
             $errors[] = "Неккоректный телефон";
         }
         if ($errors == false) {
             $productsBasket = Basket::getProducts();
             if (User::isGuest()) {
                 $userId = false;
             } else {
                 $userId = User::validateLogged();
             }
             $result = Order::save($userName, $userEmail, $userPhone, $userComment, $userId, $productsBasket);
             if ($result) {
                 $adminEmail = "alexey.vnu@gmail.com";
                 $subject = "Новый заказ";
                 mail($adminEmail, $subject, $userComment);
                 Basket::clear();
             }
         } else {
             $productsInBasket = Basket::getProducts();
             $productId = array_keys($productsInBasket);
             $products = Products::getProductsByIdInBasket($productId);
             $totalPrice = Basket::getTotalPrice($products);
             $total = array_sum($totalPrice);
             $totalQuantity = Basket::countItem();
         }
     } else {
         $productsInbasket = Basket::getProducts();
         if ($productsInbasket == false) {
             header("Loaction: /");
         } else {
             $productId = array_keys($productsInbasket);
             $products = Products::getProductsByIdInBasket($productId);
             $totalPrice = Basket::getTotalPrice($products);
             $totalQuantity = Basket::countItem();
             $userName = false;
             $userEmail = false;
             $userPhone = false;
             $userComment = false;
             if (User::isGuest()) {
             } else {
                 $userId = User::validateLogged();
                 $user = User::getUserById($userId);
                 $userName = $user['name'];
                 $userEmail = $user['email'];
             }
         }
     }
     require_once ROOT . "/views/basket/order.php";
     return true;
 }
开发者ID:Evkazolinium,项目名称:Eshop_for_example,代码行数:72,代码来源:BasketController.php

示例3:

                        <div class="center">
                            <p>
                              </p>
                            <td class="col-sm-1 col-md-2">
                                
                                

                                
                                
                            <div class="input-group">
                                  <span class="input-group-btn">
                                      <button type="button" class="btn btn-danger btn-number" value="-" data-id="<?=$product['id']?>" id="minus" >
                                        <span class="glyphicon glyphicon-minus"></span>
                                      </button>
                                  </span>
                                <span type="text" id="count" class="form-control input-number" value="<?=Basket::countItem();?>"  data-id="<?=$product['id']?>" ></span>
                                  <span class="input-group-btn">
                                      <button type="button" class="btn btn-success btn-number-plus" value="+" data-id="<?=$product['id']?>" id="plus">
                                          <span class="glyphicon glyphicon-plus"></span>
                                      </button>
                                  </span>
                              </div>
                            </td>
                            </div>
                        <td class="col-sm-1 col-md-1 text-center"><strong><?=$totalPrice[$i];?></strong></td>
                        <td class="col-sm-1 col-md-1">
                        <a href="/basket/delete/<?=$product['id'];?>" type="button" class="btn btn-danger">
                            <span class="glyphicon glyphicon-remove"></span> Удалить
                        </a></td>
                    </tr>
					<?php $i++; endforeach;?>
开发者ID:Evkazolinium,项目名称:Eshop_for_example,代码行数:31,代码来源:index.php


注:本文中的Basket::countItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。