Filter hooks

Developers can customise the behaviour of the order form through filter hooks. There are many useful filter hooks supported by this plugin, and by WooCommerce itself.

Here’s some example code that uses these filter hooks:

  • orderform_woocommerce_adjust_product_price

    • string $price — the displayed product price
    • int $product_id — the product ID
    • return: string

    Change the product price (e.g. for custom discounting).

  • orderform_woocommerce_classes

    • array $classes — an array of CSS class names
    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: array

    Change the CSS classes applied to the order form table.

  • orderform_woocommerce_empty_order_message

    • string $message — “Please select an item from the form”
    • return: string

    Change the error message shown when an order is submitted without any products.

  • orderform_woocommerce_form_attrs

    • array $attrs — the shortcode attributes for the order form
    • return: array

    Modify the attributes passed to the shortcode.

  • orderform_woocommerce_form_redirect

    • string $redirect_url
    • string $submitredirect
    • return: string

    Change the page that shows after submitting an order form.

  • orderform_woocommerce_item_variation_choose

    • string $label — the label for the empty select option
    • string $attr_name — the name of the variation attribute
    • WC_Product $product — the WooCommerce product
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the label on the empty select option for a variation select element.

  • orderform_woocommerce_order_form

    • string $html — the HTML content of the order form, including the wrapper div and form element
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the HTML for the order form.

  • orderform_woocommerce_out_of_stock_msg

    • string $msg — the Out of Stock message
    • WC_Product $product — the WooCommerce product
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the out of stock message for a product.

  • orderform_woocommerce_product_category_list

    • string $categories — the list of categories for the product
    • WC_Product $product — the WooCommerce product
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the list of categories for a product when collating products into categories for the order-form-by-category template.

  • orderform_woocommerce_product_category_list_separator

    • string $separator — defaults to “, “
    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the product category separator (normally a comma and space, “, “) when collating products into categories for the order-form-by-category template.

  • orderform_woocommerce_product_group_list_separator

    • string $separator — defaults to “, ”
    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the product group separator (normally a comma and space, “, ”) when collating products into categories for the order-form-by-category template.

  • orderform_woocommerce_product_is_variable

    • bool $is_variable
    • WC_Product $product
    • return: bool

    Change whether a product is treated as a variable product or a simple product.

  • orderform_woocommerce_product_row_template

    • string $template_name — the name of the product row template
    • WC_Product $product — the WooCommerce product
    • array $attrs — the shortcode attributes for the order form
    • return: string

    Change the product row template that will be used to display a product in the order form.

  • orderform_woocommerce_products

    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: array

    Change the products selected for an order form.

  • orderform_woocommerce_products_by_category

    • array $categories — a hierarchical array of categories and associated products
    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: array

    Customise the categories and products selected for an order form.

  • orderform_woocommerce_products_grouped

    • array $groups — a hierarchical array of categories and associated products
    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: array

    Customise the groups and products selected for an order form.

  • orderform_woocommerce_responsive_css

    • bool $enabled — whether to enable the responsive CSS for this order form
    • array $products — the WooCommerce products in the order form
    • array $attrs — the shortcode attributes for the order form
    • return: bool

    Enable or disable responsive CSS on an order form.

  • orderform_woocommerce_responsive_width

    • string $width — a valid CSS width value, e.g. “770px”
    • return: string

    Change the width at which responsive CSS activates.

  • orderform_woocommerce_responsive_width_buttons_desktop

    • string $width — a valid CSS width value, e.g. “1200px”
    • return: string

    Change the minimum breakpoint for grid buttons CSS on desktop displays.

  • orderform_woocommerce_responsive_width_buttons_mobile

    • string $width — a valid CSS width value, e.g. “1199px”
    • return: string

    Change the maximum breakpoint for grid buttons CSS on mobile displays.

  • orderform_woocommerce_responsive_width_grid_desktop

    • string $width — a valid CSS width value, e.g. “900px”
    • return: string

    Change the minimum breakpoint for responsive CSS grids on desktop.

  • orderform_woocommerce_responsive_width_grid_mobile

    • string $width — a valid CSS width value, e.g. “899px”
    • return: string

    Change the maximum breakpoint for responsive CSS grids on mobile.

  • orderform_woocommerce_shop_thumbnail

    • string $thumbnail_size — the registered image size for thumbnail in the order form; defaults to ‘woocommerce_gallery_thumbnail’

    Change the image size used to show product thumbnails in order forms