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

Commit

Permalink
initialize_session if it does not yet exist before calling the sessio…
Browse files Browse the repository at this point in the history
…n class (#5577)
  • Loading branch information
mikejolley authored and gigitux committed Jan 17, 2022
1 parent a5fe2b2 commit fd6ba1e
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit fd6ba1e

Please sign in to comment.