Skip to content

Commit

Permalink
Merge branch 'stable' into franz/changelogs_20211227
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiroellplenty authored Dec 27, 2021
2 parents 9c71106 + 79cf0f2 commit c2460e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Api/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ public function create($data, int $code = ResponseCode::OK, array $headers = [])
/** @var CheckoutService $checkoutService */
$checkoutService = pluginApp(CheckoutService::class);

$responseData['events']['CheckoutChanged']['checkout'] = $checkoutService->getCheckout();
$responseData['events']['AfterBasketChanged']['basket'] = $basketService->getBasketForTemplate();
$responseData['events']['AfterBasketChanged']['showNetPrices'] = $contactRepository->showNetPrices();
$responseData['events']['AfterBasketChanged']['basketItems'] = $basketService->getBasketItemsForTemplate(
'',
false
);
$responseData['events']['CheckoutChanged']['checkout'] = $checkoutService->getCheckout();
}

$responseData["data"] = $data;
Expand Down
10 changes: 7 additions & 3 deletions src/Middlewares/DetectLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ public function before(Request $request)
$webstoreConfig = $webstoreConfigurationRepository->getWebstoreConfiguration();
$splittedURL = explode('/', $request->get('plentyMarkets'));

CategoryController::$LANGUAGE_FROM_URL = $splittedURL[0] ?: Utils::getDefaultLang();
$isValidLang = in_array($splittedURL[0], Utils::getLanguageList());
if ($isValidLang) {
CategoryController::$LANGUAGE_FROM_URL = $splittedURL[0];
} else {
CategoryController::$LANGUAGE_FROM_URL = Utils::getDefaultLang();
}

if (strpos(end($splittedURL), '.') === false) {
// language has not been detected. check if url points to default language
$this->setLanguage($request->get('Lang', $splittedURL[0]), $webstoreConfig);
$this->setLanguage($request->get('Lang', CategoryController::$LANGUAGE_FROM_URL), $webstoreConfig);
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/Providers/IOServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,16 @@ function (/** @var AfterBasketChanged $event */ $event) {

if(($error = $event->getCouponValidationError()) instanceof ValidationException) {
$messageBag = $error->getMessageBag();
if (is_null($messageBag)) {
$message = $error->getMessage();
$code = $error->getCode();
} else {
$message = $messageBag->first();
$code = $messageBag->keys()[0];
}
/** @var NotificationService $notificationService */
$notificationService = pluginApp(NotificationService::class);
$notificationService->warn($messageBag->first(), 1000 + $messageBag->keys()[0]);
$notificationService->warn($message, 1000 + $code);
}
}
);
Expand Down

0 comments on commit c2460e6

Please sign in to comment.