Commit 7c514320101ae98e0f10c73c20eacdaaa482e77c
1 parent
0ed9dcdf
Share basket
Showing
8 changed files
with
555 additions
and
158 deletions
Show diff stats
1 | +<?php | |
2 | + /** | |
3 | + * @var \yii\web\View $this | |
4 | + * @var string $url | |
5 | + */ | |
6 | + use yii\bootstrap\Html; | |
7 | + | |
8 | + echo Html::tag('p', \Yii::t('app', 'User shared with you basket, to view follow the link down below:')); | |
9 | + echo Html::tag('p', Html::a($url, $url)); | |
0 | 10 | \ No newline at end of file | ... | ... |
composer.json
... | ... | @@ -37,7 +37,8 @@ |
37 | 37 | "kartik-v/yii2-widget-colorinput": "*", |
38 | 38 | "kartik-v/yii2-widget-datepicker": "@dev", |
39 | 39 | "nodge/yii2-eauth": "~2.0", |
40 | - "skeeks/yii2-assets-auto-compress": "*" | |
40 | + "skeeks/yii2-assets-auto-compress": "*", | |
41 | + "zyx/zyx-phpmailer": "@stable" | |
41 | 42 | }, |
42 | 43 | "require-dev": { |
43 | 44 | "yiisoft/yii2-debug": "~2.0.0", | ... | ... |
composer.lock
... | ... | @@ -4,20 +4,20 @@ |
4 | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
5 | 5 | "This file is @generated automatically" |
6 | 6 | ], |
7 | - "content-hash": "05e52a3942b2da7e252a6d47a295317c", | |
7 | + "content-hash": "f5d818fe2726a09810a6587656444937", | |
8 | 8 | "packages": [ |
9 | 9 | { |
10 | 10 | "name": "2amigos/yii2-tinymce-widget", |
11 | - "version": "1.1.1", | |
11 | + "version": "1.1.2", | |
12 | 12 | "source": { |
13 | 13 | "type": "git", |
14 | 14 | "url": "https://github.com/2amigos/yii2-tinymce-widget.git", |
15 | - "reference": "d58bad3ede450f86acd475fb4ecda982b980132b" | |
15 | + "reference": "4f519e37774ef231e4b4d6046854d5638548c8e0" | |
16 | 16 | }, |
17 | 17 | "dist": { |
18 | 18 | "type": "zip", |
19 | - "url": "https://api.github.com/repos/2amigos/yii2-tinymce-widget/zipball/d58bad3ede450f86acd475fb4ecda982b980132b", | |
20 | - "reference": "d58bad3ede450f86acd475fb4ecda982b980132b", | |
19 | + "url": "https://api.github.com/repos/2amigos/yii2-tinymce-widget/zipball/4f519e37774ef231e4b4d6046854d5638548c8e0", | |
20 | + "reference": "4f519e37774ef231e4b4d6046854d5638548c8e0", | |
21 | 21 | "shasum": "" |
22 | 22 | }, |
23 | 23 | "require": { |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | "yii 2", |
65 | 65 | "yii2" |
66 | 66 | ], |
67 | - "time": "2015-03-28T21:53:43+00:00" | |
67 | + "time": "2017-06-09T14:12:14+00:00" | |
68 | 68 | }, |
69 | 69 | { |
70 | 70 | "name": "bower-asset/amcharts", |
... | ... | @@ -82,10 +82,7 @@ |
82 | 82 | }, |
83 | 83 | "type": "bower-asset-library", |
84 | 84 | "extra": { |
85 | - "bower-asset-main": "./dist/amcharts/amcharts.js", | |
86 | - "branch-alias": { | |
87 | - "dev-master": "3.18.5-dev" | |
88 | - } | |
85 | + "bower-asset-main": "./dist/amcharts/amcharts.js" | |
89 | 86 | }, |
90 | 87 | "time": "2016-01-04 17:22:55" |
91 | 88 | }, |
... | ... | @@ -105,10 +102,7 @@ |
105 | 102 | }, |
106 | 103 | "type": "bower-asset-library", |
107 | 104 | "extra": { |
108 | - "bower-asset-main": "./dist/amcharts/amcharts.js", | |
109 | - "branch-alias": { | |
110 | - "dev-master": "3.13.0-dev" | |
111 | - } | |
105 | + "bower-asset-main": "./dist/amcharts/amcharts.js" | |
112 | 106 | }, |
113 | 107 | "time": "2015-01-28 07:40:20" |
114 | 108 | }, |
... | ... | @@ -1818,16 +1812,16 @@ |
1818 | 1812 | }, |
1819 | 1813 | { |
1820 | 1814 | "name": "mrclay/minify", |
1821 | - "version": "3.0.0", | |
1815 | + "version": "3.0.1", | |
1822 | 1816 | "source": { |
1823 | 1817 | "type": "git", |
1824 | 1818 | "url": "https://github.com/mrclay/minify.git", |
1825 | - "reference": "e904f2e1ae5e893f942e07a4860b6c47393844f1" | |
1819 | + "reference": "6a5b09a00e089bdf3e14d545fadd1525abac5e61" | |
1826 | 1820 | }, |
1827 | 1821 | "dist": { |
1828 | 1822 | "type": "zip", |
1829 | - "url": "https://api.github.com/repos/mrclay/minify/zipball/e904f2e1ae5e893f942e07a4860b6c47393844f1", | |
1830 | - "reference": "e904f2e1ae5e893f942e07a4860b6c47393844f1", | |
1823 | + "url": "https://api.github.com/repos/mrclay/minify/zipball/6a5b09a00e089bdf3e14d545fadd1525abac5e61", | |
1824 | + "reference": "6a5b09a00e089bdf3e14d545fadd1525abac5e61", | |
1831 | 1825 | "shasum": "" |
1832 | 1826 | }, |
1833 | 1827 | "require": { |
... | ... | @@ -1837,7 +1831,7 @@ |
1837 | 1831 | "mrclay/jsmin-php": "~2", |
1838 | 1832 | "mrclay/props-dic": "^2.2", |
1839 | 1833 | "php": "^5.3.0 || ^7.0", |
1840 | - "tubalmartin/cssmin": "~2.4.8-p5" | |
1834 | + "tubalmartin/cssmin": "~4" | |
1841 | 1835 | }, |
1842 | 1836 | "require-dev": { |
1843 | 1837 | "firephp/firephp-core": "~0.4.0", |
... | ... | @@ -1876,7 +1870,7 @@ |
1876 | 1870 | ], |
1877 | 1871 | "description": "Minify is a PHP5 app that helps you follow several rules for client-side performance. It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers", |
1878 | 1872 | "homepage": "https://github.com/mrclay/minify", |
1879 | - "time": "2017-04-03T20:50:53+00:00" | |
1873 | + "time": "2017-06-08T19:33:53+00:00" | |
1880 | 1874 | }, |
1881 | 1875 | { |
1882 | 1876 | "name": "mrclay/props-dic", |
... | ... | @@ -1979,16 +1973,16 @@ |
1979 | 1973 | }, |
1980 | 1974 | { |
1981 | 1975 | "name": "noam148/yii2-image-manager", |
1982 | - "version": "1.2.5", | |
1976 | + "version": "1.2.6", | |
1983 | 1977 | "source": { |
1984 | 1978 | "type": "git", |
1985 | 1979 | "url": "https://github.com/noam148/yii2-image-manager.git", |
1986 | - "reference": "a1ceb0c856bd839c1c48edca0163221775aaf624" | |
1980 | + "reference": "4f4568e40f461b6f5c6bcebbc1e56b0906319b47" | |
1987 | 1981 | }, |
1988 | 1982 | "dist": { |
1989 | 1983 | "type": "zip", |
1990 | - "url": "https://api.github.com/repos/noam148/yii2-image-manager/zipball/a1ceb0c856bd839c1c48edca0163221775aaf624", | |
1991 | - "reference": "a1ceb0c856bd839c1c48edca0163221775aaf624", | |
1984 | + "url": "https://api.github.com/repos/noam148/yii2-image-manager/zipball/4f4568e40f461b6f5c6bcebbc1e56b0906319b47", | |
1985 | + "reference": "4f4568e40f461b6f5c6bcebbc1e56b0906319b47", | |
1992 | 1986 | "shasum": "" |
1993 | 1987 | }, |
1994 | 1988 | "require": { |
... | ... | @@ -2024,7 +2018,7 @@ |
2024 | 2018 | "widget", |
2025 | 2019 | "yii2" |
2026 | 2020 | ], |
2027 | - "time": "2017-05-18T15:12:11+00:00" | |
2021 | + "time": "2017-06-11T09:21:10+00:00" | |
2028 | 2022 | }, |
2029 | 2023 | { |
2030 | 2024 | "name": "noam148/yii2-image-resize", |
... | ... | @@ -2172,6 +2166,59 @@ |
2172 | 2166 | "time": "2017-04-09T20:23:01+00:00" |
2173 | 2167 | }, |
2174 | 2168 | { |
2169 | + "name": "phpmailer/phpmailer", | |
2170 | + "version": "v5.2.8", | |
2171 | + "source": { | |
2172 | + "type": "git", | |
2173 | + "url": "https://github.com/PHPMailer/PHPMailer.git", | |
2174 | + "reference": "d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f" | |
2175 | + }, | |
2176 | + "dist": { | |
2177 | + "type": "zip", | |
2178 | + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f", | |
2179 | + "reference": "d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f", | |
2180 | + "shasum": "" | |
2181 | + }, | |
2182 | + "require": { | |
2183 | + "php": ">=5.0.0" | |
2184 | + }, | |
2185 | + "require-dev": { | |
2186 | + "phpdocumentor/phpdocumentor": "*", | |
2187 | + "phpunit/phpunit": "4.0.*" | |
2188 | + }, | |
2189 | + "type": "library", | |
2190 | + "autoload": { | |
2191 | + "classmap": [ | |
2192 | + "class.phpmailer.php", | |
2193 | + "class.pop3.php", | |
2194 | + "class.smtp.php" | |
2195 | + ] | |
2196 | + }, | |
2197 | + "notification-url": "https://packagist.org/downloads/", | |
2198 | + "license": [ | |
2199 | + "LGPL-2.1" | |
2200 | + ], | |
2201 | + "authors": [ | |
2202 | + { | |
2203 | + "name": "Jim Jagielski", | |
2204 | + "email": "jimjag@gmail.com" | |
2205 | + }, | |
2206 | + { | |
2207 | + "name": "Marcus Bointon", | |
2208 | + "email": "phpmailer@synchromedia.co.uk" | |
2209 | + }, | |
2210 | + { | |
2211 | + "name": "Andy Prevost", | |
2212 | + "email": "codeworxtech@users.sourceforge.net" | |
2213 | + }, | |
2214 | + { | |
2215 | + "name": "Brent R. Matzelle" | |
2216 | + } | |
2217 | + ], | |
2218 | + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", | |
2219 | + "time": "2014-05-14T07:04:18+00:00" | |
2220 | + }, | |
2221 | + { | |
2175 | 2222 | "name": "phpoffice/phpexcel", |
2176 | 2223 | "version": "1.8.1", |
2177 | 2224 | "source": { |
... | ... | @@ -2851,29 +2898,34 @@ |
2851 | 2898 | }, |
2852 | 2899 | { |
2853 | 2900 | "name": "tubalmartin/cssmin", |
2854 | - "version": "v2.4.8-p10", | |
2901 | + "version": "v4.1.0", | |
2855 | 2902 | "source": { |
2856 | 2903 | "type": "git", |
2857 | 2904 | "url": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port.git", |
2858 | - "reference": "9c640e5d2d6fe1eac2167ff138b8b0ce39475d03" | |
2905 | + "reference": "1c7ae93cf6b392d4dae5c4ae18979918413af16e" | |
2859 | 2906 | }, |
2860 | 2907 | "dist": { |
2861 | 2908 | "type": "zip", |
2862 | - "url": "https://api.github.com/repos/tubalmartin/YUI-CSS-compressor-PHP-port/zipball/9c640e5d2d6fe1eac2167ff138b8b0ce39475d03", | |
2863 | - "reference": "9c640e5d2d6fe1eac2167ff138b8b0ce39475d03", | |
2909 | + "url": "https://api.github.com/repos/tubalmartin/YUI-CSS-compressor-PHP-port/zipball/1c7ae93cf6b392d4dae5c4ae18979918413af16e", | |
2910 | + "reference": "1c7ae93cf6b392d4dae5c4ae18979918413af16e", | |
2864 | 2911 | "shasum": "" |
2865 | 2912 | }, |
2866 | 2913 | "require": { |
2867 | - "php": ">=5.0.0" | |
2914 | + "ext-pcre": "*", | |
2915 | + "php": ">=5.3.2" | |
2868 | 2916 | }, |
2869 | 2917 | "require-dev": { |
2870 | - "cogpowered/finediff": "0.3.*" | |
2918 | + "cogpowered/finediff": "0.3.*", | |
2919 | + "phpunit/phpunit": "4.8.*" | |
2871 | 2920 | }, |
2921 | + "bin": [ | |
2922 | + "cssmin" | |
2923 | + ], | |
2872 | 2924 | "type": "library", |
2873 | 2925 | "autoload": { |
2874 | - "classmap": [ | |
2875 | - "cssmin.php" | |
2876 | - ] | |
2926 | + "psr-4": { | |
2927 | + "tubalmartin\\CssMin\\": "src" | |
2928 | + } | |
2877 | 2929 | }, |
2878 | 2930 | "notification-url": "https://packagist.org/downloads/", |
2879 | 2931 | "license": [ |
... | ... | @@ -2895,7 +2947,7 @@ |
2895 | 2947 | "minify", |
2896 | 2948 | "yui" |
2897 | 2949 | ], |
2898 | - "time": "2017-04-04T14:38:03+00:00" | |
2950 | + "time": "2017-05-16T13:45:26+00:00" | |
2899 | 2951 | }, |
2900 | 2952 | { |
2901 | 2953 | "name": "yii2tech/filedb", |
... | ... | @@ -3300,6 +3352,50 @@ |
3300 | 3352 | "yii2" |
3301 | 3353 | ], |
3302 | 3354 | "time": "2017-05-22T11:24:30+00:00" |
3355 | + }, | |
3356 | + { | |
3357 | + "name": "zyx/zyx-phpmailer", | |
3358 | + "version": "0.9.2", | |
3359 | + "source": { | |
3360 | + "type": "git", | |
3361 | + "url": "https://github.com/SDKiller/zyx-phpmailer.git", | |
3362 | + "reference": "2032706c35a345f875c4acf310600098a37ca469" | |
3363 | + }, | |
3364 | + "dist": { | |
3365 | + "type": "zip", | |
3366 | + "url": "https://api.github.com/repos/SDKiller/zyx-phpmailer/zipball/2032706c35a345f875c4acf310600098a37ca469", | |
3367 | + "reference": "2032706c35a345f875c4acf310600098a37ca469", | |
3368 | + "shasum": "" | |
3369 | + }, | |
3370 | + "require": { | |
3371 | + "phpmailer/phpmailer": "v5.2.8", | |
3372 | + "yiisoft/yii2": "*" | |
3373 | + }, | |
3374 | + "type": "yii2-extension", | |
3375 | + "autoload": { | |
3376 | + "psr-4": { | |
3377 | + "zyx\\phpmailer\\": "" | |
3378 | + } | |
3379 | + }, | |
3380 | + "notification-url": "https://packagist.org/downloads/", | |
3381 | + "license": [ | |
3382 | + "BSD-3-Clause" | |
3383 | + ], | |
3384 | + "authors": [ | |
3385 | + { | |
3386 | + "name": "Serge Postrash aka SDKiller", | |
3387 | + "email": "jexy.ru@gmail.com" | |
3388 | + } | |
3389 | + ], | |
3390 | + "description": "PHPMailer integration for Yii 2 framework", | |
3391 | + "keywords": [ | |
3392 | + "email", | |
3393 | + "mail", | |
3394 | + "mailer", | |
3395 | + "phpmailer", | |
3396 | + "yii2" | |
3397 | + ], | |
3398 | + "time": "2014-05-14T20:30:24+00:00" | |
3303 | 3399 | } |
3304 | 3400 | ], |
3305 | 3401 | "packages-dev": [ |
... | ... | @@ -5412,16 +5508,16 @@ |
5412 | 5508 | }, |
5413 | 5509 | { |
5414 | 5510 | "name": "symfony/polyfill-mbstring", |
5415 | - "version": "v1.3.0", | |
5511 | + "version": "v1.4.0", | |
5416 | 5512 | "source": { |
5417 | 5513 | "type": "git", |
5418 | 5514 | "url": "https://github.com/symfony/polyfill-mbstring.git", |
5419 | - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" | |
5515 | + "reference": "f29dca382a6485c3cbe6379f0c61230167681937" | |
5420 | 5516 | }, |
5421 | 5517 | "dist": { |
5422 | 5518 | "type": "zip", |
5423 | - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", | |
5424 | - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", | |
5519 | + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", | |
5520 | + "reference": "f29dca382a6485c3cbe6379f0c61230167681937", | |
5425 | 5521 | "shasum": "" |
5426 | 5522 | }, |
5427 | 5523 | "require": { |
... | ... | @@ -5433,7 +5529,7 @@ |
5433 | 5529 | "type": "library", |
5434 | 5530 | "extra": { |
5435 | 5531 | "branch-alias": { |
5436 | - "dev-master": "1.3-dev" | |
5532 | + "dev-master": "1.4-dev" | |
5437 | 5533 | } |
5438 | 5534 | }, |
5439 | 5535 | "autoload": { |
... | ... | @@ -5467,7 +5563,7 @@ |
5467 | 5563 | "portable", |
5468 | 5564 | "shim" |
5469 | 5565 | ], |
5470 | - "time": "2016-11-14T01:06:16+00:00" | |
5566 | + "time": "2017-06-09T14:24:12+00:00" | |
5471 | 5567 | }, |
5472 | 5568 | { |
5473 | 5569 | "name": "symfony/yaml", |
... | ... | @@ -5769,7 +5865,8 @@ |
5769 | 5865 | "kartik-v/yii2-widget-select2": 20, |
5770 | 5866 | "bower-asset/amcharts": 20, |
5771 | 5867 | "bower-asset/pnotify": 20, |
5772 | - "kartik-v/yii2-widget-datepicker": 20 | |
5868 | + "kartik-v/yii2-widget-datepicker": 20, | |
5869 | + "zyx/zyx-phpmailer": 0 | |
5773 | 5870 | }, |
5774 | 5871 | "prefer-stable": false, |
5775 | 5872 | "prefer-lowest": false, | ... | ... |
frontend/controllers/SiteController.php
... | ... | @@ -14,11 +14,14 @@ |
14 | 14 | use artbox\order\models\SignupForm; |
15 | 15 | use artbox\weblog\models\Article; |
16 | 16 | use common\models\Settings; |
17 | + use frontend\models\ShareBasket; | |
17 | 18 | use nodge\eauth\ErrorException; |
18 | 19 | use nodge\eauth\openid\ControllerBehavior; |
19 | 20 | use Yii; |
20 | 21 | use yii\base\InvalidParamException; |
21 | 22 | use yii\bootstrap\Html; |
23 | + use yii\helpers\Json; | |
24 | + use yii\helpers\Url; | |
22 | 25 | use yii\web\BadRequestHttpException; |
23 | 26 | use yii\web\Controller; |
24 | 27 | use yii\filters\VerbFilter; |
... | ... | @@ -50,7 +53,8 @@ |
50 | 53 | 'verbs' => [ |
51 | 54 | 'class' => VerbFilter::className(), |
52 | 55 | 'actions' => [ |
53 | - 'feedback' => [ 'post' ], | |
56 | + 'feedback' => [ 'post' ], | |
57 | + 'share-basket' => [ 'post' ], | |
54 | 58 | ], |
55 | 59 | ], |
56 | 60 | 'eauth' => [ |
... | ... | @@ -298,14 +302,14 @@ |
298 | 302 | Yii::$app->getUrlManager() |
299 | 303 | ->createAbsoluteUrl('site/login') |
300 | 304 | ); |
301 | - | |
305 | + | |
302 | 306 | try { |
303 | 307 | if ($eauth->authenticate()) { |
304 | 308 | // var_dump($eauth->getIsAuthenticated(), $eauth->getAttributes()); exit; |
305 | 309 | $identity = Customer::findByEAuth($eauth); |
306 | 310 | Yii::$app->getUser() |
307 | 311 | ->login($identity); |
308 | - | |
312 | + | |
309 | 313 | // special redirect with closing popup window |
310 | 314 | $eauth->redirect(); |
311 | 315 | } else { |
... | ... | @@ -316,7 +320,7 @@ |
316 | 320 | // save error to show it later |
317 | 321 | Yii::$app->getSession() |
318 | 322 | ->setFlash('error', 'EAuthException: ' . $e->getMessage()); |
319 | - | |
323 | + | |
320 | 324 | // close popup window and redirect to cancelUrl |
321 | 325 | // $eauth->cancel(); |
322 | 326 | $eauth->redirect($eauth->getCancelUrl()); |
... | ... | @@ -418,4 +422,33 @@ |
418 | 422 | ] |
419 | 423 | ); |
420 | 424 | } |
425 | + | |
426 | + public function actionShareBasket() | |
427 | + { | |
428 | + $response = \Yii::$app->response; | |
429 | + $response->format = $response::FORMAT_JSON; | |
430 | + $model = new ShareBasket(); | |
431 | + if ($model->load(\Yii::$app->request->post()) && $model->validate()) { | |
432 | + $result = $model->send(); | |
433 | + return $result; | |
434 | + } else { | |
435 | + return [ | |
436 | + 'success' => false, | |
437 | + 'msg' => \Yii::t('app', 'Email is not set.'), | |
438 | + ]; | |
439 | + } | |
440 | + } | |
441 | + | |
442 | + public function actionGetBasket($items) | |
443 | + { | |
444 | + /** | |
445 | + * @var \artbox\order\models\Basket $basket | |
446 | + */ | |
447 | + $basket = \Yii::$app->get('basket'); | |
448 | + $itemArray = Json::decode($items); | |
449 | + foreach ($itemArray as $variantId => $count) { | |
450 | + $basket->set($variantId, $count); | |
451 | + } | |
452 | + return $this->redirect('/checkout/index'); | |
453 | + } | |
421 | 454 | } | ... | ... |
1 | +<?php | |
2 | + /** | |
3 | + * Created by PhpStorm. | |
4 | + * User: yarik | |
5 | + * Date: 12.06.17 | |
6 | + * Time: 11:21 | |
7 | + */ | |
8 | + | |
9 | + namespace frontend\models; | |
10 | + | |
11 | + use yii\base\Model; | |
12 | + use yii\helpers\Json; | |
13 | + use yii\helpers\Url; | |
14 | + | |
15 | + class ShareBasket extends Model | |
16 | + { | |
17 | + public $email; | |
18 | + public $url = 'site/get-basket'; | |
19 | + public $from = 'artbox@artbox.dev'; | |
20 | + | |
21 | + /** | |
22 | + * @inheritdoc | |
23 | + */ | |
24 | + public function rules() | |
25 | + { | |
26 | + return [ | |
27 | + [ | |
28 | + [ | |
29 | + 'email', | |
30 | + ], | |
31 | + 'email', | |
32 | + ], | |
33 | + [ | |
34 | + [ | |
35 | + 'email', | |
36 | + ], | |
37 | + 'required', | |
38 | + ], | |
39 | + ]; | |
40 | + } | |
41 | + | |
42 | + public function attributeLabels() | |
43 | + { | |
44 | + return [ | |
45 | + 'email' => \Yii::t('app', 'Поделиться корзиной'), | |
46 | + ]; | |
47 | + } | |
48 | + | |
49 | + public function send() | |
50 | + { | |
51 | + /** | |
52 | + * @var \artbox\order\models\Basket $basket | |
53 | + */ | |
54 | + $basket = \Yii::$app->get('basket'); | |
55 | + $data = $basket->getData(); | |
56 | + if (empty($data)) { | |
57 | + return [ | |
58 | + 'success' => false, | |
59 | + 'msg' => \Yii::t('app', 'Basket is empty'), | |
60 | + ]; | |
61 | + } | |
62 | + $dataArray = []; | |
63 | + foreach ($data as $variantId => $item) { | |
64 | + $dataArray[ $variantId ] = $item[ 'count' ]; | |
65 | + } | |
66 | + $dataString = Json::encode($dataArray); | |
67 | + $url = Url::to( | |
68 | + [ | |
69 | + $this->url, | |
70 | + 'items' => $dataString, | |
71 | + ], | |
72 | + true | |
73 | + ); | |
74 | + if (\Yii::$app->mailer->compose( | |
75 | + [ 'html' => 'shareBasket' ], | |
76 | + [ | |
77 | + 'url' => $url, | |
78 | + ] | |
79 | + ) | |
80 | + ->setFrom($this->from) | |
81 | + ->setTo($this->email) | |
82 | + ->setSubject(\Yii::t('app', 'Shared basket')) | |
83 | + ->send() | |
84 | + ) { | |
85 | + return [ | |
86 | + 'success' => true, | |
87 | + 'msg' => \Yii::t('app', 'Email successfully sent.'), | |
88 | + ]; | |
89 | + } else { | |
90 | + return [ | |
91 | + 'success' => false, | |
92 | + 'msg' => \Yii::t('app', 'Email cannot be send.'), | |
93 | + | |
94 | + ]; | |
95 | + } | |
96 | + } | |
97 | + } | |
0 | 98 | \ No newline at end of file | ... | ... |
frontend/views/checkout/index.php
... | ... | @@ -6,6 +6,8 @@ |
6 | 6 | * @var \artbox\catalog\models\Product[] $topItems |
7 | 7 | */ |
8 | 8 | use artbox\core\helpers\ImageHelper; |
9 | + use frontend\models\ShareBasket; | |
10 | + use yii\bootstrap\ActiveForm; | |
9 | 11 | use yii\bootstrap\Html; |
10 | 12 | |
11 | 13 | $formatter = \Yii::$app->formatter; |
... | ... | @@ -136,33 +138,86 @@ |
136 | 138 | <!-- /.table-responsive --> |
137 | 139 | |
138 | 140 | <div class="box-footer"> |
139 | - <div class="pull-left"> | |
140 | - <?php | |
141 | - echo Html::a( | |
142 | - Html::icon('chevron-left', [ 'prefix' => 'fa fa-' ]) . \Yii::t( | |
143 | - 'app', | |
144 | - ' Продолжить покупки' | |
145 | - ), | |
146 | - [ 'site/index' ], | |
147 | - [ | |
148 | - 'class' => 'btn btn-default', | |
149 | - ] | |
150 | - ) | |
151 | - ?> | |
141 | + <div class="col-xs-12"> | |
142 | + <div class="col-xs-12 col-sm-9"> | |
143 | + <?php | |
144 | + $shareBasket = new ShareBasket(); | |
145 | + $shareBasketForm = ActiveForm::begin( | |
146 | + [ | |
147 | + 'action' => [ '/site/share-basket' ], | |
148 | + 'options' => [ | |
149 | + 'class' => 'share-basket-form', | |
150 | + 'data' => [ | |
151 | + 'title' => \Yii::t('app', 'Shared basket'), | |
152 | + 'msg' => \Yii::t('app', 'Basket successfully shared.'), | |
153 | + ], | |
154 | + ], | |
155 | + ] | |
156 | + ); | |
157 | + ?> | |
158 | + <div class="col-xs-12 col-sm-4"> | |
159 | + <?php | |
160 | + echo Html::label( | |
161 | + $shareBasket->getAttributeLabel('email'), | |
162 | + Html::getInputId($shareBasket, 'email') | |
163 | + ); | |
164 | + ?> | |
165 | + </div> | |
166 | + <div class="col-xs-12 col-sm-6"> | |
167 | + <?php | |
168 | + echo $shareBasketForm->field($shareBasket, 'email') | |
169 | + ->textInput( | |
170 | + [ | |
171 | + 'placeholder' => 'email@email.com', | |
172 | + ] | |
173 | + ) | |
174 | + ->label(false); | |
175 | + ?> | |
176 | + </div> | |
177 | + <div class="col-xs-12 col-sm-2"> | |
178 | + <?php | |
179 | + echo Html::submitButton( | |
180 | + \Yii::t('app', 'Ok'), | |
181 | + [ | |
182 | + 'class' => 'btn btn-primary', | |
183 | + ] | |
184 | + ); | |
185 | + ?> | |
186 | + </div> | |
187 | + <?php | |
188 | + $shareBasketForm::end(); | |
189 | + ?> | |
190 | + </div> | |
152 | 191 | </div> |
153 | - <div class="pull-right"> | |
154 | - <?php | |
155 | - echo Html::a( | |
156 | - \Yii::t( | |
157 | - 'app', | |
158 | - ' Оформить заказ ' | |
159 | - ) . Html::icon('chevron-right', [ 'prefix' => 'fa fa-' ]), | |
160 | - [ 'checkout/info' ], | |
161 | - [ | |
162 | - 'class' => 'btn btn-success', | |
163 | - ] | |
164 | - ) | |
165 | - ?> | |
192 | + <div class="col-xs-12"> | |
193 | + <div class="pull-left"> | |
194 | + <?php | |
195 | + echo Html::a( | |
196 | + Html::icon('chevron-left', [ 'prefix' => 'fa fa-' ]) . \Yii::t( | |
197 | + 'app', | |
198 | + ' Продолжить покупки' | |
199 | + ), | |
200 | + [ 'site/index' ], | |
201 | + [ | |
202 | + 'class' => 'btn btn-default', | |
203 | + ] | |
204 | + ) | |
205 | + ?> | |
206 | + </div> | |
207 | + <div class="pull-right"> | |
208 | + <?php | |
209 | + echo Html::a( | |
210 | + \Yii::t( | |
211 | + 'app', | |
212 | + ' Оформить заказ ' | |
213 | + ) . Html::icon('chevron-right', [ 'prefix' => 'fa fa-' ]), | |
214 | + [ 'checkout/info' ], | |
215 | + [ | |
216 | + 'class' => 'btn btn-success', | |
217 | + ] | |
218 | + ) | |
219 | + ?> | |
220 | + </div> | |
166 | 221 | </div> |
167 | 222 | </div> |
168 | 223 | ... | ... |
frontend/views/layouts/_basket_modal.php
... | ... | @@ -5,6 +5,8 @@ |
5 | 5 | <h4 class="modal-title callback text-center" id="Login"> |
6 | 6 | <?php |
7 | 7 | use artbox\core\helpers\ImageHelper; |
8 | + use frontend\models\ShareBasket; | |
9 | + use yii\bootstrap\ActiveForm; | |
8 | 10 | use yii\bootstrap\Html; |
9 | 11 | |
10 | 12 | echo Html::a( |
... | ... | @@ -189,6 +191,55 @@ |
189 | 191 | <!-- /.table-responsive --> |
190 | 192 | |
191 | 193 | <div class="box-footer"> |
194 | + <div class="col-xs-12 col-sm-9"> | |
195 | + <?php | |
196 | + $shareBasket = new ShareBasket(); | |
197 | + $shareBasketForm = ActiveForm::begin( | |
198 | + [ | |
199 | + 'action' => [ '/site/share-basket' ], | |
200 | + 'options' => [ | |
201 | + 'class' => 'share-basket-form', | |
202 | + 'data' => [ | |
203 | + 'title' => \Yii::t('app', 'Shared basket'), | |
204 | + 'msg' => \Yii::t('app', 'Basket successfully shared.'), | |
205 | + ], | |
206 | + ], | |
207 | + ] | |
208 | + ); | |
209 | + ?> | |
210 | + <div class="col-xs-12 col-sm-4"> | |
211 | + <?php | |
212 | + echo Html::label( | |
213 | + $shareBasket->getAttributeLabel('email'), | |
214 | + Html::getInputId($shareBasket, 'email') | |
215 | + ); | |
216 | + ?> | |
217 | + </div> | |
218 | + <div class="col-xs-12 col-sm-6"> | |
219 | + <?php | |
220 | + echo $shareBasketForm->field($shareBasket, 'email') | |
221 | + ->textInput( | |
222 | + [ | |
223 | + 'placeholder' => 'email@email.com', | |
224 | + ] | |
225 | + ) | |
226 | + ->label(false); | |
227 | + ?> | |
228 | + </div> | |
229 | + <div class="col-xs-12 col-sm-2"> | |
230 | + <?php | |
231 | + echo Html::submitButton( | |
232 | + \Yii::t('app', 'Ok'), | |
233 | + [ | |
234 | + 'class' => 'btn btn-primary', | |
235 | + ] | |
236 | + ); | |
237 | + ?> | |
238 | + </div> | |
239 | + <?php | |
240 | + $shareBasketForm::end(); | |
241 | + ?> | |
242 | + </div> | |
192 | 243 | <div class="pull-right"> |
193 | 244 | <?php |
194 | 245 | echo Html::a( | ... | ... |
frontend/web/js/script.js
... | ... | @@ -126,12 +126,22 @@ $(function() { |
126 | 126 | .parents('.product-row-basket') |
127 | 127 | .data('id'); |
128 | 128 | showLoader('#basket'); |
129 | + showLoader('#basket-modal'); | |
129 | 130 | var xhr = basket.remove(id); |
130 | 131 | xhr.done(function() { |
132 | + if ($('#basket').length) { | |
133 | + $.pjax.reload({ | |
134 | + container: '#basket', | |
135 | + fragment: '#basket', | |
136 | + timeout: 5000, | |
137 | + async: false | |
138 | + }); | |
139 | + } | |
131 | 140 | $.pjax.reload({ |
132 | - container: '#basket', | |
133 | - fragment: '#basket', | |
134 | - timeout: 5000 | |
141 | + container: '#basket-modal', | |
142 | + fragment: '#basket-modal', | |
143 | + timeout: 5000, | |
144 | + async: false | |
135 | 145 | }); |
136 | 146 | }) |
137 | 147 | }); |
... | ... | @@ -150,13 +160,15 @@ $(function() { |
150 | 160 | $.pjax.reload({ |
151 | 161 | container: '#basket', |
152 | 162 | fragment: '#basket', |
153 | - timeout: 5000 | |
163 | + timeout: 5000, | |
164 | + async: false | |
154 | 165 | }); |
155 | 166 | } |
156 | 167 | $.pjax.reload({ |
157 | 168 | container: '#basket-modal', |
158 | 169 | fragment: '#basket-modal', |
159 | - timeout: 5000 | |
170 | + timeout: 5000, | |
171 | + async: false | |
160 | 172 | }); |
161 | 173 | }); |
162 | 174 | }); |
... | ... | @@ -187,86 +199,88 @@ $(function() { |
187 | 199 | }.bind(this)); |
188 | 200 | |
189 | 201 | $(document) |
190 | - .on( | |
191 | - 'click', '.wishlist-rm, .wishlist-add', function() { | |
192 | - var button = $(this); | |
193 | - $.ajax( | |
194 | - { | |
195 | - url: button.data('url'), | |
196 | - type: "POST", | |
197 | - data: { | |
198 | - 'variant': button.data('variant'), | |
199 | - 'product': button.data('product'), | |
200 | - 'user': button.data('user') | |
201 | - }, | |
202 | - success: function(data) { | |
203 | - button.replaceWith(data.button); | |
204 | - new PNotify( | |
205 | - { | |
206 | - title: 'Info', | |
207 | - text: data.message, | |
208 | - type: 'info', | |
209 | - styling: 'fontawesome' | |
210 | - } | |
211 | - ); | |
202 | + .on('click', '.wishlist-rm, .wishlist-add', function() { | |
203 | + var button = $(this); | |
204 | + $.ajax({ | |
205 | + url: button.data('url'), | |
206 | + type: "POST", | |
207 | + data: { | |
208 | + 'variant': button.data('variant'), | |
209 | + 'product': button.data('product'), | |
210 | + 'user': button.data('user') | |
211 | + }, | |
212 | + success: function(data) { | |
213 | + button.replaceWith(data.button); | |
214 | + new PNotify({ | |
215 | + title: 'Info', | |
216 | + text: data.message, | |
217 | + type: 'info', | |
218 | + styling: 'fontawesome' | |
219 | + }); | |
212 | 220 | |
213 | - } | |
214 | - } | |
215 | - ) | |
216 | - } | |
217 | - ); | |
221 | + } | |
222 | + }) | |
223 | + }); | |
218 | 224 | |
219 | 225 | $(document) |
220 | - .on( | |
221 | - 'click', '.wishlist-delete', function(e) { | |
222 | - e.preventDefault(); | |
223 | - var button = $(this); | |
224 | - $.ajax( | |
225 | - { | |
226 | - url: button.data('url'), | |
227 | - type: "POST", | |
228 | - data: { | |
229 | - 'product': button.data('product'), | |
230 | - 'variant': button.data('variant'), | |
231 | - 'user': button.data('user') | |
232 | - }, | |
233 | - success: function(data) { | |
234 | - if (data.success) { | |
235 | - $.pjax.reload({container: '#wishlist-products'}); | |
236 | - new PNotify( | |
237 | - { | |
238 | - title: 'Info', | |
239 | - text: data.message, | |
240 | - type: 'info', | |
241 | - styling: 'fontawesome' | |
242 | - } | |
243 | - ); | |
244 | - } | |
245 | - } | |
226 | + .on('click', '.wishlist-delete', function(e) { | |
227 | + e.preventDefault(); | |
228 | + var button = $(this); | |
229 | + $.ajax({ | |
230 | + url: button.data('url'), | |
231 | + type: "POST", | |
232 | + data: { | |
233 | + 'product': button.data('product'), | |
234 | + 'variant': button.data('variant'), | |
235 | + 'user': button.data('user') | |
236 | + }, | |
237 | + success: function(data) { | |
238 | + if (data.success) { | |
239 | + $.pjax.reload({container: '#wishlist-products'}); | |
240 | + new PNotify({ | |
241 | + title: 'Info', | |
242 | + text: data.message, | |
243 | + type: 'info', | |
244 | + styling: 'fontawesome' | |
245 | + }); | |
246 | 246 | } |
247 | - ); | |
248 | - } | |
249 | - ); | |
250 | - $(document).on('click', '.sort-cat>a', function(e){ | |
251 | - $(this).parent().toggleClass("active"); | |
252 | - return false; | |
253 | - }); | |
254 | - $(document).on('click', '.sorter li a', function(e){ | |
255 | - var sortclick = $(this).text(); | |
256 | - parentsort = $(".sort-cat a span"); | |
257 | - pstext = $(parentsort).text(); | |
258 | - mainlink = $(".sort-cat a").attr('href'); | |
259 | - newmainlink = $(this).attr('href'); | |
247 | + } | |
248 | + }); | |
249 | + }); | |
250 | + $(document) | |
251 | + .on('click', '.sort-cat>a', function(e) { | |
252 | + $(this) | |
253 | + .parent() | |
254 | + .toggleClass("active"); | |
255 | + return false; | |
256 | + }); | |
257 | + $(document) | |
258 | + .on('click', '.sorter li a', function(e) { | |
259 | + var sortclick = $(this) | |
260 | + .text(); | |
261 | + parentsort = $(".sort-cat a span"); | |
262 | + pstext = $(parentsort) | |
263 | + .text(); | |
264 | + mainlink = $(".sort-cat a") | |
265 | + .attr('href'); | |
266 | + newmainlink = $(this) | |
267 | + .attr('href'); | |
260 | 268 | |
261 | - $(parentsort).text(sortclick); | |
262 | - $(".sort-cat>a").attr('href', newmainlink); | |
263 | - $(this).text(pstext); | |
264 | - $(this).attr('href', mainlink); | |
265 | - $(".sort-cat>a").click(); | |
269 | + $(parentsort) | |
270 | + .text(sortclick); | |
271 | + $(".sort-cat>a") | |
272 | + .attr('href', newmainlink); | |
273 | + $(this) | |
274 | + .text(pstext); | |
275 | + $(this) | |
276 | + .attr('href', mainlink); | |
277 | + $(".sort-cat>a") | |
278 | + .click(); | |
266 | 279 | |
267 | - $(location).attr('href',newmainlink); | |
268 | - return false; | |
269 | - }); | |
280 | + $(location) | |
281 | + .attr('href', newmainlink); | |
282 | + return false; | |
283 | + }); | |
270 | 284 | |
271 | 285 | // Price slider |
272 | 286 | $('.price-inputs input') |
... | ... | @@ -371,14 +385,54 @@ $(function() { |
371 | 385 | $('.vcovers') |
372 | 386 | .perfectScrollbar({wheelSpeed: 0.5}); |
373 | 387 | |
374 | - $(document).on('click', '.sidebar-menu .form-group .hiddens-button a.btn', function(){ | |
375 | - $(this).parent().parent().find(".hiddens").toggleClass("active"); | |
376 | - $(this).text(function(i, text){ | |
377 | - return text === "Ещё" ? "Скрыть" : "Ещё"; | |
388 | + $(document) | |
389 | + .on('click', '.sidebar-menu .form-group .hiddens-button a.btn', function() { | |
390 | + $(this) | |
391 | + .parent() | |
392 | + .parent() | |
393 | + .find(".hiddens") | |
394 | + .toggleClass("active"); | |
395 | + $(this) | |
396 | + .text(function(i, text) { | |
397 | + return text === "Ещё" ? "Скрыть" : "Ещё"; | |
398 | + }); | |
399 | + return false; | |
378 | 400 | }); |
379 | - return false; | |
380 | - }); | |
381 | 401 | |
402 | + $(document) | |
403 | + .on('beforeSubmit', '.share-basket-form', function(e) { | |
404 | + $.post($(this) | |
405 | + .attr('action'), $(this) | |
406 | + .serialize(), function(data) { | |
407 | + }); | |
408 | + new PNotify({ | |
409 | + title: $(this) | |
410 | + .data('title'), | |
411 | + text: $(this) | |
412 | + .data('msg'), | |
413 | + type: 'info', | |
414 | + styling: 'fontawesome' | |
415 | + }); | |
416 | + this.reset(); | |
417 | + return false; | |
418 | + }); | |
419 | + $(document) | |
420 | + .on('submit', '.share-basket-form', function(e) { | |
421 | + $.post($(this) | |
422 | + .attr('action'), $(this) | |
423 | + .serialize(), function(data) { | |
424 | + }); | |
425 | + new PNotify({ | |
426 | + title: $(this) | |
427 | + .data('title'), | |
428 | + text: $(this) | |
429 | + .data('msg'), | |
430 | + type: 'info', | |
431 | + styling: 'fontawesome' | |
432 | + }); | |
433 | + this.reset(); | |
434 | + return false; | |
435 | + }); | |
382 | 436 | }); |
383 | 437 | function showLoader(container) { |
384 | 438 | $(container) | ... | ... |