Erric_Zhu 发表于 2012-6-19 11:43:48

Erric_Zhu 发表于 2012-6-19 11:27 static/image/common/back.gif
怎么发给你呢.你的QQ或其他联系方式?

我贴在这儿吧:

CONTROLLER:
function update() {
      $data = array(
            'rowid' => $this->input->post('rowid'),
            'qty' => $this->input->post('qty'),
      );
                  print_r($data);

      $this->cart->update($data);
    }

View:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
        <title>Shoping Cart</title>
        <meta charset="UTF-8">
        <style type="text/css">
                body {
                        font: 13px Arial;
                }
                #products {
                        text-align: center; float: left;
                }
                #products ul {
                        list-style-type: none; margin: 0px;
                }
                #products li {
                        width: 150px; padding: 4px; margin: 8px;
                        border: 1px solid #ddd; background-color: #eee;
                        -moz-border-radius: 4px; -webkit-border-radius: 4px;
                }
                #products .name {
                        font-size: 15px; margin: 5px;
                }
                #products .price {
                        margin: 5px;
                }
                #products .option {
                        margin: 5px;
                }

                #cart {
                        padding: 4px; margin: 8px; float: left;
                        border: 1px solid #ddd; background-color: #eee;
                        -moz-border-radius: 4px; -webkit-border-radius: 4px;
                }
                #cart table {
                        width: 320px; border-collapse: collapse;
                        text-align: left;
                }
                #cart th {
                        border-bottom: 1px solid #aaa;
                }
                #cart caption {
                        font-size: 15px; height: 30px; text-align: left;
                }
                #cart .total {
                        height: 40px;
                }
                #cart .remove a {
                        color: red;
                }
        </style>
</head>
<body>
        <div id="products">
        <ul>
                <?php foreach ($products as $product): ?>
                <li>
                        <?php echo form_open('shop/add'); ?>
                        <div class="name"><?php echo $product->name; ?></div>
                        <div class="thumb">
                        <?php echo img(array(
                                'src' => 'layouts/images/' . $product->image,
                                'class' => 'thumb',
                                'alt' => $product->name
                        )); ?>
                        </div>
                        <div class="price">$<?php echo $product->price; ?></div>
                        <div class="option">
                                <?php if ($product->option_name): ?>
                                        <?php echo form_label($product->option_name, 'option_'. $product->id); ?>
                                        <?php echo form_dropdown(
                                                $product->option_name,
                                                $product->option_values,
                                                NULL,
                                                'id="option_'. $product->id.'"'
                                        ); ?>
                                <?php endif; ?>
                        </div>

                        <?php echo form_hidden('id', $product->id); ?>
                        <?php echo form_submit('action', 'Add to Cart'); ?>
                        <?php echo form_close(); ?>
                </li>
                <?php endforeach; ?>
        </ul>
        </div>

        <?php if ($cart = $this->cart->contents()): ?>
        <div id="cart">
                <table>
                <caption>Shopping Cart</caption>
                <thead>
                        <tr>
                                <th>Item Name</th>
                                <th>Qty</th>
                                <th>Option</th>
                                <th>Price</th>

                                <th>Action</th>
                                <th></th>

                        </tr>
                </thead>

                <?php foreach ($cart as $item): ?>
          <?php echo form_open('shop');?>
                        <tr>
                                <td><?php echo $item['name']; ?></td>
      <td><?php echo form_input(array('name' => 'qty', 'value' => $item['qty'], 'maxlength' => '3', 'size' => '1')); ?></td>
                                <td>
                                        <?php if ($this->cart->has_options($item['rowid'])) {
                                                foreach ($this->cart->product_options($item['rowid']) as $option => $value) {
                                                        echo $option . ": <em>" . $value . "</em>";
                                                }

                                        } ?>
                                </td>

                                <td>$<?php echo $item['subtotal']; ?></td>
                                <td class="remove">
                                        <?php echo anchor('shop/update/'.$item['rowid'],'Update'); ?>
                                </td>

                                <td class="remove">
                                        <?php echo anchor('shop/remove/'.$item['rowid'],'Delete'); ?>
                                </td>
                        </tr>
                <?php endforeach; ?>

                <tr class="total">
                        <td colspan="3"><strong>Total</strong></td>
                        <td>$<?php echo $this->cart->total(); ?></td>
                </tr>
                </table>
        </div>
        <?php endif; ?>
</body>
</html>

ilci 发表于 2012-6-19 12:49:02

你有Q吗 我加你好了

Erric_Zhu 发表于 2012-6-19 13:26:15

ilci 发表于 2012-6-19 12:49 static/image/common/back.gif
你有Q吗 我加你好了

3922373,谢谢.

Erric_Zhu 发表于 2012-6-19 15:09:18

已解决.谢谢各位.特别谢谢Jeongee.

ilci 发表于 2012-6-19 17:16:17

好的 解决就好了{:1_1:}

Erric_Zhu 发表于 2012-6-20 09:35:55

ilci 发表于 2012-6-19 17:16 static/image/common/back.gif
好的 解决就好了

thxks a lot

马谎言 发表于 2013-12-5 15:01:21

Erric_Zhu 发表于 2012-6-20 09:35 static/image/common/back.gif
thxks a lot

问一下 问题出在哪儿了 刚好要写这一块
页: 1 [2]
查看完整版本: CI购物车问题:不能更新数量呢