質問 > フロント機能 > 購入必須商品の設定について |
フロント機能
フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
K9K9 |
投稿日時: 2017/4/12 22:33
対応状況: 解決済
|
半人前 登録日: 2016/6/2 居住地: 投稿: 12 |
Re: 購入必須商品の設定について 大変助かりました。ありがとうございます。やりたいことは実装できました。 後学の為、修正箇所をまとめます。
Ver3.0.14 インストールディレクトリ/src/Eccube/Controller内にある CartController.php public function 内(88行目付近)に下記追加 //カテゴリの商品がカートにあるか確認する $flg = false; $Cart = $app['eccube.service.cart']->getCart(); foreach ($Cart->getCartItems() as $CartItem) { $ProductClass = $CartItem->getObject(); $Product = $ProductClass ->getProduct(); foreach ($Product->getProductCategories() as $ProductCategory) { if ($ProductCategory->getCategoryId() == 1) { $flg = true; break 2; } } } //ここまで return $app->render( 'Cart/index.twig', array( 'Cart' => $Cart, 'least' => $least, 'quantity' => $quantity, 'is_delivery_free' => $isDeliveryFree, //category_ok_flgを渡すために追加↓ 'category_ok_flg' => $flg, ) ); app/template/テンプレートディレクトリ/Cart/index.twig のレジに進むの箇所を下記に変更 {% if category_ok_flg %} <p id="total_box__next_button" > <a href="{{ path('cart_buystep') }}" class="btn btn-success btn-block">レジに進む</a> </p> <p id="total_box__top_button"> <a href="{{ url('top') }}" class="btn btn-info btn-block">商品を追加する</a> </p> {% else %} <p id="total_box__top_button"> <a href="{{ url('product_list') }}?category_id=1" class="btn btn-info btn-block">カテゴリ1の商品を選んでください</a> </p> {% endif %} これで想定していた通りの動作ができました。 ありがとうございました。 |
フラット表示 | 前のトピック | 次のトピック |
題名 | 投稿者 | 日時 |
---|---|---|
購入必須商品の設定について | K9K9 | 2017/4/9 16:35 |
Re: 購入必須商品の設定について | 468 | 2017/4/9 19:59 |
Re: 購入必須商品の設定について | umebius | 2017/4/9 20:41 |
Re: 購入必須商品の設定について | 468 | 2017/4/10 9:16 |
Re: 購入必須商品の設定について | K9K9 | 2017/4/10 21:53 |
Re: 購入必須商品の設定について | Yuya.u | 2017/4/10 22:26 |
Re: 購入必須商品の設定について | K9K9 | 2017/4/11 21:49 |
Re: 購入必須商品の設定について | umebius | 2017/4/12 1:32 |
» Re: 購入必須商品の設定について | K9K9 | 2017/4/12 22:33 |
Re: 購入必須商品の設定について | umebius | 2017/4/13 12:56 |