Skip to content

Commit

Permalink
Add possibility to set checkout without validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lopes-vincent committed Apr 8, 2021
1 parent 443b558 commit 4ab51af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0.2</version>
<version>1.0.6</version>
<authors>
<author>
<name>Vincent Lopes-Vicente</name>
Expand Down
16 changes: 13 additions & 3 deletions Controller/Front/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ class CheckoutController extends BaseFrontOpenApiController
* summary="Validate and set an checkout",
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(ref="#/components/schemas/Checkout")
* @OA\JsonContent(
* allOf={
* @OA\Schema(@OA\Property(property="needValidate", type="boolean", default=false)),
* @OA\Schema(ref="#/components/schemas/Checkout")
* }
* )
* ),
* @OA\Response(
* response="200",
Expand Down Expand Up @@ -64,9 +69,14 @@ public function setCheckout(Request $request)
}
}

$decodedContent = json_decode($request->getContent(), true);

/** @var Checkout $checkout */
$checkout = $this->getModelFactory()->buildModel('Checkout', $request->getContent());
$checkout->checkIsValid();
$checkout = $this->getModelFactory()->buildModel('Checkout', $decodedContent);

if (isset($decodedContent['needValidate']) && true === $decodedContent['needValidate']) {
$checkout->checkIsValid();
}

$order = $this->getOrder($this->getRequest());
$orderEvent = new OrderEvent($order);
Expand Down

0 comments on commit 4ab51af

Please sign in to comment.