Hooks and functions reference

While we have tried our best to make the plugin support as many use-cases and 3rd-party plugins out-of-the-box, there’s always something that we can’t foresee. That’s why Quote Requests for WooCommerce provides a myriad of functions and hooks for easy extensibility.

Functions

All functions are located in the functions.php file and the files loaded by it. You can check their parameters and return values in said locations. The components IDs can be found in the config_prod.php and config-premium_prod.php files.

Function nameDescription
dws_qrwc_di_containerReturns the dependency injection container instance.
dws_qrwc_instanceReturns the plugin’s main class instance from the DI container.
dws_qrwc_componentReturns a given plugin component from the DI container by its ID.
dws_qrwc_get_raw_settingReturns the raw database value of a given setting.
dws_qrwc_get_validated_settingReturns the validated database value of a given setting.
dws_qrwc_get_raw_requests_product_settingReturns the raw database value of a given product-level setting.
dws_qrwc_get_validated_requests_product_settingReturns the validated database value of a given product-level setting.
dws_qrwc_get_merged_validated_requests_settingReturns a given setting’s validated value by taking into account both the global setting and the product-level setting.
Function nameDescription
dws_qrwc_get_quote_tracking_page Returns the WP_Post object of the page configured in the settings to be the quote tracking page.
dws_qrwc_are_requests_enabled Returns whether customer requests are enabled or not.
dws_qrwc_is_supported_request_productReturns the supported product types for customer requests.
dws_qrwc_is_valid_request_productReturns whether a given product can be added to customer quote requests or not.
dws_qrwc_is_valid_request_customerReturns whether a given customer can submit quote requests or not.
dws_qrwc_can_add_product_to_request_listReturns whether a given product can be added to customer quote requests or not at the current time (checks for stock levels).
dws_qrwc_wc_cart_has_quote_request_itemsReturns whether the cart is currently being used as a quote request list or not.
dws_qrwc_is_quoteReturns whether a given post ID belongs to a quote object.
dws_qrwc_create_quoteProgrammatically creates a new quote request.
dws_qrwc_create_order_from_quoteProgrammatically creates an order from the data stored in a quote request.

Hooks

All hook tags are computationally generated to ensure uniqueness. It is possible to reverse-engineer the end-result, but it is recommended to just use the same helpers in order to ensure future-compatibility.

There are 2 helper functions to help you generate our hooks:

Function nameDescription
dws_qrwc_get_hook_tagReturns a plugin-level hook.
dws_qrwc_get_component_hook_tagReturns a component-level hook.

It’s recommended to use the action dws_qrwc_initialized to register your hooks. It’s guaranteed that the functions above will be present and work on this action.

Filter whether a product is valid for quote requests

add_action( 'dws_qrwc_initialized', function() {
    add_filter(
        dws_qrwc_get_hook_tag( 'customer_request', 'is_valid_product' ),
        function( bool $is_valid, int $product_id ): bool {
            return $is_valid;
        },
        10,
        2
    );
} );Code language: PHP (php)

Filter whether a customer is valid for quote requests

add_action( 'dws_qrwc_initialized', function() {
    add_filter(
        dws_qrwc_get_hook_tag( 'customer_request', 'is_valid_customer' ),
        function( bool $is_valid, int $user_id, ?int $product_id = null ): bool {
            return $is_valid;
        },
        10,
        3
    );
} );Code language: PHP (php)
Updated on December 3, 2021

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
CONTACT SUPPORT