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


PHP Product::getPrice方法代码示例

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


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

示例1: actionPayment

 public function actionPayment()
 {
     if (\Yii::$app->session->has('customer')) {
         $modelCustomer = new Customer();
         $infoCustomer = $modelCustomer->getInformation($_SESSION['customer']);
         $modelOrder = new Order();
         $modelOrderDetail = new OrderDetail();
         $modelProduct = new Product();
         $ids = array();
         foreach ($_SESSION['cart_items'] as $id => $quantity) {
             array_push($ids, $id);
         }
         $products = $modelProduct->getWithIDs($ids);
         if (\Yii::$app->request->post()) {
             $modelOrder->load(\Yii::$app->request->post());
             $modelOrder->save();
             $orderId = $modelOrder->id;
             foreach ($_SESSION['cart_items'] as $id => $quantity) {
                 $unitPrice = $modelProduct->getPrice($id) * $quantity;
                 \Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute();
             }
             \Yii::$app->session->remove('cart_items');
             return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']);
         } else {
             return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]);
         }
     } else {
         $this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']);
     }
 }
开发者ID:royutoan,项目名称:pianodanang,代码行数:30,代码来源:CartController.php

示例2:

        <th>Tổng tiền</th>
    </tr>
    <?php 
foreach ($orderDetails as $orderDetail) {
    ?>
    <tr>
        <td><?php 
    echo $orderDetail['productId'];
    ?>
</td>
        <td><?php 
    echo $modelProduct->getName($orderDetail['productId']);
    ?>
</td>
        <td><?php 
    echo number_format($modelProduct->getPrice($orderDetail['productId']));
    ?>
 VNĐ</td>
        <td><?php 
    echo $orderDetail['quantity'];
    ?>
</td>
        <td><strong><?php 
    echo number_format($modelProduct->getPrice($orderDetail['productId']) * $orderDetail['quantity']);
    ?>
 VNĐ</strong></td>
    </tr>
    <?php 
}
?>
</table>
开发者ID:royutoan,项目名称:pianodanang,代码行数:31,代码来源:view.php


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