Store order info in wc order meta to get if there is no session.

This commit is contained in:
Narek Zakarian 2022-05-10 18:46:40 +04:00
parent f78dfac648
commit ab0e90dab0
4 changed files with 26 additions and 7 deletions

View file

@ -207,12 +207,6 @@ class CreditCardRenderer {
const firstName = document.getElementById('billing_first_name') ? document.getElementById('billing_first_name').value : '';
const lastName = document.getElementById('billing_last_name') ? document.getElementById('billing_last_name').value : '';
if (!firstName || !lastName) {
this.spinner.unblock();
this.errorHandler.message(this.defaultConfig.hosted_fields.labels.cardholder_name_required);
return;
}
hostedFieldsData.cardholderName = firstName + ' ' + lastName;
}

View file

@ -242,6 +242,13 @@ class CreateOrderEndpoint implements EndpointInterface {
}
$order = $this->create_paypal_order( $wc_order );
if ( 'pay-now' === $data['context'] && is_a( $wc_order, \WC_Order::class ) ) {
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $order->id() );
$wc_order->update_meta_data( PayPalGateway::INTENT_META_KEY, $order->intent() );
$wc_order->save_meta_data();
}
wp_send_json_success( $order->to_array() );
return true;