Feature/daniele/checkout custom parameters#819
Conversation
6ab27a1 to
b394995
Compare
includes/class-freemius.php
Outdated
| protected $_checkout_config = []; | ||
|
|
||
| /** | ||
|
|
includes/class-freemius.php
Outdated
| * | ||
| * @return array | ||
| */ | ||
| protected function validate_checkout_config($config) |
There was a problem hiding this comment.
@DanieleAlessandra Missing spaces around $config.
includes/class-freemius.php
Outdated
|
|
||
| $result = array(); | ||
|
|
||
| foreach ($schema as $key => $expected_type) |
includes/class-freemius.php
Outdated
|
|
||
| foreach ($schema as $key => $expected_type) | ||
| { | ||
| if (array_key_exists($key, $config)) |
includes/class-freemius.php
Outdated
| switch ($type) | ||
| { | ||
| case 'bool': | ||
| if (is_bool($value)) |
includes/class-freemius.php
Outdated
| * @return array | ||
| */ | ||
| public function get_checkout_config() | ||
| { |
includes/class-freemius.php
Outdated
| // cart | ||
| 'always_show_renewals_amount' => 'bool', | ||
| 'annual_discount' => 'bool', | ||
| 'billing_cycle' => ['string', 'int'], |
There was a problem hiding this comment.
@DanieleAlessandra Please check this out:
https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#declaring-arrays
Long array syntax.
# Conflicts: # start.php
e760ad5 to
0ee6bea
Compare
Introduce a namespaced filter to let developers add/modify query params sent to Freemius Checkout. • Add fs_apply_filter( $fs->get_unique_affix(), 'checkout_query_params', ... )
0ee6bea to
c96efc6
Compare
Introduced the private $_allowed_custom_params property to define all supported custom query parameters for the checkout. After applying `fs_apply_filter()`, the function now filters `$filtered_params` using `array_intersect_key()` to remove any unsupported keys before merging. This prevents external filters from injecting unexpected parameters into the checkout query.
swashata
left a comment
There was a problem hiding this comment.
@DanieleAlessandra this is a very good approach, please see the small tweaks I suggested.
| ); | ||
|
|
||
| return array_merge( $context_params, $_GET, array( | ||
| /** |
There was a problem hiding this comment.
Remove this doc block please. See that it is already stale. Instead
- See the
start.phpand see we have list ofFreemius filters collection, just add the filter there. - Later we will update our docs https://freemius.com/help/documentation/wordpress-sdk/filters-actions-hooks/
| * @param int|mixed $plan_id The selected plan ID (if any). | ||
| * @param int|mixed $licenses The requested number of licenses (if provided). | ||
| */ | ||
| $filtered_params = fs_apply_filter( |
There was a problem hiding this comment.
Why not
$filtered_params = $fs->apply_filters('checkout_query_params', $context_params);
There was a problem hiding this comment.
@DanieleAlessandra let's call the filter
checkout/configuration
Following we already have this https://freemius.com/help/documentation/wordpress-sdk/filters-actions-hooks/#checkoutpurchasedcompleted
| 'show_refund_badge' => 'bool', | ||
| 'show_reviews' => 'bool', | ||
| 'show_upsells' => 'bool', | ||
| 'title' => 'string', |
There was a problem hiding this comment.
@DanieleAlessandra let's add the billing_cycle_selector in the list as well.
This PR introduces support for additional checkout configuration properties in the SDK initializer.
What’s new
The following properties are now recognized during initialization:
Behavior
• If these properties exist in the initialization config, they are validated and stored.
• When opening the checkout (both iframe and redirect modes), the provided values are automatically passed along to the checkout context.
This allows developers to customize the checkout flow appearance and cart behavior more flexibly directly from the SDK initialization.