Rental Products has filters, actions, functions, shortcodes and a block for customizing how rentals are priced, displayed and checked. This page lists the public ones. Add code with a code snippets plugin or a custom plugin, and test it on a staging site first; see safely adding custom code to your WooCommerce store. If you have questions about these resources, contact support.
Some hooks only run in one handler mode. New installs use the modern handlers; stores that upgraded from a version before 7.0 may be in legacy mode (check which). Hooks marked "legacy mode only" don’t run with the modern handlers.
Filters
All filters are prefixed wcrp_rental_products_.
Pricing
| Filter | Description |
|---|---|
wcrp_rental_products_advanced_pricing | Changes the rental total. Runs only for products with Advanced pricing on. See seasonal and per-night pricing. |
wcrp_rental_products_cart_item_price | The rental cart item price. |
wcrp_rental_products_default_rental_options | The defaults used when a product’s rental option is empty. Filtering it isn’t recommended, because changed defaults can cause product data issues. |
wcrp_rental_products_multiply_addons_total_by_number_of_days_selected_flat_fees | Whether flat fee add-ons are multiplied by the number of rental days, when the product’s Multiply add-ons total by number of days selected is on. Default true. |
wcrp_rental_products_multiply_addons_total_by_number_of_days_selected_percentage_based | Whether percentage-based add-ons are multiplied by the number of rental days too. Default false. |
Cart and orders
| Filter | Description |
|---|---|
wcrp_rental_products_cart_group_rentals | Return true to sort rental items in the cart by start date, grouping rentals with the same dates. Default false. |
wcrp_rental_products_reserve_stock_for_unpaid_orders | Return false to reserve rental stock only once an order is paid. See reserve stock only when orders are paid. |
wcrp_rental_products_order_add_rental_products_url | The address the Add rental product(s) button opens on the order screen. Legacy mode only. |
Security deposits
| Filter | Description |
|---|---|
wcrp_rental_products_cart_fees_disable_security_deposits | Return true to skip security deposits for a cart, for example for certain customers or cart contents. Receives the cart. |
wcrp_rental_products_include_security_deposits_for_bundled_items | Return true to also charge the deposits of products inside a rental bundle. By default only the bundle’s own deposit is charged. |
Dates and calendars
| Filter | Description |
|---|---|
wcrp_rental_products_rental_date_format | A date format for rentals, instead of the WordPress date format. |
wcrp_rental_products_rental_time_format | A time format for rentals, instead of the WordPress time format. |
wcrp_rental_products_rental_form_first_day | The rental form calendar’s first day of the week, instead of the WordPress Week Starts On setting. |
wcrp_rental_products_rentals_dashboard_calendar_first_day | The Rentals » Calendar first day of the week, instead of the WordPress setting. |
wcrp_rental_products_litepicker_language | The language code for the rental form and availability checker calendars. Defaults to the WordPress language. |
wcrp_rental_products_rentals_dashboard_calendar_event_name | The event titles on Rentals » Calendar, also used in the calendar feed. Receives the name, the event data, whether it’s public (the feed) and the calendar mode. Leave out identifying information when the event is public. |
wcrp_rental_products_calendar_feed_simple_event_time_override | A time, such as 09:00, for calendar feed events in simple mode, which otherwise have no time and sit at the top of the day. |
Rental form and product display
| Filter | Description |
|---|---|
wcrp_rental_products_rental_form_after_quantity_enabled_hook_priority | The hook priority of the rental form when Position is After the product quantity field. See rental form position. |
wcrp_rental_products_rental_form_after_quantity_disabled_hook_priority | The hook priority of the rental form when Position is Before the product quantity field. |
wcrp_rental_products_rental_form_total_prefix | The text before the total in the rental form. |
wcrp_rental_products_rental_form_total_days_parenthesis | Whether the total days in the rental form are shown in parentheses. |
wcrp_rental_products_rental_form_total_days_as_weeks | Return true to show the rental form’s total days as weeks. Legacy mode only. |
wcrp_rental_products_rental_price_html | The rental price HTML on shop and product pages. |
wcrp_rental_products_rental_price_display_prefix | The Price prefix setting. |
wcrp_rental_products_rental_price_display_suffix | The Price suffix setting. |
wcrp_rental_products_rental_information_title | The rental information tab’s Title setting. |
wcrp_rental_products_select_dates_button_html | The Select dates button HTML on shop pages. |
Labels
Each label on the Rentals » Settings » Labels tab has a filter named after it: wcrp_rental_products_text_ plus the label’s name in lowercase with underscores. For example, wcrp_rental_products_text_rent_from filters Rent from, wcrp_rental_products_text_security_deposit filters Security deposit and wcrp_rental_products_text_part_of_bundle filters Part of bundle. Each receives the text from the settings.
Actions
| Action | Description |
|---|---|
wcrp_rental_products_rental_form_after_rental_totals | Fires in the rental form after the total price line, before the in-person and return notices. Modern handlers only. |
Functions
These functions are kept for compatibility and are available in both modes.
| Function | Returns |
|---|---|
wcrp_rental_products_advanced_configuration() | Array of the values set in the Advanced configuration setting |
wcrp_rental_products_availability_checker_data() | Array of the dates and quantity the customer selected in the availability checker |
wcrp_rental_products_check_availability() | Availability status string |
wcrp_rental_products_default_rental_options() | Array of the default rental options |
wcrp_rental_products_is_rental_only() | True or false |
wcrp_rental_products_is_rental_purchase() | True or false |
wcrp_rental_products_order_has_rentals() | True or false |
wcrp_rental_products_rental_date_format() | Rental date format string |
wcrp_rental_products_rental_form_date_format() | Rental form date format string |
wcrp_rental_products_rental_form_first_day() | First day of the week set for the rental form |
wcrp_rental_products_rental_form_maximum_date() | The maximum date, or number of days, the rental form allows |
wcrp_rental_products_rental_time_format() | Rental time format string |
JavaScript events
| Event | Description |
|---|---|
wcrp_rental_products_product_rental_form_update | Fires when the rental form updates on the product page. Legacy mode only. |
Shortcodes and block
[wcrp_rental_products_availability_checker]: the availability checker. The Availability Checker block (wcrp-rental-products/availability-checker, in the Rental Products block category) does the same.[wcrp_rental_products_rental_purchase_toggle]: the rental or purchase toggle, for product templates where it doesn’t show automatically. See rental or purchase toggle.
Rental Products has no REST API endpoints or WP-CLI commands.
Seasonal and per-night pricing
The wcrp_rental_products_advanced_pricing filter lets you change a rental’s total, for example by the dates chosen. It runs only for products whose Advanced pricing option is On, or set to Use default from rental settings while the store default under Rentals » Settings » Advanced is on. With advanced pricing on, customers can’t change that item’s quantity in the cart, and the price shown near the product title doesn’t reflect your code.
The filter receives:
$total: the calculated total for the quantity (price × quantity), after any total override and pricing tier.$data: an array includingrent_fromandrent_to(dates asYYYY-MM-DD),quantity,product_id,variation_id(for variations),return_days_threshold, and the product page’s query parameters prefixed_GET_.
Return the new total for the quantity.
Rental Products counts calendar days, so Monday to Thursday is four days. To charge per night instead (three nights for Monday to Thursday) on a product priced per day, scale the total by nights over days:
add_filter( 'wcrp_rental_products_advanced_pricing', function( $total, $data ) {
$days = (int) round( ( strtotime( $data['rent_to'] ) - strtotime( $data['rent_from'] ) ) / DAY_IN_SECONDS ) + 1;
if ( $days > 1 ) {
$total = $total / $days * ( $days - 1 );
}
return $total;
}, 10, 2 );
This assumes a Period product with a 1-day pricing period and no pricing tiers or total overrides. The calendar still shows calendar days.
Reserve stock only when orders are paid
By default, an order reserves its rental stock as soon as it’s placed, whatever its payment status. To reserve stock only once an order reaches a paid status, add:
/**
* Reserve rental stock only when orders are paid.
* Unpaid orders won't block availability for other customers.
*
* @link https://kestrelwp.com/docs/how-rental-availability-works/#reserve-stock-only-when-orders-are-paid
*/
add_filter( 'wcrp_rental_products_reserve_stock_for_unpaid_orders', '__return_false' );
What changes for your orders, the admin and customers is explained in how rental availability works. Read it before you add the snippet.
Rental form position
The rental form is added to product pages with WooCommerce hooks, depending on the Position setting:
- After the product quantity field:
woocommerce_after_add_to_cart_quantity, priority 10. - Before the product quantity field:
woocommerce_before_add_to_cart_button, priority 9. It uses this hook, notwoocommerce_before_add_to_cart_quantity, so it sits before WooCommerce Product Add-Ons fields, which use the same hook at priority 10.
To move the form among other elements on those hooks, change its priority with the two hook priority filters above. Fields from other plugins, such as a variable product’s options or Product Add-Ons fields, are positioned by those plugins.
Rental product pages get body classes you can target with CSS: wcrp-rental-products-is-rental on every rental product, plus -is-rental-only, -is-rental-purchase, -is-rental-purchase-rental, -is-rental-purchase-purchase and -is-rental-bundle (each prefixed wcrp-rental-products).
Cookies
The availability checker sets three cookies, for 30 days, to remember a customer’s choices. Include them in your cookie policy.
| Cookie | Stores |
|---|---|
wcrp_rental_products_availability_checker_rent_from | The start date selected |
wcrp_rental_products_availability_checker_rent_to | The end date selected |
wcrp_rental_products_availability_checker_quantity | The quantity selected |
Advanced configuration
Rentals » Settings » Advanced » Performance & debugging has an Advanced configuration field for diagnostic options. Only fill it in when Rental Products support gives you a value to use, and remove it when you’re done. wcrp_rental_products_advanced_configuration() returns what’s set.
Retired with the modern handlers
These hooks are only read in legacy mode. With the modern handlers they have no effect:
wcrp_rental_products_in_person_pick_up_return_same_day_overlaps. Same-day in-person handovers for rentals longer than a day are always allowed.- The filters that changed which page elements the legacy rental form reads (the add to cart button and product and variation ID inputs). The modern rental form reads the product from the form itself.
wcrp_rental_products_order_add_rental_products_url,wcrp_rental_products_rental_form_total_days_as_weeksand the JavaScript eventwcrp_rental_products_product_rental_form_update, as marked above.
