Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions src/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ public function get_settings( $tab ) {
'default' => 'no',
'type' => 'checkbox',
],
[
'title' => __( 'Disable encryption', 'wc-serial-numbers' ),
'id' => 'wc_serial_numbers_disable_encryption',
'desc' => __( 'Store serial keys in database as plaintext.', 'wc-serial-numbers' ),
'desc_tip' => __( 'If this options is enabled, keys will not be stored in encrypted form.', 'wc-serial-numbers' ),
'default' => 'no',
'type' => 'checkbox',
],
[
'type' => 'sectionend',
'id' => 'section_serial_numbers',
Expand Down
6 changes: 3 additions & 3 deletions src/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public function __construct() {
* @return false|string
*/
public static function maybeEncrypt( $key ) {
if ( ! self::isEncrypted( $key ) ) {
return self::encrypt( $key );
if(self::isEncrypted( $key ) || 'yes' == wc_serial_numbers_encryption_disabled()) {
return $key;
}

return $key;
return self::encrypt( $key );
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ protected function update_120() {
$options = [
'wc_serial_numbers_autocomplete_order' => $this->update_1_2_0_get_option( 'wsn_auto_complete_order', 'yes', 'wsn_delivery_settings' ),
'wc_serial_numbers_reuse_serial_number' => $this->update_1_2_0_get_option( 'wsn_re_use_serial', 'no', 'wsn_delivery_settings' ),
'wc_serial_numbers_disable_encryption' => 'no',
'wc_serial_numbers_disable_software_support' => 'no',
'wc_serial_numbers_manual_delivery' => 'no',
'wc_serial_numbers_hide_serial_number' => 'yes',
Expand Down
12 changes: 12 additions & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,18 @@ function wcsn_decrypt_key( $key ) {
return Encryption::maybeDecrypt( $key );
}

/**
* Check if encryption is disabled (i.e, for real physical product serial numbers)
*
* @param $product_id
*
* @return bool
* @since 1.x.x
*/
function wc_serial_numbers_encryption_disabled() {
return 'yes' == get_option( 'wc_serial_numbers_disable_encryption' );
}

/**
* Get product stocks
*
Expand Down