質問 > フロント機能 > カート情報の取得箇所について |
フロント機能
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
yoshiaki |
投稿日時: 2016/6/29 13:45
対応状況: −−−
|
半人前 登録日: 2016/6/22 居住地: 投稿: 11 |
カート情報の取得箇所について 初歩的なことなのかもしれませんが、まだ勉強し始めでいろいろと調べたりソースを追いながらになってしまうため認識の誤り等があった場合はヒントなどをいただければと思っています。
商品を選択するとカートに、選択した商品が入っているかと思うのですが その商品の情報というのはセッションが持っているという形でしょうか? src\Eccube\ControllerProviderのFrontControllerProvider.phpから // cart $c->match('/cart', '\Eccube\Controller\CartController::index')->bind('cart'); $c->post('/cart/add', '\Eccube\Controller\CartController::add')->bind('cart_add'); $c->put('/cart/up/{productClassId}', '\Eccube\Controller\CartController::up')->bind('cart_up')->assert('productClassId', '\d+'); $c->put('/cart/down/{productClassId}', '\Eccube\Controller\CartController::down')->bind('cart_down')->assert('productClassId', '\d+'); // setquantity deprecated since 3.0.0, to be removed in 3.1 $c->put('/cart/setQuantity/{productClassId}/{quantity}', '\Eccube\Controller\CartController::setQuantity')->bind('cart_set_quantity')->assert('productClassId', '\d+')->assert('quantity', '\d+'); $c->put('/cart/remove/{productClassId}', '\Eccube\Controller\CartController::remove')->bind('cart_remove')->assert('productClassId', '\d+'); $c->match('/cart/buystep', '\Eccube\Controller\CartController::buystep')->bind('cart_buystep'); このようにカートに関する部分を確認し、CartController.phpの各メソッドが呼ばれるということがわかり カート画面を見る場合はcontrollerのindexメソッドということも理解ができました。 indexメソッドの最初で $Cart = $app['eccube.service.cart']->getCart(); このように書かれているため、 CartService.phpのgetCartメソッドを呼び出し処理が行われるかと思います。 この、CartService.phpのコンストラクタ部分にて $this->app = $app; $this->session = $app['session']; $this->entityManager = $app['orm.em']; if ($this->session->has('cart')) { $this->cart = $this->session->get('cart'); } else { $this->cart = new \Eccube\Entity\Cart(); } $this->loadProductClassFromCart(); $this->BaseInfo = $app['eccube.repository.base_info']->get(); この部分でセッションからカートの情報をとってきていると思うのですが認識はあっているでしょうか? お願いいたします。 |
tacky |
投稿日時: 2016/6/29 15:21
対応状況: −−−
|
長老 登録日: 2015/10/3 居住地: Tokyo 投稿: 277 |
Re: カート情報の取得箇所について 上記認識であっていると思います。
補足としましては。 src/Eccube/Controller/ProductController.php 270行目あたりにカートに商品をセットする記述があります。 $app['eccube.service.cart']->addProduct($addCartData['product_class_id'], $addCartData['quantity'])->save(); src/Eccube/Service/CartService.phpの addProductで商品の在庫や支払い・商品種別等などをチェックした後、 function save()でセッションにセットしています。 return $this->session->set('cart', $this->cart); その後おっしゃるとおりgetCart()で取得しています。 |
yoshiaki |
投稿日時: 2016/6/29 15:40
対応状況: −−−
|
半人前 登録日: 2016/6/22 居住地: 投稿: 11 |
Re: カート情報の取得箇所について 認識としてはあっていたようでほっとしております。
補足の部分もこちらから聞いていたわけではないのに ご丁寧に教えてくださりありがとうございます。 |
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | トップ |