Skip to content

Conversation

@danielbitzer
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

The woocommerce_order_actions is used by a a bunch of plugins like WC Payments, Subscriptions, AutomateWoo and could be improved. Currently a global order object ($theorder) is commonly used to conditionally add items to the array depending on what type of order is being edited. Rather than use a global this should be a filter argument.

This PR adds an $order filter argument to the woocommerce_order_actions filter while maintaining backwards compatibility.

How to test the changes in this Pull Request:

  1. Test that order actions appear on the order edit admin screen

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Dev - Add order argument to "woocommerce_order_actions" filter

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@danielbitzer danielbitzer self-assigned this Aug 11, 2021
@vedanshujain vedanshujain requested review from a team and roykho and removed request for a team August 13, 2021 13:01
)
);
$theorder = $theorder instanceof WC_Order ? $theorder : null;
$order_actions = self::get_available_order_actions_for_order( $theorder );
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @danielbitzer - Thanks for the PR! So we're trying not to add any new methods unless it is absolutely necessary. And for those cases, we also utilize the internal src namespace to do so. That way it is not publicly exposed. But in this case, I don't think we need a new method for this. Perhaps just put the docblock above the filter for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HI @roykho! Would making the method private also be acceptable? That way it's not publicly exposed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok great, I've made that change.

@roykho
Copy link
Contributor

roykho commented Aug 26, 2021

@danielbitzer - thanks for the update. Can you please add the @since version in to 5.8.0 (two places). Thanks!

@danielbitzer
Copy link
Contributor Author

Can you please add the @since version in to 5.8.0 (two places). Thanks!

@roykho done!

Copy link
Contributor

@roykho roykho left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. LGTM!

@roykho roykho merged commit ad955c1 into trunk Aug 27, 2021
@roykho roykho deleted the move-order-actions-variable-to-filter-arg branch August 27, 2021 12:41
@github-actions github-actions bot added this to the 5.8.0 milestone Aug 27, 2021
@github-actions
Copy link
Contributor

Hi @roykho, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the status: needs changelog label
  • Add the status: needs testing instructions label

@roykho roykho added release: highlight Issues that have a high user impact and need to be discussed/paid attention to. release: add changelog Mark all PRs that have not had their changelog entries added. [auto] labels Aug 27, 2021
@zhongruige zhongruige added release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] testing instructions added and removed release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: highlight Issues that have a high user impact and need to be discussed/paid attention to.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants