/** * カートを取得します。 * * @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; }
public function getCart() { foreach ($this->cart->getCartItems() as $CartItem) { $ProductClass = $this->entityManager->getRepository($CartItem->getClassName())->find($CartItem->getClassId()); $CartItem->setObject($ProductClass); } return $this->cart; }
public function getCart() { /* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */ $softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete'); $softDeleteFilter->setExcludes(array('Eccube\\Entity\\ProductClass')); foreach ($this->cart->getCartItems() as $CartItem) { $ProductClass = $this->entityManager->getRepository($CartItem->getClassName())->find($CartItem->getClassId()); // 商品情報が削除されたらカートからも削除 if ($ProductClass->getDelFlg() == Constant::DISABLED) { $CartItem->setObject($ProductClass); } else { $this->setError('cart.product.delete'); $this->removeProduct($ProductClass->getId()); } } return $this->cart; }
public function getCart() { /* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */ $softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete'); $softDeleteFilter->setExcludes(array('Eccube\\Entity\\ProductClass')); foreach ($this->cart->getCartItems() as $CartItem) { $ProductClass = $this->entityManager->getRepository($CartItem->getClassName())->find($CartItem->getClassId()); $stockUnlimited = $ProductClass->getStockUnlimited(); if ($ProductClass->getDelFlg() == Constant::DISABLED) { // 商品情報が有効 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'); } else { if (!is_null($saleLimit) && $saleLimit < $quantity) { // 販売制限数が購入数を超えている場合、メッセージを表示 $this->setError('cart.over.sale_limit'); } } // カートに追加 $CartItem->setObject($ProductClass); } } else { // 商品情報が削除されていたらエラー $this->setError('cart.product.delete'); // カートから削除 $this->removeProduct($ProductClass->getId()); } } return $this->cart; }