| @@ 89-115 (lines=27) @@ | ||
| 86 | /** |
|
| 87 | * @param CartActionEvent $event |
|
| 88 | */ |
|
| 89 | static public function handleCartAdd(CartActionEvent $event) |
|
| 90 | { |
|
| 91 | $result = $event->getEventData(); |
|
| 92 | /** @var Currency $currency */ |
|
| 93 | $currency = static::$currency; |
|
| 94 | ||
| 95 | $ga = []; |
|
| 96 | ||
| 97 | $ga['currency'] = $currency->iso_code; |
|
| 98 | $ga['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 99 | /** @var Product $item */ |
|
| 100 | $quantity = $item['quantity']; |
|
| 101 | $item = $item['model']; |
|
| 102 | ||
| 103 | $res[] = [ |
|
| 104 | 'id' => $item->id, |
|
| 105 | 'name' => $item->name, |
|
| 106 | 'category' => self::getCategories($item), |
|
| 107 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 108 | 'quantity' => $quantity, |
|
| 109 | ]; |
|
| 110 | return $res; |
|
| 111 | }, []); |
|
| 112 | ||
| 113 | $result['ecGoogle'] = $ga; |
|
| 114 | $event->setEventData($result); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * @param CartActionEvent $event |
|
| @@ 120-146 (lines=27) @@ | ||
| 117 | /** |
|
| 118 | * @param CartActionEvent $event |
|
| 119 | */ |
|
| 120 | static public function handleRemoveFromCart(CartActionEvent $event) |
|
| 121 | { |
|
| 122 | $result = $event->getEventData(); |
|
| 123 | /** @var Currency $currency */ |
|
| 124 | $currency = static::$currency; |
|
| 125 | ||
| 126 | $ga = []; |
|
| 127 | ||
| 128 | $ga['currency'] = $currency->iso_code; |
|
| 129 | $ga['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 130 | /** @var Product $item */ |
|
| 131 | $quantity = $item['quantity']; |
|
| 132 | $item = $item['model']; |
|
| 133 | ||
| 134 | $res[] = [ |
|
| 135 | 'id' => $item->id, |
|
| 136 | 'name' => $item->name, |
|
| 137 | 'category' => self::getCategories($item), |
|
| 138 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 139 | 'quantity' => $quantity, |
|
| 140 | ]; |
|
| 141 | return $res; |
|
| 142 | }, []); |
|
| 143 | ||
| 144 | $result['ecGoogle'] = $ga; |
|
| 145 | $event->setEventData($result); |
|
| 146 | } |
|
| 147 | ||
| 148 | /** |
|
| 149 | * @param CartActionEvent $event |
|
| @@ 151-177 (lines=27) @@ | ||
| 148 | /** |
|
| 149 | * @param CartActionEvent $event |
|
| 150 | */ |
|
| 151 | static public function handleChangeQuantity(CartActionEvent $event) |
|
| 152 | { |
|
| 153 | $result = $event->getEventData(); |
|
| 154 | /** @var Currency $currency */ |
|
| 155 | $currency = static::$currency; |
|
| 156 | ||
| 157 | $ga = []; |
|
| 158 | ||
| 159 | $ga['currency'] = $currency->iso_code; |
|
| 160 | $ga['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 161 | /** @var Product $item */ |
|
| 162 | $quantity = $item['quantity']; |
|
| 163 | $item = $item['model']; |
|
| 164 | ||
| 165 | $res[] = [ |
|
| 166 | 'id' => $item->id, |
|
| 167 | 'name' => $item->name, |
|
| 168 | 'category' => self::getCategories($item), |
|
| 169 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 170 | 'quantity' => $quantity, |
|
| 171 | ]; |
|
| 172 | return $res; |
|
| 173 | }, []); |
|
| 174 | ||
| 175 | $result['ecGoogle'] = $ga; |
|
| 176 | $event->setEventData($result); |
|
| 177 | } |
|
| 178 | ||
| 179 | /** |
|
| 180 | * @param CartActionEvent $event |
|
| @@ 182-208 (lines=27) @@ | ||
| 179 | /** |
|
| 180 | * @param CartActionEvent $event |
|
| 181 | */ |
|
| 182 | static public function handleClearCart(CartActionEvent $event) |
|
| 183 | { |
|
| 184 | $result = $event->getEventData(); |
|
| 185 | /** @var Currency $currency */ |
|
| 186 | $currency = static::$currency; |
|
| 187 | ||
| 188 | $ga = []; |
|
| 189 | ||
| 190 | $ga['currency'] = $currency->iso_code; |
|
| 191 | $ga['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 192 | /** @var Product $item */ |
|
| 193 | $quantity = $item['quantity']; |
|
| 194 | $item = $item['model']; |
|
| 195 | ||
| 196 | $res[] = [ |
|
| 197 | 'id' => $item->id, |
|
| 198 | 'name' => $item->name, |
|
| 199 | 'category' => self::getCategories($item), |
|
| 200 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 201 | 'quantity' => $quantity, |
|
| 202 | ]; |
|
| 203 | return $res; |
|
| 204 | }, []); |
|
| 205 | ||
| 206 | $result['ecGoogle'] = $ga; |
|
| 207 | $event->setEventData($result); |
|
| 208 | } |
|
| 209 | ||
| 210 | /** |
|
| 211 | * @param ViewEvent $event |
|
| @@ 88-114 (lines=27) @@ | ||
| 85 | /** |
|
| 86 | * @param CartActionEvent $event |
|
| 87 | */ |
|
| 88 | static public function handleCartAdd(CartActionEvent $event) |
|
| 89 | { |
|
| 90 | $result = $event->getEventData(); |
|
| 91 | /** @var Currency $currency */ |
|
| 92 | $currency = static::$currency; |
|
| 93 | ||
| 94 | $ya = []; |
|
| 95 | ||
| 96 | $ya['currency'] = $currency->iso_code; |
|
| 97 | $ya['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 98 | $quantity = $item['quantity']; |
|
| 99 | /** @var Product $item */ |
|
| 100 | $item = $item['model']; |
|
| 101 | ||
| 102 | $res[] = [ |
|
| 103 | 'id' => $item->id, |
|
| 104 | 'name' => $item->name, |
|
| 105 | 'category' => self::getCategories($item), |
|
| 106 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 107 | 'quantity' => $quantity, |
|
| 108 | ]; |
|
| 109 | return $res; |
|
| 110 | }, []); |
|
| 111 | ||
| 112 | $result['ecYandex'] = $ya; |
|
| 113 | $event->setEventData($result); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * @param CartActionEvent $event |
|
| @@ 119-145 (lines=27) @@ | ||
| 116 | /** |
|
| 117 | * @param CartActionEvent $event |
|
| 118 | */ |
|
| 119 | static public function handleRemoveFromCart(CartActionEvent $event) |
|
| 120 | { |
|
| 121 | $result = $event->getEventData(); |
|
| 122 | /** @var Currency $currency */ |
|
| 123 | $currency = static::$currency; |
|
| 124 | ||
| 125 | $ya = []; |
|
| 126 | ||
| 127 | $ya['currency'] = $currency->iso_code; |
|
| 128 | $ya['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 129 | $quantity = $item['quantity']; |
|
| 130 | /** @var Product $item */ |
|
| 131 | $item = $item['model']; |
|
| 132 | ||
| 133 | $res[] = [ |
|
| 134 | 'id' => $item->id, |
|
| 135 | 'name' => $item->name, |
|
| 136 | 'category' => self::getCategories($item), |
|
| 137 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 138 | 'quantity' => $quantity, |
|
| 139 | ]; |
|
| 140 | return $res; |
|
| 141 | }, []); |
|
| 142 | ||
| 143 | $result['ecYandex'] = $ya; |
|
| 144 | $event->setEventData($result); |
|
| 145 | } |
|
| 146 | ||
| 147 | /** |
|
| 148 | * @param CartActionEvent $event |
|
| @@ 150-176 (lines=27) @@ | ||
| 147 | /** |
|
| 148 | * @param CartActionEvent $event |
|
| 149 | */ |
|
| 150 | static public function handleChangeQuantity(CartActionEvent $event) |
|
| 151 | { |
|
| 152 | $result = $event->getEventData(); |
|
| 153 | /** @var Currency $currency */ |
|
| 154 | $currency = static::$currency; |
|
| 155 | ||
| 156 | $ya = []; |
|
| 157 | ||
| 158 | $ya['currency'] = $currency->iso_code; |
|
| 159 | $ya['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 160 | $quantity = $item['quantity']; |
|
| 161 | /** @var Product $item */ |
|
| 162 | $item = $item['model']; |
|
| 163 | ||
| 164 | $res[] = [ |
|
| 165 | 'id' => $item->id, |
|
| 166 | 'name' => $item->name, |
|
| 167 | 'category' => self::getCategories($item), |
|
| 168 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 169 | 'quantity' => $quantity, |
|
| 170 | ]; |
|
| 171 | return $res; |
|
| 172 | }, []); |
|
| 173 | ||
| 174 | $result['ecYandex'] = $ya; |
|
| 175 | $event->setEventData($result); |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * @param CartActionEvent $event |
|
| @@ 181-207 (lines=27) @@ | ||
| 178 | /** |
|
| 179 | * @param CartActionEvent $event |
|
| 180 | */ |
|
| 181 | static public function handleClearCart(CartActionEvent $event) |
|
| 182 | { |
|
| 183 | $result = $event->getEventData(); |
|
| 184 | /** @var Currency $currency */ |
|
| 185 | $currency = static::$currency; |
|
| 186 | ||
| 187 | $ya = []; |
|
| 188 | ||
| 189 | $ya['currency'] = $currency->iso_code; |
|
| 190 | $ya['products'] = array_reduce($event->getProducts(), function($res, $item) use ($currency) { |
|
| 191 | $quantity = $item['quantity']; |
|
| 192 | /** @var Product $item */ |
|
| 193 | $item = $item['model']; |
|
| 194 | ||
| 195 | $res[] = [ |
|
| 196 | 'id' => $item->id, |
|
| 197 | 'name' => $item->name, |
|
| 198 | 'category' => self::getCategories($item), |
|
| 199 | 'price' => CurrencyHelper::convertCurrencies($item->price, $item->currency, $currency), |
|
| 200 | 'quantity' => $quantity, |
|
| 201 | ]; |
|
| 202 | return $res; |
|
| 203 | }, []); |
|
| 204 | ||
| 205 | $result['ecYandex'] = $ya; |
|
| 206 | $event->setEventData($result); |
|
| 207 | } |
|
| 208 | ||
| 209 | /** |
|
| 210 | * @param ViewEvent $event |
|