@@ -283,17 +283,14 @@ discard block |
||
| 283 | 283 | { |
| 284 | 284 | $address->copyFrom( $value ); |
| 285 | 285 | $this->basket->setAddress( $address, $type ); |
| 286 | - } |
|
| 287 | - else if( is_array( $value ) ) |
|
| 286 | + } else if( is_array( $value ) ) |
|
| 288 | 287 | { |
| 289 | 288 | $this->setAddressFromArray( $address, $value ); |
| 290 | 289 | $this->basket->setAddress( $address, $type ); |
| 291 | - } |
|
| 292 | - else if( $value === null ) |
|
| 290 | + } else if( $value === null ) |
|
| 293 | 291 | { |
| 294 | 292 | $this->basket->deleteAddress( $type ); |
| 295 | - } |
|
| 296 | - else |
|
| 293 | + } else |
|
| 297 | 294 | { |
| 298 | 295 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
| 299 | 296 | } |
@@ -519,10 +516,11 @@ discard block |
||
| 519 | 516 | { |
| 520 | 517 | $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
| 521 | 518 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
| 522 | - } |
|
| 523 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
| 519 | + } else if( ( $result = reset( $productItems ) ) !== false ) { |
|
| 520 | + // count == 1 |
|
| 524 | 521 | { |
| 525 | 522 | $productItem = $result; |
| 523 | + } |
|
| 526 | 524 | $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
| 527 | 525 | |
| 528 | 526 | $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
@@ -542,10 +540,11 @@ discard block |
||
| 542 | 540 | |
| 543 | 541 | $attr[] = $orderAttributeItem; |
| 544 | 542 | } |
| 545 | - } |
|
| 546 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
| 543 | + } else if( !isset( $options['variant'] ) || $options['variant'] != false ) { |
|
| 544 | + // count == 0 |
|
| 547 | 545 | { |
| 548 | 546 | $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
| 547 | + } |
|
| 549 | 548 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
| 550 | 549 | } |
| 551 | 550 | |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
| 33 | 33 | * connections, logger, session, etc. |
| 34 | 34 | */ |
| 35 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 35 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 36 | 36 | { |
| 37 | - parent::__construct( $context ); |
|
| 37 | + parent::__construct($context); |
|
| 38 | 38 | |
| 39 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
| 39 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
| 40 | 40 | $this->basket = $this->domainManager->getSession(); |
| 41 | 41 | |
| 42 | 42 | $this->checkLocale(); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | public function clear() |
| 50 | 50 | { |
| 51 | 51 | $this->basket = $this->domainManager->createItem(); |
| 52 | - $this->domainManager->setSession( $this->basket ); |
|
| 52 | + $this->domainManager->setSession($this->basket); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function save() |
| 71 | 71 | { |
| 72 | - if( $this->basket->isModified() ) { |
|
| 73 | - $this->domainManager->setSession( $this->basket ); |
|
| 72 | + if ($this->basket->isModified()) { |
|
| 73 | + $this->domainManager->setSession($this->basket); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -95,48 +95,48 @@ discard block |
||
| 95 | 95 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 96 | 96 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 97 | 97 | */ |
| 98 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 98 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 99 | 99 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
| 100 | - $stocktype = 'default' ) |
|
| 100 | + $stocktype = 'default') |
|
| 101 | 101 | { |
| 102 | 102 | $context = $this->getContext(); |
| 103 | 103 | |
| 104 | - $productItem = $this->getDomainItem( 'product', 'product.id', $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
| 104 | + $productItem = $this->getDomainItem('product', 'product.id', $prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
| 105 | 105 | |
| 106 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 107 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
| 108 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
| 109 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
| 106 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 107 | + $orderBaseProductItem->copyFrom($productItem); |
|
| 108 | + $orderBaseProductItem->setQuantity($quantity); |
|
| 109 | + $orderBaseProductItem->setStockType($stocktype); |
|
| 110 | 110 | |
| 111 | 111 | $attr = array(); |
| 112 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 112 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 113 | 113 | |
| 114 | - switch( $productItem->getType() ) |
|
| 114 | + switch ($productItem->getType()) |
|
| 115 | 115 | { |
| 116 | 116 | case 'select': |
| 117 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
| 117 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
| 118 | 118 | break; |
| 119 | 119 | case 'bundle': |
| 120 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
| 120 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
| 121 | 121 | break; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 125 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 124 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 125 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
| 126 | 126 | |
| 127 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
| 128 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
| 129 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
| 127 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
| 128 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
| 129 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
| 130 | 130 | |
| 131 | 131 | // remove product rebate of original price in favor to rebates granted for the order |
| 132 | - $price->setRebate( '0.00' ); |
|
| 132 | + $price->setRebate('0.00'); |
|
| 133 | 133 | |
| 134 | - $orderBaseProductItem->setPrice( $price ); |
|
| 135 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 134 | + $orderBaseProductItem->setPrice($price); |
|
| 135 | + $orderBaseProductItem->setAttributes($attr); |
|
| 136 | 136 | |
| 137 | - $this->basket->addProduct( $orderBaseProductItem ); |
|
| 137 | + $this->basket->addProduct($orderBaseProductItem); |
|
| 138 | 138 | |
| 139 | - $this->domainManager->setSession( $this->basket ); |
|
| 139 | + $this->domainManager->setSession($this->basket); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
@@ -145,18 +145,18 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @param integer $position Position number (key) of the order product item |
| 147 | 147 | */ |
| 148 | - public function deleteProduct( $position ) |
|
| 148 | + public function deleteProduct($position) |
|
| 149 | 149 | { |
| 150 | - $product = $this->basket->getProduct( $position ); |
|
| 150 | + $product = $this->basket->getProduct($position); |
|
| 151 | 151 | |
| 152 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 152 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 153 | 153 | { |
| 154 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
| 155 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 154 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
| 155 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $this->basket->deleteProduct( $position ); |
|
| 159 | - $this->domainManager->setSession( $this->basket ); |
|
| 158 | + $this->basket->deleteProduct($position); |
|
| 159 | + $this->domainManager->setSession($this->basket); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
@@ -169,36 +169,36 @@ discard block |
||
| 169 | 169 | * The 'stock'=>false option allows adding products without being in stock. |
| 170 | 170 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 171 | 171 | */ |
| 172 | - public function editProduct( $position, $quantity, array $options = array(), |
|
| 173 | - array $configAttributeCodes = array() ) |
|
| 172 | + public function editProduct($position, $quantity, array $options = array(), |
|
| 173 | + array $configAttributeCodes = array()) |
|
| 174 | 174 | { |
| 175 | - $product = $this->basket->getProduct( $position ); |
|
| 175 | + $product = $this->basket->getProduct($position); |
|
| 176 | 176 | |
| 177 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 177 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 178 | 178 | { |
| 179 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
| 180 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 179 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
| 180 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $product->setQuantity( $quantity ); |
|
| 183 | + $product->setQuantity($quantity); |
|
| 184 | 184 | |
| 185 | 185 | $attributes = $product->getAttributes(); |
| 186 | - foreach( $attributes as $key => $attribute ) |
|
| 186 | + foreach ($attributes as $key => $attribute) |
|
| 187 | 187 | { |
| 188 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
| 189 | - unset( $attributes[$key] ); |
|
| 188 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
| 189 | + unset($attributes[$key]); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - $product->setAttributes( $attributes ); |
|
| 192 | + $product->setAttributes($attributes); |
|
| 193 | 193 | |
| 194 | - $productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) ); |
|
| 195 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
| 196 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
| 194 | + $productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text')); |
|
| 195 | + $prices = $productItem->getRefItems('price', 'default'); |
|
| 196 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
| 197 | 197 | |
| 198 | - $this->basket->deleteProduct( $position ); |
|
| 199 | - $this->basket->addProduct( $product, $position ); |
|
| 198 | + $this->basket->deleteProduct($position); |
|
| 199 | + $this->basket->addProduct($product, $position); |
|
| 200 | 200 | |
| 201 | - $this->domainManager->setSession( $this->basket ); |
|
| 201 | + $this->domainManager->setSession($this->basket); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -208,50 +208,50 @@ discard block |
||
| 208 | 208 | * @param string $code Coupon code entered by the user |
| 209 | 209 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 210 | 210 | */ |
| 211 | - public function addCoupon( $code ) |
|
| 211 | + public function addCoupon($code) |
|
| 212 | 212 | { |
| 213 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 214 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
| 213 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 214 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | - $search = $codeManager->createSearch( true ); |
|
| 217 | + $search = $codeManager->createSearch(true); |
|
| 218 | 218 | $expr = array( |
| 219 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
| 219 | + $search->compare('==', 'coupon.code.code', $code), |
|
| 220 | 220 | $search->getConditions(), |
| 221 | 221 | ); |
| 222 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 223 | - $search->setSlice( 0, 1 ); |
|
| 222 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 223 | + $search->setSlice(0, 1); |
|
| 224 | 224 | |
| 225 | - $result = $codeManager->searchItems( $search ); |
|
| 225 | + $result = $codeManager->searchItems($search); |
|
| 226 | 226 | |
| 227 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
| 228 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
| 227 | + if (($codeItem = reset($result)) === false) { |
|
| 228 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
| 232 | - $search = $manager->createSearch( true ); |
|
| 232 | + $search = $manager->createSearch(true); |
|
| 233 | 233 | $expr = array( |
| 234 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
| 234 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
| 235 | 235 | $search->getConditions(), |
| 236 | 236 | ); |
| 237 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 238 | - $search->setSlice( 0, 1 ); |
|
| 237 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 238 | + $search->setSlice(0, 1); |
|
| 239 | 239 | |
| 240 | - $result = $manager->searchItems( $search ); |
|
| 240 | + $result = $manager->searchItems($search); |
|
| 241 | 241 | |
| 242 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 243 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
| 242 | + if (($item = reset($result)) === false) { |
|
| 243 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
| 247 | - $provider = $manager->getProvider( $item, $code ); |
|
| 247 | + $provider = $manager->getProvider($item, $code); |
|
| 248 | 248 | |
| 249 | - if( $provider->isAvailable( $this->basket ) !== true ) { |
|
| 250 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
| 249 | + if ($provider->isAvailable($this->basket) !== true) { |
|
| 250 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $provider->addCoupon( $this->basket ); |
|
| 254 | - $this->domainManager->setSession( $this->basket ); |
|
| 253 | + $provider->addCoupon($this->basket); |
|
| 254 | + $this->domainManager->setSession($this->basket); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
@@ -261,22 +261,22 @@ discard block |
||
| 261 | 261 | * @param string $code Coupon code entered by the user |
| 262 | 262 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 263 | 263 | */ |
| 264 | - public function deleteCoupon( $code ) |
|
| 264 | + public function deleteCoupon($code) |
|
| 265 | 265 | { |
| 266 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 266 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 267 | 267 | |
| 268 | 268 | $search = $manager->createSearch(); |
| 269 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
| 270 | - $search->setSlice( 0, 1 ); |
|
| 269 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
| 270 | + $search->setSlice(0, 1); |
|
| 271 | 271 | |
| 272 | - $result = $manager->searchItems( $search ); |
|
| 272 | + $result = $manager->searchItems($search); |
|
| 273 | 273 | |
| 274 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 275 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
| 274 | + if (($item = reset($result)) === false) { |
|
| 275 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->basket ); |
|
| 279 | - $this->domainManager->setSession( $this->basket ); |
|
| 278 | + $manager->getProvider($item, $code)->deleteCoupon($this->basket); |
|
| 279 | + $this->domainManager->setSession($this->basket); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
@@ -288,31 +288,31 @@ discard block |
||
| 288 | 288 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
| 289 | 289 | * if one of the keys is invalid when using an array with key/value pairs |
| 290 | 290 | */ |
| 291 | - public function setAddress( $type, $value ) |
|
| 291 | + public function setAddress($type, $value) |
|
| 292 | 292 | { |
| 293 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
| 294 | - $address->setType( $type ); |
|
| 293 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
| 294 | + $address->setType($type); |
|
| 295 | 295 | |
| 296 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
| 296 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
| 297 | 297 | { |
| 298 | - $address->copyFrom( $value ); |
|
| 299 | - $this->basket->setAddress( $address, $type ); |
|
| 298 | + $address->copyFrom($value); |
|
| 299 | + $this->basket->setAddress($address, $type); |
|
| 300 | 300 | } |
| 301 | - else if( is_array( $value ) ) |
|
| 301 | + else if (is_array($value)) |
|
| 302 | 302 | { |
| 303 | - $this->setAddressFromArray( $address, $value ); |
|
| 304 | - $this->basket->setAddress( $address, $type ); |
|
| 303 | + $this->setAddressFromArray($address, $value); |
|
| 304 | + $this->basket->setAddress($address, $type); |
|
| 305 | 305 | } |
| 306 | - else if( $value === null ) |
|
| 306 | + else if ($value === null) |
|
| 307 | 307 | { |
| 308 | - $this->basket->deleteAddress( $type ); |
|
| 308 | + $this->basket->deleteAddress($type); |
|
| 309 | 309 | } |
| 310 | 310 | else |
| 311 | 311 | { |
| 312 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
| 312 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $this->domainManager->setSession( $this->basket ); |
|
| 315 | + $this->domainManager->setSession($this->basket); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
@@ -325,43 +325,43 @@ discard block |
||
| 325 | 325 | * entered by the customer when choosing one of the delivery or payment options |
| 326 | 326 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 327 | 327 | */ |
| 328 | - public function setService( $type, $id, array $attributes = array() ) |
|
| 328 | + public function setService($type, $id, array $attributes = array()) |
|
| 329 | 329 | { |
| 330 | 330 | $context = $this->getContext(); |
| 331 | 331 | |
| 332 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
| 333 | - $serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) ); |
|
| 332 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
| 333 | + $serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text')); |
|
| 334 | 334 | |
| 335 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
| 336 | - $result = $provider->checkConfigFE( $attributes ); |
|
| 337 | - $unknown = array_diff_key( $attributes, $result ); |
|
| 335 | + $provider = $serviceManager->getProvider($serviceItem); |
|
| 336 | + $result = $provider->checkConfigFE($attributes); |
|
| 337 | + $unknown = array_diff_key($attributes, $result); |
|
| 338 | 338 | |
| 339 | - if( count( $unknown ) > 0 ) |
|
| 339 | + if (count($unknown) > 0) |
|
| 340 | 340 | { |
| 341 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
| 342 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 341 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
| 342 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - foreach( $result as $key => $value ) |
|
| 345 | + foreach ($result as $key => $value) |
|
| 346 | 346 | { |
| 347 | - if( $value !== null ) { |
|
| 348 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
| 347 | + if ($value !== null) { |
|
| 348 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
| 352 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
| 353 | 353 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
| 354 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
| 354 | + $orderServiceItem->copyFrom($serviceItem); |
|
| 355 | 355 | |
| 356 | - $price = $provider->calcPrice( $this->basket ); |
|
| 356 | + $price = $provider->calcPrice($this->basket); |
|
| 357 | 357 | // remove service rebate of original price |
| 358 | - $price->setRebate( '0.00' ); |
|
| 359 | - $orderServiceItem->setPrice( $price ); |
|
| 358 | + $price->setRebate('0.00'); |
|
| 359 | + $orderServiceItem->setPrice($price); |
|
| 360 | 360 | |
| 361 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
| 361 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
| 362 | 362 | |
| 363 | - $this->basket->setService( $orderServiceItem, $type ); |
|
| 364 | - $this->domainManager->setSession( $this->basket ); |
|
| 363 | + $this->basket->setService($orderServiceItem, $type); |
|
| 364 | + $this->domainManager->setSession($this->basket); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | |
@@ -373,44 +373,44 @@ discard block |
||
| 373 | 373 | * @param array $variantAttributeIds List of product variant attribute IDs |
| 374 | 374 | * @param string $stocktype |
| 375 | 375 | */ |
| 376 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 377 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
| 376 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 377 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
| 378 | 378 | { |
| 379 | 379 | $quantity = $orderBaseProductItem->getQuantity(); |
| 380 | 380 | $products = $subProductIds = $orderProducts = array(); |
| 381 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
| 381 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
| 382 | 382 | |
| 383 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
| 383 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
| 384 | 384 | $subProductIds[] = $item->getId(); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - if( count( $subProductIds ) > 0 ) |
|
| 387 | + if (count($subProductIds) > 0) |
|
| 388 | 388 | { |
| 389 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 389 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 390 | 390 | |
| 391 | - $search = $productManager->createSearch( true ); |
|
| 391 | + $search = $productManager->createSearch(true); |
|
| 392 | 392 | $expr = array( |
| 393 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 393 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 394 | 394 | $search->getConditions(), |
| 395 | 395 | ); |
| 396 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 396 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 397 | 397 | |
| 398 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
| 398 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - foreach( $products as $product ) |
|
| 401 | + foreach ($products as $product) |
|
| 402 | 402 | { |
| 403 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
| 403 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
| 404 | 404 | |
| 405 | 405 | $orderProduct = $orderProductManager->createItem(); |
| 406 | - $orderProduct->copyFrom( $product ); |
|
| 407 | - $orderProduct->setStockType( $stocktype ); |
|
| 408 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
| 406 | + $orderProduct->copyFrom($product); |
|
| 407 | + $orderProduct->setStockType($stocktype); |
|
| 408 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
| 409 | 409 | |
| 410 | 410 | $orderProducts[] = $orderProduct; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
| 413 | + $orderBaseProductItem->setProducts($orderProducts); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
@@ -425,36 +425,36 @@ discard block |
||
| 425 | 425 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
| 426 | 426 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 427 | 427 | */ |
| 428 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 429 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
| 428 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 429 | + array $attributeIds, $type, array $attributeValues = array()) |
|
| 430 | 430 | { |
| 431 | - if( empty( $attributeIds ) ) { |
|
| 431 | + if (empty($attributeIds)) { |
|
| 432 | 432 | return array(); |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
| 436 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
| 435 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
| 436 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
| 437 | 437 | |
| 438 | 438 | $list = array(); |
| 439 | 439 | $context = $this->getContext(); |
| 440 | 440 | |
| 441 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 442 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
| 441 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 442 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
| 443 | 443 | |
| 444 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 444 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 445 | 445 | { |
| 446 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
| 446 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
| 447 | 447 | |
| 448 | - if( !empty( $prices ) ) { |
|
| 449 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
| 448 | + if (!empty($prices)) { |
|
| 449 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | $item = $orderProductAttributeManager->createItem(); |
| 453 | - $item->copyFrom( $attrItem ); |
|
| 454 | - $item->setType( $type ); |
|
| 453 | + $item->copyFrom($attrItem); |
|
| 454 | + $item->setType($type); |
|
| 455 | 455 | |
| 456 | - if( isset( $attributeValues[$id] ) ) { |
|
| 457 | - $item->setValue( $attributeValues[$id] ); |
|
| 456 | + if (isset($attributeValues[$id])) { |
|
| 457 | + $item->setValue($attributeValues[$id]); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | $list[] = $item; |
@@ -474,23 +474,23 @@ discard block |
||
| 474 | 474 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
| 475 | 475 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 476 | 476 | */ |
| 477 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
| 477 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
| 478 | 478 | { |
| 479 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 479 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 480 | 480 | |
| 481 | - $search = $manager->createSearch( true ); |
|
| 481 | + $search = $manager->createSearch(true); |
|
| 482 | 482 | $expr = array( |
| 483 | - $search->compare( '==', $key, $value ), |
|
| 483 | + $search->compare('==', $key, $value), |
|
| 484 | 484 | $search->getConditions(), |
| 485 | 485 | ); |
| 486 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 486 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 487 | 487 | |
| 488 | - $result = $manager->searchItems( $search, $ref ); |
|
| 488 | + $result = $manager->searchItems($search, $ref); |
|
| 489 | 489 | |
| 490 | - if( ( $item = reset( $result ) ) === false ) |
|
| 490 | + if (($item = reset($result)) === false) |
|
| 491 | 491 | { |
| 492 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
| 493 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 492 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
| 493 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | return $item; |
@@ -508,50 +508,50 @@ discard block |
||
| 508 | 508 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
| 509 | 509 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
| 510 | 510 | */ |
| 511 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 512 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
| 511 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 512 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
| 513 | 513 | { |
| 514 | 514 | $attr = array(); |
| 515 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
| 515 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
| 516 | 516 | |
| 517 | - if( count( $productItems ) > 1 ) |
|
| 517 | + if (count($productItems) > 1) |
|
| 518 | 518 | { |
| 519 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
| 520 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 519 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
| 520 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 521 | 521 | } |
| 522 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
| 522 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
| 523 | 523 | { |
| 524 | 524 | $productItem = $result; |
| 525 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
| 525 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
| 526 | 526 | |
| 527 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 527 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 528 | 528 | |
| 529 | - if( !empty( $subprices ) ) { |
|
| 529 | + if (!empty($subprices)) { |
|
| 530 | 530 | $prices = $subprices; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
| 533 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
| 534 | 534 | |
| 535 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
| 536 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
| 535 | + if (($mediaItem = reset($submedia)) !== false) { |
|
| 536 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
| 540 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
| 539 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
| 540 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
| 541 | 541 | |
| 542 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
| 542 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
| 543 | 543 | { |
| 544 | 544 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
| 545 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
| 546 | - $orderAttributeItem->setType( 'variant' ); |
|
| 545 | + $orderAttributeItem->copyFrom($attrItem); |
|
| 546 | + $orderAttributeItem->setType('variant'); |
|
| 547 | 547 | |
| 548 | 548 | $attr[] = $orderAttributeItem; |
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
| 551 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
| 552 | 552 | { |
| 553 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
| 554 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 553 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
| 554 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | return $attr; |
@@ -566,18 +566,18 @@ discard block |
||
| 566 | 566 | * an address item. |
| 567 | 567 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 568 | 568 | */ |
| 569 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
| 569 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
| 570 | 570 | { |
| 571 | - foreach( $map as $key => $value ) { |
|
| 572 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
| 571 | + foreach ($map as $key => $value) { |
|
| 572 | + $map[$key] = strip_tags($value); // prevent XSS |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - $errors = $address->fromArray( $map ); |
|
| 575 | + $errors = $address->fromArray($map); |
|
| 576 | 576 | |
| 577 | - if( count( $errors ) > 0 ) |
|
| 577 | + if (count($errors) > 0) |
|
| 578 | 578 | { |
| 579 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
| 580 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
| 579 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
| 580 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | } |