-
Notifications
You must be signed in to change notification settings - Fork 842
Instant Search: Add option to show or hidden product prices in results #46454
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
base: trunk
Are you sure you want to change the base?
Conversation
These changes add a new toggle to the Jetpack Search Customizer screen. This new toggle, "Show price', allows the product price to be hidden when Jetpack Instant Search is configured with the "Product (for WooCommerce Stores)" result format. This is necessary to hide prices for users in countries where prices must be shown with VAT integrated into them. At present, Instant Search does not have the ability to show prices with VAT in Instant Search results.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 4 files.
Full summary · PHP report · JS report Coverage check overridden by
Coverage tests to be added 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.
Pull request overview
This PR adds a new "Show price" toggle to Jetpack Instant Search, allowing WooCommerce store owners to hide product prices from search results. This is particularly useful for stores in regions where VAT must be incorporated into displayed prices, which isn't currently supported by Instant Search.
Key Changes
- Adds a new
jetpack_search_show_product_pricesetting with a default value of enabled (true) - Conditionally renders the ProductPrice component in search results based on the new setting
- Provides UI controls in both WordPress Customizer and Customberg sidebar for toggling price visibility
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
projects/packages/search/src/instant-search/lib/customize.js |
Maps the new setting to JavaScript state for customizer integration |
projects/packages/search/src/instant-search/components/search-results.jsx |
Passes the showProductPrice prop to search result components |
projects/packages/search/src/instant-search/components/search-result-product.jsx |
Conditionally renders ProductPrice component based on the new prop |
projects/packages/search/src/instant-search/components/search-app.jsx |
Passes the enableProductPrice state to the overlay SearchResults |
projects/packages/search/src/customizer/class-customizer.php |
Registers the customizer control for the "Show price" toggle |
projects/packages/search/src/customberg/hooks/use-search-options.js |
Adds entity prop hooks for reading/writing the productPrice setting |
projects/packages/search/src/customberg/components/sidebar/sidebar-options.jsx |
Adds UI toggle control, conditionally shown only for product format |
projects/packages/search/src/customberg/components/app-wrapper/index.jsx |
Maps productPrice option to overlay state for preview |
projects/packages/search/src/class-settings.php |
Registers the new setting with REST API support |
projects/packages/search/src/class-helper.php |
Includes enableProductPrice in initial JavaScript state generation |
projects/packages/search/changelog/enhance-allow-hiding-price |
Documents the new feature as a minor enhancement |
| array( $setting_prefix . 'inf_scroll', 'boolean', true ), | ||
| array( $setting_prefix . 'filtering_opens_overlay', 'boolean', true ), | ||
| array( $setting_prefix . 'show_post_date', 'boolean', true ), | ||
| array( $setting_prefix . 'show_product_price', 'boolean', true ), |
Copilot
AI
Jan 6, 2026
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.
As noted in the class documentation above (lines 18-19), this new setting must be added to the Jetpack sync configuration and whitelisted on WPCOM. Ensure that jetpack_search_show_product_price is added to Automattic\Jetpack\Sync\Modules\Search::$options_to_sync and is properly whitelisted and sanitized on WPCOM as mentioned in reference PCYsg-sBM-p2.
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'm not sure on this, as filtering_opens_overlay and show_post_date are not included in the sync array. I've followed the pattern for show_post_date and as it wasn't included, I haven't included this either. If this is an oversight between the two locations this PR should be fine to address that.
| private static $options_to_sync = array( |
| $wp_customize->add_control( | ||
| $id, | ||
| array( | ||
| 'type' => 'checkbox', | ||
| 'section' => $section_id, | ||
| 'label' => __( 'Show price', 'jetpack-search-pkg' ), | ||
| ) | ||
| ); |
Copilot
AI
Jan 6, 2026
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.
The "Show price" control is always visible in the WordPress Customizer regardless of the selected result format, but it only has an effect when the result format is set to "Product". Consider adding an active_callback to the control configuration to conditionally show this control only when the result format is "product", similar to how it's conditionally shown in the Customberg sidebar (sidebar-options.jsx lines 157-166). This would improve the user experience by avoiding confusion about when this setting applies.
Note: The existing "Show post date" control (lines 285-303) has the same pattern where it's always visible but only relevant for the "expanded" format, so this is consistent with the current codebase. However, adding conditional visibility for both controls would be a worthwhile improvement.
Fixes SEARCH-112
Proposed changes:
This PR adds a new
Show pricestoggle alongside the existing Customize Jetpack Search options, which only shows when the Instant Search "Result Format" is set to "Product".This option is needed for stores based in countries where VAT must be incorporated into display prices. As this is not possible with Instant Search at present, adding an option to hide the price from results is a necessary compromise.
New Option
Prices enabled
Prices disabled
Other information:
Jetpack product discussion
No
Does this pull request change what data or activity we track or use?
No
Testing instructions:
/wp-admin/admin.php?page=jetpack-search-configure.Show Pricesoption.