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

Fire HPOS bulk action hook for all custom bulk actions #38747

Merged
merged 2 commits into from Jun 16, 2023
Merged

Conversation

jorgeatorres
Copy link
Member

@jorgeatorres jorgeatorres commented Jun 15, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

In HPOS, order bulk actions starting with mark_ (which include "Mark as Completed", "Mark as Cancelled", etc.) were being handled by our ListTable code internally, preventing 3rd parties from implementing similar actions as the bulk action hook wasn't being fired.

This PR makes it so any bulk action that isn't effectively handled by our own code can be implemented by the bulk action hook, even those starting with mark_ that don't correspond to a change to a known order status.

Closes #38558.

How to test the changes in this Pull Request:

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

With some copy/paste from the excellent instructions provided in #38558.

  1. Check out trunk.
  2. Enable HPOS by making sure that the "Enable the high performance order storage feature." is enabled in WC > Settings > Advanced > Features. Similarly, ensure that "Use the WooCommerce orders tables" is selected in WC > Settings > Advanced > Custom data stores.
  3. Create a custom plugin or snippet with the following code:
    add_filter( "bulk_actions-woocommerce_page_wc-orders", function($actions) {
        return array_merge( $actions, [ 'mark_as_exported' => __( 'Mark as exported' ) ] );
    } );
    
    add_action( "handle_bulk_actions-woocommerce_page_wc-orders", function($redirect_to, $action, $ids) {
        if ($action === 'mark_as_exported') {
            die( 'Handling mark as exported' ); // <-- this never happens
        }
    }, 10, 3 );
  4. Trigger the bulk action from the orders list table - select at least 1 order, then "Mark as exported" from bulk actions, and click Apply.
  5. Confirm that nothing happens.
  6. Check out this branch and repeat steps 2-4, but this time confirm that the custom hook is triggered and you see a "Handling mark as exported" on the screen.

…or all custom actions

Actions starting with “mark_” were silently handled by our own code, preventing 3rd parties from adding their own “mark_” bulk actions and acting on them.
@github-actions github-actions bot added focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jun 15, 2023
@jorgeatorres jorgeatorres marked this pull request as ready for review June 15, 2023 19:04
@jorgeatorres jorgeatorres added focus: custom order tables / HPOS Issues related to High-Performance Order Storage (HPOS) née Custom Order Tables. and removed focus: react admin [team:Ghidorah] labels Jun 15, 2023
@jorgeatorres jorgeatorres requested review from a team and barryhughes and removed request for a team June 15, 2023 19:07
@github-actions
Copy link
Contributor

Hi @barryhughes,

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

1 similar comment
@github-actions
Copy link
Contributor

Hi @barryhughes,

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

@github-actions
Copy link
Contributor

Test Results Summary

Commit SHA: ebd26bb

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 0s
E2E Tests1950010020513m 15s

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.

Copy link
Member

@barryhughes barryhughes left a comment

Choose a reason for hiding this comment

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

Nice change 👌🏼

@barryhughes barryhughes merged commit 409c36a into trunk Jun 16, 2023
21 checks passed
@barryhughes barryhughes deleted the fix/38558 branch June 16, 2023 18:35
@github-actions github-actions bot added this to the 7.9.0 milestone Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: custom order tables / HPOS Issues related to High-Performance Order Storage (HPOS) née Custom Order Tables. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[COT] custom bulk actions prefixed with mark_ are ignored
2 participants