-
Notifications
You must be signed in to change notification settings - Fork 217
Allow purchase of free trials with ECE #4557
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8467c25
Allow purchase of free trials with ECE
wjrosa c17d9de
Changelog and readme entries
wjrosa 33e176c
Unit tests
wjrosa 1e638dc
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa 63d45fd
Remove condition inside canMakePayment
wjrosa bfc3b1e
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa cdca351
Temporary changes to debug
wjrosa 79f7d4c
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa da2cd5c
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa 48ebe0d
Method to check for existing free trial in cart
wjrosa fa57d69
Adding the JS property to flag the free trial
wjrosa 1b99ba7
Checking for free trials to change the configuration mode parameter
wjrosa 2daf2b9
Remove debug code
wjrosa 9a71639
Revert unnecessary change
wjrosa c91368f
Revert unnecessary change
wjrosa 3dc3e41
Helper class for WC_Subscriptions_Product
wjrosa 41f23fc
Simplifying logic + unit test
wjrosa 2ad897b
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa ad40478
Fix payment method creation
wjrosa e6143d1
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa 0bd5184
Revert removal of free product check + adding the free trial check al…
wjrosa 80d57e3
Adding the free trial parameter to missing methods
wjrosa ea853ca
Fix shortcode checkout
wjrosa c9dd64e
Simplifying setting of mode parameter
wjrosa 66882bd
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa 886aa63
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa 0da2c62
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa 5ed09d9
Merge branch 'add/allow-ece-purchases-for-free-trials' of https://git…
wjrosa 618e9af
Merge branch 'develop' into add/allow-ece-purchases-for-free-trials
wjrosa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Subscription WC_Subscriptions_Product helper. | ||
*/ | ||
|
||
/** | ||
* Class WC_Subscriptions_Product. | ||
* | ||
* This helper class should ONLY be used for unit tests!. | ||
*/ | ||
class WC_Subscriptions_Product { | ||
/** | ||
* The mocked value for get_trial_length(). | ||
* | ||
* @var int | ||
*/ | ||
public static int $get_trial_length_result; | ||
|
||
/** | ||
* The mocked value for is_subscription(). | ||
* | ||
* @var bool | ||
*/ | ||
public static bool $is_subscription_result; | ||
|
||
/** | ||
* Get the length of the trial period for a subscription product. | ||
* | ||
* @return int | ||
*/ | ||
public static function get_trial_length(): int { | ||
return self::$get_trial_length_result; | ||
} | ||
|
||
/** | ||
* @param int $result The value to return from get_trial_length(). | ||
* @return void | ||
*/ | ||
public static function set_trial_length( int $result ): void { | ||
self::$get_trial_length_result = $result; | ||
} | ||
|
||
/** | ||
* Determine if a product is a subscription. | ||
* | ||
* @return bool | ||
*/ | ||
public static function is_subscription(): bool { | ||
return self::$is_subscription_result; | ||
} | ||
|
||
/** | ||
* Set the value to be returned from is_subscription(). | ||
* | ||
* @param bool $result The value to return from is_subscription(). | ||
* @return void | ||
*/ | ||
public static function set_is_subscription( bool $result ): void { | ||
self::$is_subscription_result = $result; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
QQ: why is it supported only for the products that do not require shipping? Is there any catch with the shippable products?
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.
I am honestly not sure. The original comment was included by you here. I just kept the limitation 😅 . However, maybe it is not needed at all (I can't imagine any reasons why it would be). Original code:
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.
Let me try to remember the reason 🤔
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.
Okay, so I don't exactly remember the reason but I remembered following what we have in WooPayments. I found this epic where item 3 says the expected behavior is ECE would be hidden. This epic was created later but there were something in WooPayments that I followed at that time 🤔
Not a blocker for this PR, but we should assess separately if support for shippable products should/can be added.
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.
Thanks for the additional context! Yeah, I think we can tackle this specific rule later. I created STRIPE-715 for that