| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * This file is part of EC-CUBE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * http://www.lockon.co.jp/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * This program is free software; you can redistribute it and/or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * modify it under the terms of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * as published by the Free Software Foundation; either version 2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * of the License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * along with this program; if not, write to the Free Software | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | namespace Eccube\Service; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Doctrine\ORM\EntityManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Eccube\Common\Constant; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Eccube\Entity\CartItem; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use Eccube\Entity\Master\Disp; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use Eccube\Entity\ProductClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use Eccube\Exception\CartException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use Symfony\Component\HttpFoundation\Session\Session; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | class CartService | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** @var \Eccube\Application */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public $app; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @var Session | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     private $session; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @var EntityManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     private $entityManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @var \Eccube\Entity\Cart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     private $cart; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @var \Eccube\Entity\BaseInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     private $BaseInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     private $errors = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     private $ProductType = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     private $messages = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     private $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 279 |  |     public function __construct(\Eccube\Application $app) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 279 |  |         $this->app = $app; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 279 |  |         $this->session = $app['session']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 279 |  |         $this->entityManager = $app['orm.em']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 279 |  |         if ($this->session->has('cart')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             $this->cart = $this->session->get('cart'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 279 |  |             $this->cart = new \Eccube\Entity\Cart(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 279 |  |         $this->loadProductClassFromCart(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 279 |  |         $this->BaseInfo = $app['eccube.repository.base_info']->get(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * カートに保存されている商品の ProductClass エンティティを読み込み、カートへ設定します。 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 279 |  |     protected function loadProductClassFromCart() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         /* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 279 |  |         $softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 279 |  |         $excludes = $softDeleteFilter->getExcludes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 279 |  |         $softDeleteFilter->setExcludes(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 279 |  |             'Eccube\Entity\ProductClass', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 279 |  |         foreach ($this->cart->getCartItems() as $CartItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 279 |  |             $this->loadProductClassFromCartItem($CartItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 279 |  |         $softDeleteFilter->setExcludes($excludes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * CartItem に対応する ProductClass を設定します。 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @param CartItem $CartItem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 137 |  |     protected function loadProductClassFromCartItem(CartItem $CartItem) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $ProductClass = $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 137 |  |             ->entityManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 137 |  |             ->getRepository($CartItem->getClassName()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 137 |  |             ->find($CartItem->getClassId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 137 |  |         $CartItem->setObject($ProductClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 137 |  |         if (is_null($this->ProductType) && $ProductClass->getDelFlg() == Constant::DISABLED) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             $this->setCanAddProductType($ProductClass->getProductType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 177 |  |     public function setCanAddProductType(\Eccube\Entity\Master\ProductType $ProductType) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 177 |  |         if (is_null($this->ProductType)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 177 |  |             $this->ProductType = $ProductType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 177 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 170 |  |     public function save() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 170 |  |         return $this->session->set('cart', $this->cart); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 14 |  |     public function unlock() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 | 14 |  |         $this->cart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 | 14 |  |             ->setLock(false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 14 |  |             ->setPreOrderId(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 120 |  |     public function lock() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 120 |  |         $this->cart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 | 120 |  |             ->setLock(true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 120 |  |             ->setPreOrderId(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 110 |  |     public function isLocked() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 110 |  |         return $this->cart->getLock(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * @param  string $pre_order_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 98 |  |     public function setPreOrderId($pre_order_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 98 |  |         $this->cart->setPreOrderId($pre_order_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 98 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 97 |  |     public function getPreOrderId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 97 |  |         return $this->cart->getPreOrderId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 29 |  |     public function clear() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 29 |  |         $this->cart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 | 29 |  |             ->setPreOrderId(null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 29 |  |             ->setLock(false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 | 29 |  |             ->clearCartItems(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 29 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 | 1 |  |     public function getCanAddProductType() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 1 |  |         return $this->ProductType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      * @param  string $productClassId | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * @param  integer $quantity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 133 |  |     public function addProduct($productClassId, $quantity = 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 | 133 |  |         $quantity += $this->getProductQuantity($productClassId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 | 133 |  |         $this->setProductQuantity($productClassId, $quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 | 132 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      * @param  string $productClassId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      * @return integer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 142 |  |     public function getProductQuantity($productClassId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 | 142 |  |         $CartItem = $this->cart->getCartItemByIdentifier('Eccube\Entity\ProductClass', (string)$productClassId); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 | 142 |  |         if ($CartItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 | 51 |  |             return $CartItem->getQuantity(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 | 139 |  |             return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      * @param  \Eccube\Entity\ProductClass|integer $ProductClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |      * @param  integer $quantity | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      * @throws CartException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 | 180 |  |     public function setProductQuantity($ProductClass, $quantity) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 180 |  |         if (!$ProductClass instanceof ProductClass) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 | 175 |  |             $ProductClass = $this->entityManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 | 175 |  |                 ->getRepository('Eccube\Entity\ProductClass') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 | 175 |  |                 ->find($ProductClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 | 175 |  |             if (!$ProductClass) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 | 3 |  |                 throw new CartException('cart.product.delete'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 | 177 |  |         if (!$this->isProductDisplay($ProductClass)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 | 4 |  |             throw new CartException('cart.product.not.status'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 | 176 |  |         $productName = $this->getProductName($ProductClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         // 商品種別に紐づく配送業者を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 | 176 |  |         $deliveries = $this->app['eccube.repository.delivery']->getDeliveries($ProductClass->getProductType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 | 176 |  |         if (count($deliveries) == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             // 商品種別が存在しなければエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $this->removeProduct($ProductClass->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |             $this->addError('cart.product.not.producttype', $productName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             throw new CartException('cart.product.not.producttype'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 | 176 |  |         $this->setCanAddProductType($ProductClass->getProductType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 | 176 |  |         if ($this->BaseInfo->getOptionMultipleShipping() != Constant::ENABLED) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 | 128 |  |             if (!$this->canAddProduct($ProductClass->getId())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |                 // 複数配送対応でなければ商品種別が異なればエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 | 128 |  |                 throw new CartException('cart.product.type.kind'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             // 複数配送の場合、同一支払方法がなければエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 | 48 |  |             if (!$this->canAddProductPayment($ProductClass->getProductType())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 | 1 |  |                 throw new CartException('cart.product.payment.kind'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 | 176 |  |         $tmp_subtotal = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 | 176 |  |         $tmp_quantity = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 | 176 |  |         foreach ($this->getCartObj()->getCartItems() as $cartitem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 | 57 |  |             $pc = $cartitem->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 | 57 |  |             if ($pc->getId() != $ProductClass->getId()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |                 // 追加された商品以外のtotal priceをセット | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 | 176 |  |                 $tmp_subtotal += $cartitem->getTotalPrice(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 | 176 |  |         for ($i = 0; $i < $quantity; $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 | 176 |  |             $tmp_subtotal += $ProductClass->getPrice02IncTax(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 | 176 |  |             if ($tmp_subtotal > $this->app['config']['max_total_fee']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 | 2 |  |                 $this->setError('cart.over.price_limit'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 | 2 |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 | 175 |  |             $tmp_quantity++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 | 176 |  |         if ($tmp_quantity == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             // 数量が0の場合、エラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 | 1 |  |             throw new CartException('cart.over.price_limit'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         // 制限数チェック(在庫不足の場合は、処理の中でカート内商品を削除している) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 | 175 |  |         $quantity = $this->setProductLimit($ProductClass, $productName, $tmp_quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		// 新しい数量でカート内商品を登録する | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 | 175 |  |         if (0 < $quantity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 | 174 |  |             $CartItem = new CartItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |             $CartItem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 | 174 |  |                 ->setClassName('Eccube\Entity\ProductClass') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 | 174 |  |                 ->setClassId((string)$ProductClass->getId()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 | 174 |  |                 ->setPrice($ProductClass->getPrice02IncTax()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 | 174 |  |                 ->setQuantity($quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 | 174 |  |             $this->cart->setCartItem($CartItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 | 175 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |      * @param  string $productClassId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |      * @return boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 | 128 |  |     public function canAddProduct($productClassId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         $ProductClass = $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 | 128 |  |             ->entityManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 | 128 |  |             ->getRepository('\Eccube\Entity\ProductClass') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 | 128 |  |             ->find($productClassId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 | 128 |  |         if (!$ProductClass) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 | 128 |  |         $ProductType = $ProductClass->getProductType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 | 128 |  |         return $this->ProductType == $ProductType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |      * @param \Eccube\Entity\Master\ProductType $ProductType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 | 49 |  |     public function canAddProductPayment(\Eccube\Entity\Master\ProductType $ProductType) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         $deliveries = $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 | 49 |  |             ->entityManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 | 49 |  |             ->getRepository('\Eccube\Entity\Delivery') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 | 49 |  |             ->findBy(array('ProductType' => $ProductType)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         // 支払方法を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 | 49 |  |         $payments = $this->entityManager->getRepository('Eccube\Entity\Payment')->findAllowedPayments($deliveries); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 | 49 |  |         if ($this->getCart()->getTotalPrice() < 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |             // カートになければ支払方法を全て設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 | 49 |  |             $this->getCart()->setPayments($payments); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 | 49 |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |         // カートに存在している支払方法と追加された商品の支払方法チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 | 45 |  |         $arr = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 | 45 |  |         foreach ($payments as $payment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 | 45 |  |             foreach ($this->getCart()->getPayments() as $p) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 | 45 |  |                 if ($payment['id'] == $p['id']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 | 44 |  |                     $arr[] = $payment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 | 45 |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 | 45 |  |         if (count($arr) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 | 44 |  |             $this->getCart()->setPayments($arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 | 44 |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         // 支払条件に一致しない | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 | 1 |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |      * カートブロックに表示するカートを取得します。 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |      * ブロックに表示するカートはチェックを行わず、セットされているカートを返します。 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |      * @return \Eccube\Entity\Cart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 | 253 |  |     public function getCartObj() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 | 253 |  |         foreach ($this->cart->getCartItems() as $CartItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |             /** @var \Eccube\Entity\ProductClass $ProductClass */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 | 63 |  |             $ProductClass = $CartItem->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 | 63 |  |             if (!$ProductClass) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 | 4 |  |                 $this->loadProductClassFromCartItem($CartItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 | 4 |  |                 $ProductClass = $CartItem->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 | 63 |  |             if ($ProductClass->getDelFlg()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                 // 商品情報が削除されていたらエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 | 2 |  |                 $this->setError('cart.product.delete'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |                 // カートから削除 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 | 253 |  |                 $this->removeProduct($ProductClass->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 | 253 |  |         return $this->cart; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |      * カートを取得します。 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |      * @return \Eccube\Entity\Cart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 | 144 |  |     public function getCart() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 | 144 |  |         foreach ($this->cart->getCartItems() as $CartItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |             /** @var \Eccube\Entity\ProductClass $ProductClass */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 | 135 |  |             $ProductClass = $CartItem->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 | 135 |  |             if (!$ProductClass) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 | 134 |  |                 $this->loadProductClassFromCartItem($CartItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 | 134 |  |                 $ProductClass = $CartItem->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 | 135 |  |             if ($ProductClass->getDelFlg() == Constant::DISABLED) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                 // 商品情報が有効 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 | 135 |  |                 if (!$this->isProductDisplay($ProductClass)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 | 4 |  |                     $this->setError('cart.product.not.status'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                 } else { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 | 135 |  |                     $productName = $this->getProductName($ProductClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                     // 制限数チェック(在庫不足の場合は、処理の中でカート内商品を削除している) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 | 135 |  |                     $quantity = $this->setProductLimit($ProductClass, $productName, $CartItem->getQuantity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |                     /// 個数が異なれば、新しい数量でカート内商品を更新する | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 | 135 |  |                     if ((0 < $quantity) && ($CartItem->getQuantity() != $quantity)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |                         // 個数が異なれば更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 | 8 |  |                         $CartItem->setQuantity($quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 | 135 |  |                         $this->cart->setCartItem($CartItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |                 // 商品情報が削除されていたらエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 | 7 |  |                 $this->setError('cart.product.delete'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |                 // カートから削除 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 | 144 |  |                 $this->removeProduct($ProductClass->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 | 144 |  |         return $this->cart; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |      * @param  string $productClassId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 | 27 |  |     public function removeProduct($productClassId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 | 27 |  |         $this->cart->removeCartItemByIdentifier('Eccube\Entity\ProductClass', (string)$productClassId); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         // 支払方法の再設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 | 27 |  |         if ($this->BaseInfo->getOptionMultipleShipping() == Constant::ENABLED) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             // 複数配送対応 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 | 1 |  |             $productTypes = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 | 1 |  |             foreach ($this->getCart()->getCartItems() as $item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                 /* @var $ProductClass \Eccube\Entity\ProductClass */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 | 1 |  |                 $ProductClass = $item->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 | 1 |  |                 $productTypes[] = $ProductClass->getProductType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |             // 配送業者を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 | 1 |  |             $deliveries = $this->entityManager->getRepository('Eccube\Entity\Delivery')->getDeliveries($productTypes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |             // 支払方法を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 | 1 |  |             $payments = $this->entityManager->getRepository('Eccube\Entity\Payment')->findAllowedPayments($deliveries); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 | 1 |  |             $this->getCart()->setPayments($payments); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 | 27 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |      * @param  string $error | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |      * @param  string $productName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 | 30 |  |     public function addError($error = null, $productName = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         // Filter duplicate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 | 30 |  |         $arrError = $this->session->getFlashBag()->peek('eccube.front.request.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 | 30 |  |         $arrProduct = $this->session->getFlashBag()->peek('eccube.front.request.product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 | 30 |  |         if (in_array($error, $arrError) && in_array($productName, $arrProduct)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 | 1 |  |             return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 | 30 |  |         $this->errors[] = $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 | 30 |  |         $this->session->getFlashBag()->add('eccube.front.request.error', $error); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 | 30 |  |         if (!is_null($productName)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |             // 追加されているエラーのキーを取得する | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 | 29 |  |             $cnt = $this->session->getFlashBag()->peek('eccube.front.request.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 | 29 |  |             end($cnt); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 | 29 |  |             $key = key($cnt); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |             // エラーと同じキー商品名を設定する | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 | 29 |  |             $arrProduct[$key] = $productName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 | 29 |  |             $this->session->getFlashBag()->set('eccube.front.request.product', $arrProduct); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 | 30 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |      * @param  string $productClassId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 | 11 |  |     public function upProductQuantity($productClassId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 | 11 |  |         $quantity = $this->getProductQuantity($productClassId) + 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 | 11 |  |         $this->setProductQuantity($productClassId, $quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 | 8 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |      * @param  string $productClassId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 | 12 |  |     public function downProductQuantity($productClassId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 | 12 |  |         $quantity = $this->getProductQuantity($productClassId) - 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 | 12 |  |         if ($quantity > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 | 8 |  |             $this->setProductQuantity($productClassId, $quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 | 10 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 | 99 |  |     public function getProductTypes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 | 99 |  |         $productTypes = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 | 99 |  |         foreach ($this->getCart()->getCartItems() as $item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |             /* @var $ProductClass \Eccube\Entity\ProductClass */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 | 99 |  |             $ProductClass = $item->getObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 | 99 |  |             $productTypes[] = $ProductClass->getProductType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 | 99 |  |         return array_unique($productTypes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |      * @return string[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 | 3 |  |     public function getErrors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 | 3 |  |         return $this->errors; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |      * @return string[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 | 1 |  |     public function getMessages() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 | 1 |  |         return $this->messages; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |      * @param  string $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 | 1 |  |     public function setMessage($message) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 | 1 |  |         $this->messages[] = $message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 | 1 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 | 1 |  |     public function getError() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 | 1 |  |         return $this->error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |      * @param  string $error | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |      * @return \Eccube\Service\CartService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 | 13 |  |     public function setError($error = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 | 13 |  |         $this->error = $error; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 | 13 |  |         $this->session->getFlashBag()->set('eccube.front.request.error', $error); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 | 13 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |      * 商品名を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |      * @param ProductClass $ProductClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 | 176 |  |     private function getProductName(ProductClass $ProductClass) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 | 176 |  |         $productName = $ProductClass->getProduct()->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 | 176 |  |         if ($ProductClass->hasClassCategory1()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 | 176 |  |             $productName .= " - ".$ProductClass->getClassCategory1()->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 | 176 |  |         if ($ProductClass->hasClassCategory2()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 | 146 |  |             $productName .= " - ".$ProductClass->getClassCategory2()->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 | 176 |  |         return $productName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |      * 非公開商品の場合、カートから削除 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |      * @param ProductClass $ProductClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |      * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 640 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 641 | 177 |  |     private function isProductDisplay(ProductClass $ProductClass) | 
            
                                                                        
                            
            
                                    
            
            
                | 642 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 643 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 644 | 177 |  |         if ($ProductClass->getProduct()->getStatus()->getId() !== Disp::DISPLAY_SHOW) { | 
            
                                                                        
                            
            
                                    
            
            
                | 645 |  |  |             // 非公開の商品はカートから削除 | 
            
                                                                        
                            
            
                                    
            
            
                | 646 | 8 |  |             $this->removeProduct($ProductClass->getId()); | 
            
                                                                        
                            
            
                                    
            
            
                | 647 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 648 | 8 |  |             return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 649 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 650 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 651 | 176 |  |         return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 652 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |      * 在庫数と販売制限数のチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |      * 在庫数または販売制限数以上の個数が設定されていれば、それぞれの個数にセットし、 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |      * 在庫数と販売制限数ともに個数が超えていれば、少ない方を適用させてメッセージを表示する | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |      * @param ProductClass $ProductClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |      * @param $productName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |      * @param $quantity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |      * @return int チェック後に更新した個数 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 | 175 |  |     private function setProductLimit(ProductClass $ProductClass, $productName, $quantity) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |          * 実際の在庫は ProductClass::ProductStock だが、購入時にロックがかかるため、 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |          * ここでは ProductClass::stock で在庫のチェックをする | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |         // 在庫数(在庫無制限の場合、null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 | 175 |  |         $stock = $ProductClass->getStock(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |         // 在庫無制限(在庫無制限の場合、1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 | 175 |  |         $stockUnlimited = $ProductClass->getStockUnlimited(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         // 販売制限数(設定されていなければnull) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 | 175 |  |         $saleLimit = $ProductClass->getSaleLimit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 | 175 |  |         if ($stockUnlimited) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |             // 在庫無制限 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 | 105 |  |             if ($saleLimit && $saleLimit < $quantity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |                 // 販売制限数を超えていれば販売制限数をセット | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |                 $this->addError('cart.over.sale_limit', $productName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 | 105 |  |                 return $saleLimit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |             // 在庫制限あり | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 | 83 |  |             if ($stock < 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |                 // 在庫がなければカートから削除 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 | 8 |  |                 $this->addError('cart.zero.stock', $productName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 | 8 |  |                 $this->removeProduct($ProductClass->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 | 8 |  |                 return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |                 // 在庫数チェックと販売制限数チェックどちらを適用するか設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 | 82 |  |                 $message = 'cart.over.stock'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 | 82 |  |                 if ($saleLimit) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 | 14 |  |                     if ($stock > $saleLimit) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |                         // 販売制限数チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 | 14 |  |                         $limit = $saleLimit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 | 14 |  |                         $message = 'cart.over.sale_limit'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |                         // 在庫数チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 | 14 |  |                         $limit = $stock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |                     // 在庫数チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 | 75 |  |                     $limit = $stock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 | 82 |  |                 if ($limit < $quantity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |                     // 在庫数、販売制限数を超えていれば購入可能数までをセット | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 | 21 |  |                     $this->addError($message, $productName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 | 21 |  |                     return $limit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 | 172 |  |         return $quantity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 728 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 729 |  |  |  |