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:
- restrict payment gateways for orders to the Cheque payment gateway
- redirect a form to a custom URL on submit
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