Skip to content
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

Pass some context information to woocommerce_blocks_hook_compatibility_additional_data hook #45156

Conversation

kmanijak
Copy link
Contributor

@kmanijak kmanijak commented Feb 27, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #44447.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. In your theme's functions.php add a following code
function comp_layer_callback( $arr, $classname ) {
	echo $classname;
}

add_filter( 'woocommerce_blocks_hook_compatibility_additional_data', 'comp_layer_callback', 10, 3 );
  1. Go to Editor and Clear Customisations on templates:
  • Product Catalog
  • Single Product
  1. Visit each of them and make sure you use a blockified template. If it's a classic template, enter the efit mode and click "Transform into blocks"
  2. Save if necessary
  3. Go to frontend /shop
  4. Expected: You should see at the top of the pageArchiveProductTemplatesCompatibility (it can be repeated multiple times)
  5. Click one of the products
  6. Expected: You should see at the top of the pageSingleProductTemplateCompatibility (it can be repeated multiple times)

Example:
image

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

…additional_data hook which is a class name in which it was called
Copy link
Contributor

github-actions bot commented Feb 27, 2024

Hi @gigitux, @woocommerce/woo-fse

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

github-actions bot commented Feb 27, 2024

Test Results Summary

Commit SHA: 1964059

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests303004403477m 33s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@gigitux
Copy link
Contributor

gigitux commented Feb 27, 2024

Thanks, @kmanijak, for working on this!

While I may not be a PHP expert, I'd like to suggest considering the possibility of passing the entire instance of the class instead of just its name. This approach could offer developers greater flexibility and freedom in their implementations. Feel free to correct me if I'm mistaken, as my understanding of PHP might be limited.

@xristos3490
Copy link
Member

Hey folks! Just wanted to add my two cents to the discussion.

Personally, I think it's best to avoid passing the object itself unless it's necessary.

This is because it could potentially lead to issues with calling public methods on the same instance (e.g., the init() method.) If there are further requirements in the future, we could consider passing the object and reviewing its public schema for any potential regressions.

Copy link
Contributor

@gigitux gigitux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @xristos3490, for sharing your thoughts! LGTM!

@kmanijak kmanijak merged commit 382bcdf into trunk Feb 28, 2024
59 checks passed
@kmanijak kmanijak deleted the 44447-enhancement-please-improve-woocommerce_blocks_hook_compatibility_additional_data-filter-hook branch February 28, 2024 09:34
@github-actions github-actions bot added this to the 8.8.0 milestone Feb 28, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Feb 28, 2024
@alopezari alopezari added needs: internal testing Indicates if the PR requires further testing conducted by Solaris status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Feb 29, 2024
@kmanijak
Copy link
Contributor Author

kmanijak commented Mar 1, 2024

Hi @webmandesign, wanted to let you know this PR was merged and the change will be available in WooCommerce 8.8! Thanks for nice suggestion in #44447!

Konamiman pushed a commit that referenced this pull request Mar 13, 2024
…ty_additional_data` hook (#45156)

* Pass additional context to the woocommerce_blocks_hook_compatibility_additional_data hook which is a class name in which it was called

* Add changelog

* Lint fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: extensibility needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Kirigami & Origami
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Please improve woocommerce_blocks_hook_compatibility_additional_data filter hook
4 participants