EC-CUBEは、デフォルトでは「商品種別」によってカートを分ける仕様になっている。もし、EC-CUBEの全ての商品を、同時に注文できない(カートを分ける)ようにするには、どうしたらよいかまとめる。
- 新しいAllocatorの作成
- cart.yamlを作成
/app/Customize/Service/Cart/AllItemCartAllocator.php を作成
<?php
namespace Customize\Service\Cart;
use Eccube\Entity\CartItem;
use Eccube\Service\Cart\CartItemAllocator;
class AllItemCartAllocator implements CartItemAllocator
{
public function allocate(CartItem $Item)
{
$ProductClass = $Item->getProductClass();
return $ProductClass->getId();
}
}
/app/config/eccube/packages/cart.yaml を作成
services:
Eccube\Service\Cart\CartItemAllocator:
class: Customize\Service\Cart\AllItemCartAllocator
<参照記事>
購入フローのカスタマイズ – < for EC-CUBE 4 Developers />
EC-CUBE4系で送料がどのように計算されるのか解説します | (株)カジヤ