@@ -103,13 +103,15 @@ private function data(&$checkoutInfo) {
103
103
function index () {
104
104
$ options = array_intersect_key ($ this ->global ['site ' ],
105
105
array_flip (['weight_type_id ' , 'length_type_id ' , 'currency_id ' , 'country_id ' ]));
106
- $ cart = Cart :: getInstance ($ options );
106
+ $ cart = Cart :: getInstance ($ this -> global + $ options );
107
107
108
108
//buy now product
109
- if (isset ($ this ->request ->request ['product_id ' ])) {
110
- $ productId = $ this ->request ->request ['product_id ' ];
111
- $ quantity = $ this ->request ->post ['quantity ' ] ?? 1 ;
112
- $ cart ->add ($ productId , $ quantity );
109
+ if (isset ($ this ->request ->get ['product_id ' ])) {
110
+ $ productId = $ this ->request ->get ['product_id ' ];
111
+ $ quantity = $ this ->request ->post ['quantity ' ] ?? 1 ;
112
+ $ option = $ this ->request ->post ['option ' ] ?? [];
113
+ $ subscriptionPlanId = $ this ->request ->post ['subscription_plan_id ' ] ?? false ;
114
+ $ cart ->add ($ productId , $ quantity , $ option , $ subscriptionPlanId );
113
115
}
114
116
115
117
if (! $ cart ->hasProducts ()) {
@@ -265,18 +267,24 @@ function index() {
265
267
$ userInfo ['display_name ' ] = $ userInfo ['first_name ' ] . ' ' . $ userInfo ['last_name ' ];
266
268
$ userInfo ['username ' ] = str_replace (' ' , '' , $ userInfo ['first_name ' ] . $ userInfo ['last_name ' ]);
267
269
268
- $ error = __ ('Error creating account! ' );
269
-
270
- if ($ result = User::add ($ userInfo )) {
271
- $ checkoutInfo ['user_id ' ] = $ result ['user ' ] ?? NULL ;
272
- $ userInfo = User::get (['user_id ' => $ user_id ]);
273
- //check if user was added before automatic login
274
- if ($ userInfo ) {
275
- \Vvveb \session (['user ' => $ userInfo ]);
276
- $ this ->view ->global ['user_id ' ] = $ userInfo ['user_id ' ];
270
+ $ result = User::add ($ userInfo );
271
+
272
+ if ($ result ) {
273
+ if (isset ($ result ['user ' ])) {
274
+ $ checkoutInfo ['user_id ' ] = $ result ['user ' ] ?? NULL ;
275
+ $ userInfo = User::get (['user_id ' => $ checkoutInfo ['user_id ' ]]);
276
+ //check if user was added before automatic login
277
+ if ($ userInfo ) {
278
+ \Vvveb \session (['user ' => $ userInfo ]);
279
+ $ this ->view ->global ['user_id ' ] = $ userInfo ['user_id ' ];
280
+ }
281
+ } else {
282
+ $ this ->view ->errors [] = __ ('This email is already in use. Please use another one or login. ' );
283
+
284
+ return ;
277
285
}
278
286
} else {
279
- $ this ->view ->errors [] = $ error ;
287
+ $ this ->view ->errors [] = __ ( ' Error creating account! ' ) ;
280
288
281
289
return ;
282
290
}
0 commit comments