public getCart ( ) : Eccube\Entity\Cart | ||
return | Eccube\Entity\Cart |
public function getCart()
{
foreach ($this->cart->getCartItems() as $CartItem) {
$ProductClass = $CartItem->getObject();
if (!$ProductClass) {
$this->loadProductClassFromCartItem($CartItem);
$ProductClass = $CartItem->getObject();
}
if ($ProductClass->getDelFlg() == Constant::DISABLED) {
// 商品情報が有効
$stockUnlimited = $ProductClass->getStockUnlimited();
if ($stockUnlimited == Constant::DISABLED && $ProductClass->getStock() < 1) {
// 在庫がなければカートから削除
$this->setError('cart.zero.stock');
$this->removeProduct($ProductClass->getId());
} else {
$quantity = $CartItem->getQuantity();
$saleLimit = $ProductClass->getSaleLimit();
if ($stockUnlimited == Constant::DISABLED && $ProductClass->getStock() < $quantity) {
// 購入数が在庫数を超えている場合、メッセージを表示
$this->setError('cart.over.stock');
} elseif (!is_null($saleLimit) && $saleLimit < $quantity) {
// 購入数が販売制限数を超えている場合、メッセージを表示
$this->setError('cart.over.sale_limit');
}
}
} else {
// 商品情報が削除されていたらエラー
$this->setError('cart.product.delete');
// カートから削除
$this->removeProduct($ProductClass->getId());
}
}
return $this->cart;
}
/** * 受注明細情報、配送商品情報を作成 * * @param Order $Order * @return Order */ public function getNewDetails(Order $Order) { // 受注詳細, 配送商品 foreach ($this->cartService->getCart()->getCartItems() as $item) { /* @var $ProductClass \Eccube\Entity\ProductClass */ $ProductClass = $item->getObject(); /* @var $Product \Eccube\Entity\Product */ $Product = $ProductClass->getProduct(); $quantity = $item->getQuantity(); // 受注明細情報を作成 $OrderDetail = $this->getNewOrderDetail($Product, $ProductClass, $quantity); $OrderDetail->setOrder($Order); $Order->addOrderDetail($OrderDetail); // 配送商品情報を作成 $this->getNewShipmentItem($Order, $Product, $ProductClass, $quantity); } return $Order; }