app/proxy/entity/src/Eccube/Entity/CartItem.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Entity;
  13. use Doctrine\ORM\Mapping as ORM;
  14.     /**
  15.      * CartItem
  16.      *
  17.      * @ORM\Table(name="dtb_cart_item")
  18.      * @ORM\InheritanceType("SINGLE_TABLE")
  19.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  20.      * @ORM\HasLifecycleCallbacks()
  21.      * @ORM\Entity(repositoryClass="Eccube\Repository\CartItemRepository")
  22.      */
  23.     class CartItem extends \Eccube\Entity\AbstractEntity implements ItemInterface
  24.     {
  25.         use PointRateTrait, \Customize\Entity\CartItemTrait;
  26.         /**
  27.          * @var integer
  28.          *
  29.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  30.          * @ORM\Id
  31.          * @ORM\GeneratedValue(strategy="IDENTITY")
  32.          */
  33.         private $id;
  34.         /**
  35.          * @var string
  36.          *
  37.          * @ORM\Column(name="price", type="decimal", precision=12, scale=2, options={"default":0})
  38.          */
  39.         private $price 0;
  40.         /**
  41.          * @var string
  42.          *
  43.          * @ORM\Column(name="quantity", type="decimal", precision=10, scale=0, options={"default":0})
  44.          */
  45.         private $quantity 0;
  46.         /**
  47.          * @var \Eccube\Entity\ProductClass
  48.          *
  49.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass")
  50.          * @ORM\JoinColumns({
  51.          *   @ORM\JoinColumn(name="product_class_id", referencedColumnName="id")
  52.          * })
  53.          */
  54.         private $ProductClass;
  55.         /**
  56.          * @var \Eccube\Entity\Cart
  57.          *
  58.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Cart", inversedBy="CartItems", cascade={"persist"})
  59.          * @ORM\JoinColumns({
  60.          *   @ORM\JoinColumn(name="cart_id", referencedColumnName="id", onDelete="CASCADE")
  61.          * })
  62.          */
  63.         private $Cart;
  64.         /**
  65.          * sessionのシリアライズのために使われる
  66.          *
  67.          * @var int
  68.          */
  69.         private $product_class_id;
  70.         public function __sleep()
  71.         {
  72.             return ['product_class_id''price''quantity'];
  73.         }
  74.         /**
  75.          * @return int
  76.          */
  77.         public function getId()
  78.         {
  79.             return $this->id;
  80.         }
  81.         /**
  82.          * @param  integer  $price
  83.          *
  84.          * @return CartItem
  85.          */
  86.         public function setPrice($price)
  87.         {
  88.             $this->price $price;
  89.             return $this;
  90.         }
  91.         /**
  92.          * @return string
  93.          */
  94.         public function getPrice()
  95.         {
  96.             return $this->price;
  97.         }
  98.         /**
  99.          * @param  integer  $quantity
  100.          *
  101.          * @return CartItem
  102.          */
  103.         public function setQuantity($quantity)
  104.         {
  105.             $this->quantity $quantity;
  106.             return $this;
  107.         }
  108.         /**
  109.          * @return string
  110.          */
  111.         public function getQuantity()
  112.         {
  113.             return $this->quantity;
  114.         }
  115.         /**
  116.          * @return integer
  117.          */
  118.         public function getTotalPrice()
  119.         {
  120.             return $this->getPrice() * $this->getQuantity();
  121.         }
  122.         /**
  123.          * 商品明細かどうか.
  124.          *
  125.          * @return boolean 商品明細の場合 true
  126.          */
  127.         public function isProduct()
  128.         {
  129.             return true;
  130.         }
  131.         /**
  132.          * 送料明細かどうか.
  133.          *
  134.          * @return boolean 送料明細の場合 true
  135.          */
  136.         public function isDeliveryFee()
  137.         {
  138.             return false;
  139.         }
  140.         /**
  141.          * 手数料明細かどうか.
  142.          *
  143.          * @return boolean 手数料明細の場合 true
  144.          */
  145.         public function isCharge()
  146.         {
  147.             return false;
  148.         }
  149.         /**
  150.          * 値引き明細かどうか.
  151.          *
  152.          * @return boolean 値引き明細の場合 true
  153.          */
  154.         public function isDiscount()
  155.         {
  156.             return false;
  157.         }
  158.         /**
  159.          * 税額明細かどうか.
  160.          *
  161.          * @return boolean 税額明細の場合 true
  162.          */
  163.         public function isTax()
  164.         {
  165.             return false;
  166.         }
  167.         /**
  168.          * ポイント明細かどうか.
  169.          *
  170.          * @return boolean ポイント明細の場合 true
  171.          */
  172.         public function isPoint()
  173.         {
  174.             return false;
  175.         }
  176.         public function getOrderItemType()
  177.         {
  178.             // TODO OrderItemType::PRODUCT
  179.             $ItemType = new \Eccube\Entity\Master\OrderItemType();
  180.             return $ItemType;
  181.         }
  182.         /**
  183.          * @param ProductClass $ProductClass
  184.          *
  185.          * @return $this
  186.          */
  187.         public function setProductClass(ProductClass $ProductClass)
  188.         {
  189.             $this->ProductClass $ProductClass;
  190.             $this->product_class_id is_object($ProductClass) ?
  191.             $ProductClass->getId() : null;
  192.             return $this;
  193.         }
  194.         /**
  195.          * @return ProductClass
  196.          */
  197.         public function getProductClass()
  198.         {
  199.             return $this->ProductClass;
  200.         }
  201.         /**
  202.          * @return int|null
  203.          */
  204.         public function getProductClassId()
  205.         {
  206.             return $this->product_class_id;
  207.         }
  208.         public function getPriceIncTax()
  209.         {
  210.             // TODO ItemInterfaceに追加, Cart::priceは税込み金額が入っているので,フィールドを分ける必要がある
  211.             return $this->price;
  212.         }
  213.         /**
  214.          * @return Cart
  215.          */
  216.         public function getCart()
  217.         {
  218.             return $this->Cart;
  219.         }
  220.         /**
  221.          * @param Cart $Cart
  222.          */
  223.         public function setCart(Cart $Cart)
  224.         {
  225.             $this->Cart $Cart;
  226.             return $this;
  227.         }
  228.     }