Skip to content

Commit

Permalink
Update conditional restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
martynmjones committed Sep 20, 2024
1 parent 37edb29 commit 3c5007c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/Admin/Product/Attributes/Input/GTINInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@ public function __construct() {
}

/**
* If Google for WooCommerce was installed after $this->disabled_from then
* this field will be disabled and not added to the product form.
*
* If Google for WooCommerce was installed before $this->disabled_from and
* WooCommerce version 9.2 or higher is installed then it will be readonly
* If WooCommerce >= 9.2 is installed then the field will be:
* - Disabled if GLA was installed after this feature was added
* - Readonly if GLA was installed before this feature was added
*
* @since x.x.x
* @return void
*/
public function conditionally_restrict(): void {
if ( $this->gla_installed_after( $this->disabled_from ) ) {
$this->set_disabled( true );
return;
}

if ( version_compare( WC_VERSION, '9.2', '>=' ) ) {
if ( $this->gla_installed_after( $this->disabled_from ) ) {
$this->set_disabled( true );
return;
}

$this->set_readonly( true );
$this->set_description( __( 'The Global Trade Item Number (GTIN) for your item can now be entered on the "Inventory" tab', 'google-listings-and-ads' ) );
}
Expand Down

0 comments on commit 3c5007c

Please sign in to comment.