Skip to content

Commit

Permalink
Add support for programatically setting a code’s codeKey
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Mar 7, 2024
1 parent 9753b63 commit 25e5f5d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/elements/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ public function afterSave(bool $isNew)
$codeRecord->lineItemId = $this->lineItemId;
$codeRecord->orderId = $this->orderId;
$codeRecord->voucherId = $this->voucherId;
$codeRecord->codeKey = $this->generateCodeKey();

// Generate a code key if not already set
$codeRecord->codeKey = $this->codeKey ?? $this->generateCodeKey();

// set the codeKey to the Code as well to use it directly
$this->codeKey = $codeRecord->codeKey;
}
Expand Down

0 comments on commit 25e5f5d

Please sign in to comment.