Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

initialize_session if it does not yet exist before calling the sessio… #5577

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/StoreApi/Utilities/DraftOrderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ trait DraftOrderTrait {
* @return integer
*/
protected function get_draft_order_id() {
if ( ! wc()->session ) {
wc()->initialize_session();
}
return wc()->session->get( 'store_api_draft_order', 0 );
}

Expand All @@ -22,6 +25,9 @@ protected function get_draft_order_id() {
* @param integer $order_id Draft order ID.
*/
protected function set_draft_order_id( $order_id ) {
if ( ! wc()->session ) {
wc()->initialize_session();
}
wc()->session->set( 'store_api_draft_order', $order_id );
}

Expand Down