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

Add ModifyPurchasablesQueryEvent #3198

Merged
merged 6 commits into from
Jul 17, 2023
Merged

Conversation

nfourtythree
Copy link
Contributor

@nfourtythree nfourtythree commented Jun 16, 2023

Description

This event gives developers the opportunity to modify the query that is used when retrieving purchasables for the "add a line item" table on the order edit page.

Example usage:

use craft\commerce\controllers\OrdersController;
use craft\commerce\events\ModifyPurchasablesTableQueryEvent;
// ...
Event::on(
    OrdersController::class,
    OrdersController::EVENT_MODIFY_PURCHASABLES_TABLE_QUERY,
    function(ModifyPurchasablesTableQueryEvent $event) {
        $likeOperator = Craft::$app->getDb()->getIsPgsql() ? 'ILIKE' : 'LIKE';
        $event->query->andWhere([$likeOperator, 'sku', 'foo']);
    }
);

To Review

  • Event naming
  • Example in PHPdoc

Related issues

#3194

@nfourtythree nfourtythree self-assigned this Jun 16, 2023
@nfourtythree nfourtythree changed the title Add ModiftPurchasablesQueryEvent Add ModifyPurchasablesQueryEvent Jun 16, 2023
@nfourtythree nfourtythree marked this pull request as ready for review June 16, 2023 08:21
@nfourtythree nfourtythree requested a review from a team as a code owner June 16, 2023 08:21
@nfourtythree
Copy link
Contributor Author

Update event name to ModifyPurchasablesTableQueryEvent.

@lukeholder lukeholder merged commit a189f18 into 4.3 Jul 17, 2023
8 checks passed
@lukeholder lukeholder deleted the feature/purchasables-order-edit-event branch July 17, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants