Eccube\Service\CartService::getProductTypes PHP Method

getProductTypes() public method

public getProductTypes ( ) : array
return array
    public function getProductTypes()
    {
        $productTypes = array();
        foreach ($this->getCart()->getCartItems() as $item) {
            /* @var $ProductClass \Eccube\Entity\ProductClass */
            $ProductClass = $item->getObject();
            $productTypes[] = $ProductClass->getProductType();
        }
        return array_unique($productTypes);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * お届け先情報を作成
  *
  * @param Order $Order
  * @param Customer $Customer
  * @param $deliveries
  * @return Order
  */
 public function getNewShipping(Order $Order, Customer $Customer, $deliveries)
 {
     // カートに保持されている商品種別を取得
     $productTypes = $this->cartService->getProductTypes();
     if ($this->BaseInfo->getOptionMultipleShipping() == Constant::ENABLED && count($productTypes) > 1) {
         // 複数配送対応
         $productType = array();
         foreach ($deliveries as $Delivery) {
             if (!in_array($Delivery->getProductType()->getId(), $productType)) {
                 $Shipping = new Shipping();
                 $this->copyToShippingFromCustomer($Shipping, $Customer)->setOrder($Order)->setDelFlg(Constant::DISABLED);
                 // 配送料金の設定
                 $this->setShippingDeliveryFee($Shipping, $Delivery);
                 $this->em->persist($Shipping);
                 $Order->addShipping($Shipping);
             }
             $productType[] = $Delivery->getProductType()->getId();
         }
     } else {
         $Shipping = new Shipping();
         $this->copyToShippingFromCustomer($Shipping, $Customer)->setOrder($Order)->setDelFlg(Constant::DISABLED);
         $Delivery = $deliveries[0];
         // 配送料金の設定
         $this->setShippingDeliveryFee($Shipping, $Delivery);
         $this->em->persist($Shipping);
         $Order->addShipping($Shipping);
     }
     return $Order;
 }
All Usage Examples Of Eccube\Service\CartService::getProductTypes