Set access modifier for $error_message to public and added a setter method (#46642)

* Set access modifier for $error_message to public and added a setter method.

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Paulo Arromba 2024-04-16 16:55:02 +01:00 committed by GitHub
parent e8a2c20914
commit 77f7b6162b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fixed a bug causing incompatibility with 3rd-party coupon extensions when certain conditions were met.

View File

@ -84,9 +84,14 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Error message.
*
* This property should not be considered public API, and should not be accessed directly.
* It is being added to supress PHP > 8.0 warnings against dynamic property creation, and all access
* should be through the getter and setter methods, namely `get_error_message()` and `set_error_message()`.
* In the future, the access modifier may be changed back to protected.
*
* @var string
*/
protected $error_message;
public $error_message;
/**
* Sorting.
@ -871,6 +876,17 @@ class WC_Coupon extends WC_Legacy_Coupon {
return $this->error_message;
}
/**
* Sets the error_message string.
*
* @param string $message Message string.
*
* @return void
*/
public function set_error_message( string $message ) {
$this->error_message = $message;
}
/**
* Check if a coupon is valid for the cart.
*