-
-
Notifications
You must be signed in to change notification settings - Fork 75
fix(checkout): correct addon pricing to only charge for new products #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2f4fd11
2df3a37
355abea
284ccb0
80c52fe
1a73346
8aeb0e4
3a2b890
b8d9509
19ae2ff
6a39c7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -295,7 +295,7 @@ | |
| */ | ||
| public static function get_schema() { | ||
|
|
||
| $instance = new static(); | ||
|
|
||
| $query_class = new $instance->query_class(); | ||
|
|
||
|
|
@@ -333,7 +333,7 @@ | |
| return false; | ||
| } | ||
|
|
||
| $instance = new static(); | ||
|
|
||
| $query_class = new $instance->query_class(); | ||
|
|
||
|
|
@@ -351,7 +351,7 @@ | |
| */ | ||
| public static function get_by_hash($item_hash) { | ||
|
|
||
| $instance = new static(); | ||
|
|
||
| $item_id = Hash::decode($item_hash, sanitize_key((new \ReflectionClass(static::class))->getShortName())); | ||
|
|
||
|
|
@@ -371,7 +371,7 @@ | |
| */ | ||
| public static function get_by($column, $value) { | ||
|
|
||
| $instance = new static(); | ||
|
|
||
| $query_class = new $instance->query_class(); | ||
|
|
||
|
|
@@ -388,7 +388,7 @@ | |
| */ | ||
| public static function get_items($query) { | ||
|
|
||
| $instance = new static(); | ||
|
|
||
| return (new $instance->query_class($query))->query(); | ||
| } | ||
|
|
@@ -403,7 +403,7 @@ | |
| */ | ||
| public static function get_items_as_array($query = []) { | ||
|
|
||
| $instance = new static(); | ||
|
|
||
| $list = (new $instance->query_class($query))->query(); | ||
|
|
||
|
|
@@ -490,7 +490,13 @@ | |
| } | ||
|
|
||
| foreach ($validator->get_validation()->getValidData() as $key => $value) { | ||
| $this->{$key} = $value; | ||
| // Skip null values to avoid overwriting existing property values with null. | ||
| // The rakit/validation library may return null for fields on PHP 8.4+ due to | ||
| // implicit nullable parameter deprecations in Attribute::getValue(), which would | ||
| // incorrectly reset boolean/integer fields (e.g. apply_to_renewals) to null. | ||
| if (null !== $value) { | ||
| $this->{$key} = $value; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
|
|
@@ -531,7 +537,7 @@ | |
| * @param array $data_unserialized The object data that will be stored. | ||
| * @param Base_Model $this The object instance. | ||
| */ | ||
| $meta = apply_filters("wu_{$this->model}_meta_pre_save", $meta, $data_unserialized, $this); | ||
|
Check warning on line 540 in inc/models/class-base-model.php
|
||
|
|
||
| $blocked_attributes = [ | ||
| 'query_class', | ||
|
|
@@ -567,7 +573,7 @@ | |
| * @param array $data_unserialized The object data that will be stored. | ||
| * @param Base_Model $this The object instance. | ||
| */ | ||
| $data = apply_filters("wu_{$this->model}_pre_save", $data, $data_unserialized, $this); | ||
|
Check warning on line 576 in inc/models/class-base-model.php
|
||
|
|
||
| $is_valid_data = $this->validate(); | ||
|
|
||
|
|
@@ -610,7 +616,7 @@ | |
| * @param array $data_unserialized The object data that will be stored. | ||
| * @param Base_Model $this The object instance. | ||
| */ | ||
| do_action('wu_model_post_save', $this->model, $data, $data_unserialized, $this); | ||
|
Check warning on line 619 in inc/models/class-base-model.php
|
||
|
|
||
| /** | ||
| * Fires after an object is stored into the database. | ||
|
|
@@ -621,7 +627,7 @@ | |
| * @param Base_Model $this The object instance. | ||
| * @param bool $new True if the object is new. | ||
| */ | ||
| do_action("wu_{$this->model}_post_save", $data, $this, $new); | ||
|
Check warning on line 630 in inc/models/class-base-model.php
|
||
|
|
||
| return $saved; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t leave the membership amount stale on addon swaps.
This branch keeps
addon_productsin sync but leavesMembership::get_amount()at the pre-addon value.Membership::save()still callsprocess_membership_update()when products change, and that flow rebuilds the recurring subscription from membership state; becausewu_get_membership_new_cart()derives an adjustment from the stored amount, the new addon can be canceled back out on future renewals. Keep the billing period unchanged for addon carts, but still merge the addon’s recurring delta into the membership amount before saving.🤖 Prompt for AI Agents