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 name | Description |
---|---|
dws_qrwc_di_container | Returns the dependency injection container instance. |
dws_qrwc_instance | Returns the plugin’s main class instance from the DI container. |
dws_qrwc_component | Returns a given plugin component from the DI container by its ID. |
dws_qrwc_get_raw_setting | Returns the raw database value of a given setting. |
dws_qrwc_get_validated_setting | Returns the validated database value of a given setting. |
dws_qrwc_get_raw_requests_product_setting | Returns the raw database value of a given product-level setting. |
dws_qrwc_get_validated_requests_product_setting | Returns the validated database value of a given product-level setting. |
dws_qrwc_get_merged_validated_requests_setting | Returns a given setting’s validated value by taking into account both the global setting and the product-level setting. |
Function name | Description |
---|---|
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_product | Returns the supported product types for customer requests. |
dws_qrwc_is_valid_request_product | Returns whether a given product can be added to customer quote requests or not. |
dws_qrwc_is_valid_request_customer | Returns whether a given customer can submit quote requests or not. |
dws_qrwc_can_add_product_to_request_list | Returns 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_items | Returns whether the cart is currently being used as a quote request list or not. |
dws_qrwc_is_quote | Returns whether a given post ID belongs to a quote object. |
dws_qrwc_create_quote | Programmatically creates a new quote request. |
dws_qrwc_create_order_from_quote | Programmatically 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 name | Description |
---|---|
dws_qrwc_get_hook_tag | Returns a plugin-level hook. |
dws_qrwc_get_component_hook_tag | Returns a component-level hook. |
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)