Do not create wc order in webhook when no form data

This commit is contained in:
Alex P 2023-07-21 19:35:56 +03:00
parent 8835f4b2a9
commit e678967c55
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -159,6 +159,14 @@ class CheckoutOrderApproved implements RequestHandler {
WC()->cart->calculate_shipping();
$form = $this->session_handler->checkout_form();
if ( ! $form ) {
return $this->failure_response(
sprintf(
'Failed to create WC order in webhook event %s, checkout data not found.',
$request['id'] ?: ''
)
);
}
$checkout = new WC_Checkout();
$wc_order_id = $checkout->create_order( $form );