Skip to content

Commit

Permalink
Merge branch 'WP-130' into 'main'
Browse files Browse the repository at this point in the history
fix: factory no recreate class object

See merge request ecommerce_modules/cms/wordpress/wordpress!55
  • Loading branch information
DEMAxx committed Dec 26, 2024
2 parents 08d26f5 + 2c7b18e commit eb8c819
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ShippingMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ShippingMethod extends WC_Shipping_Method
{
use SettingsFields;

private static ?ShippingMethod $instance = null;
private const DEFAULTS
= [
'automate_wait_gateways' => [],
Expand All @@ -85,6 +86,7 @@ public function __construct($instance_id = 0)
];
$this->enabled = 'yes';
$this->init();
static::$instance = $this;
}

final public function init(): void
Expand Down Expand Up @@ -114,7 +116,7 @@ public static function factory(?int $instanceId = null): self
}
}

return WC()->shipping()->load_shipping_methods()[Config::DELIVERY_NAME];
return static::$instance ?: WC()->shipping()->load_shipping_methods()[Config::DELIVERY_NAME];
}

/** @noinspection MissingReturnTypeInspection */
Expand Down

0 comments on commit eb8c819

Please sign in to comment.