@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | * @param string $warehouse Unique code of the warehouse to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantIds = array(), |
|
45 | - array $configIds = array(), array $hiddenIds = array(), array $customValues = array(), $warehouse = 'default' ) |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantIds = array(), |
|
45 | + array $configIds = array(), array $hiddenIds = array(), array $customValues = array(), $warehouse = 'default') |
|
46 | 46 | { |
47 | 47 | $stocklevel = null; |
48 | 48 | |
49 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
50 | - $stocklevel = $this->getStockLevel( $prodid, $warehouse ); |
|
49 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
50 | + $stocklevel = $this->getStockLevel($prodid, $warehouse); |
|
51 | 51 | } |
52 | 52 | |
53 | - $qty = ( $stocklevel !== null ? min( $stocklevel, $quantity ) : $quantity ); |
|
53 | + $qty = ($stocklevel !== null ? min($stocklevel, $quantity) : $quantity); |
|
54 | 54 | |
55 | - if( $qty > 0 ) |
|
55 | + if ($qty > 0) |
|
56 | 56 | { |
57 | 57 | $this->getController()->addProduct( |
58 | 58 | $prodid, $qty, $options, $variantIds, $configIds, $hiddenIds, $customValues, $warehouse |
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - if( $qty < $quantity ) |
|
62 | + if ($qty < $quantity) |
|
63 | 63 | { |
64 | - $product = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' )->getItem( $prodid ); |
|
65 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $product->getName() ); |
|
66 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
64 | + $product = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product')->getItem($prodid); |
|
65 | + $msg = sprintf('There are not enough products "%1$s" in stock', $product->getName()); |
|
66 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -77,23 +77,23 @@ discard block |
||
77 | 77 | * The 'stock'=>false option allows adding products without being in stock. |
78 | 78 | * @param string[] $configCodes Codes of the product config attributes that should be REMOVED |
79 | 79 | */ |
80 | - public function editProduct( $position, $quantity, array $options = array(), array $configCodes = array() ) |
|
80 | + public function editProduct($position, $quantity, array $options = array(), array $configCodes = array()) |
|
81 | 81 | { |
82 | 82 | $stocklevel = null; |
83 | - $product = $this->getController()->get()->getProduct( $position ); |
|
83 | + $product = $this->getController()->get()->getProduct($position); |
|
84 | 84 | |
85 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
86 | - $stocklevel = $this->getStockLevel( $product->getProductId(), $product->getWarehouseCode() ); |
|
85 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
86 | + $stocklevel = $this->getStockLevel($product->getProductId(), $product->getWarehouseCode()); |
|
87 | 87 | } |
88 | 88 | |
89 | - $qty = ( $stocklevel !== null ? min( $stocklevel, $quantity ) : $quantity ); |
|
89 | + $qty = ($stocklevel !== null ? min($stocklevel, $quantity) : $quantity); |
|
90 | 90 | |
91 | - $this->getController()->editProduct( $position, $qty, $options, $configCodes ); |
|
91 | + $this->getController()->editProduct($position, $qty, $options, $configCodes); |
|
92 | 92 | |
93 | - if( $qty < $quantity ) |
|
93 | + if ($qty < $quantity) |
|
94 | 94 | { |
95 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $product->getName() ); |
|
96 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
95 | + $msg = sprintf('There are not enough products "%1$s" in stock', $product->getName()); |
|
96 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -105,35 +105,35 @@ discard block |
||
105 | 105 | * @param string $warehouse Unique code of the warehouse |
106 | 106 | * @return integer|null Number of available items in stock (null for unlimited stock) |
107 | 107 | */ |
108 | - protected function getStockLevel( $prodid, $warehouse ) |
|
108 | + protected function getStockLevel($prodid, $warehouse) |
|
109 | 109 | { |
110 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
110 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
111 | 111 | |
112 | - $search = $manager->createSearch( true ); |
|
112 | + $search = $manager->createSearch(true); |
|
113 | 113 | $expr = array( |
114 | - $search->compare( '==', 'product.stock.parentid', $prodid ), |
|
114 | + $search->compare('==', 'product.stock.parentid', $prodid), |
|
115 | 115 | $search->getConditions(), |
116 | - $search->compare( '==', 'product.stock.warehouse.code', $warehouse ), |
|
116 | + $search->compare('==', 'product.stock.warehouse.code', $warehouse), |
|
117 | 117 | ); |
118 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
118 | + $search->setConditions($search->combine('&&', $expr)); |
|
119 | 119 | |
120 | - $result = $manager->searchItems( $search ); |
|
120 | + $result = $manager->searchItems($search); |
|
121 | 121 | |
122 | - if( empty( $result ) ) |
|
122 | + if (empty($result)) |
|
123 | 123 | { |
124 | - $msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse ); |
|
125 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
124 | + $msg = sprintf('No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse); |
|
125 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $stocklevel = null; |
129 | 129 | |
130 | - foreach( $result as $item ) |
|
130 | + foreach ($result as $item) |
|
131 | 131 | { |
132 | - if( ( $stock = $item->getStockLevel() ) === null ) { |
|
132 | + if (($stock = $item->getStockLevel()) === null) { |
|
133 | 133 | return null; |
134 | 134 | } |
135 | 135 | |
136 | - $stocklevel = max( (int) $stocklevel, $item->getStockLevel() ); |
|
136 | + $stocklevel = max((int) $stocklevel, $item->getStockLevel()); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $stocklevel; |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | * @return mixed Returns the value of the called method |
28 | 28 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
29 | 29 | */ |
30 | - public function __call( $name, array $param ) |
|
30 | + public function __call($name, array $param) |
|
31 | 31 | { |
32 | - if( ( $result = call_user_func_array( array( $this->getController(), $name ), $param ) ) === false ) |
|
32 | + if (($result = call_user_func_array(array($this->getController(), $name), $param)) === false) |
|
33 | 33 | { |
34 | - $cntl = get_class( $this->getController() ); |
|
35 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Unable to call method "%1$s::%2$s"', $cntl, $name ) ); |
|
34 | + $cntl = get_class($this->getController()); |
|
35 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Unable to call method "%1$s::%2$s"', $cntl, $name)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return $result; |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
82 | 82 | * @return void |
83 | 83 | */ |
84 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
84 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
85 | 85 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
86 | - $warehouse = 'default' ) |
|
86 | + $warehouse = 'default') |
|
87 | 87 | { |
88 | 88 | $this->getController()->addProduct( |
89 | 89 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @param integer $position Position number (key) of the order product item |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function deleteProduct( $position ) |
|
101 | + public function deleteProduct($position) |
|
102 | 102 | { |
103 | - $this->getController()->deleteProduct( $position ); |
|
103 | + $this->getController()->deleteProduct($position); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
113 | 113 | * @return void |
114 | 114 | */ |
115 | - public function editProduct( $position, $quantity, array $configAttributeCodes = array() ) |
|
115 | + public function editProduct($position, $quantity, array $configAttributeCodes = array()) |
|
116 | 116 | { |
117 | - $this->getController()->editProduct( $position, $quantity, $configAttributeCodes ); |
|
117 | + $this->getController()->editProduct($position, $quantity, $configAttributeCodes); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
126 | 126 | * @return void |
127 | 127 | */ |
128 | - public function addCoupon( $code ) |
|
128 | + public function addCoupon($code) |
|
129 | 129 | { |
130 | - $this->getController()->addCoupon( $code ); |
|
130 | + $this->getController()->addCoupon($code); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
139 | 139 | * @return void |
140 | 140 | */ |
141 | - public function deleteCoupon( $code ) |
|
141 | + public function deleteCoupon($code) |
|
142 | 142 | { |
143 | - $this->getController()->deleteCoupon( $code ); |
|
143 | + $this->getController()->deleteCoupon($code); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | * if one of the keys is invalid when using an array with key/value pairs |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - public function setAddress( $type, $value ) |
|
156 | + public function setAddress($type, $value) |
|
157 | 157 | { |
158 | - $this->getController()->setAddress( $type, $value ); |
|
158 | + $this->getController()->setAddress($type, $value); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
170 | 170 | * @return void |
171 | 171 | */ |
172 | - public function setService( $type, $id, array $attributes = array() ) |
|
172 | + public function setService($type, $id, array $attributes = array()) |
|
173 | 173 | { |
174 | - $this->getController()->setService( $type, $id, $attributes ); |
|
174 | + $this->getController()->setService($type, $id, $attributes); |
|
175 | 175 | } |
176 | 176 | } |
@@ -41,26 +41,26 @@ |
||
41 | 41 | * @param string $warehouse Unique code of the warehouse to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
45 | 45 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
46 | - $warehouse = 'default' ) |
|
46 | + $warehouse = 'default') |
|
47 | 47 | { |
48 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
48 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
49 | 49 | |
50 | - $search = $catalogListManager->createSearch( true ); |
|
50 | + $search = $catalogListManager->createSearch(true); |
|
51 | 51 | $expr = array( |
52 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
52 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
53 | 53 | $search->getConditions() |
54 | 54 | ); |
55 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
56 | - $search->setSlice( 0, 1 ); |
|
55 | + $search->setConditions($search->combine('&&', $expr)); |
|
56 | + $search->setSlice(0, 1); |
|
57 | 57 | |
58 | - $result = $catalogListManager->searchItems( $search ); |
|
58 | + $result = $catalogListManager->searchItems($search); |
|
59 | 59 | |
60 | - if( reset( $result ) === false ) |
|
60 | + if (reset($result) === false) |
|
61 | 61 | { |
62 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
63 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
62 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
63 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $this->getController()->addProduct( |