Preorderline documentation1.x
Developers

Filters and hooks

React to pre-orders being placed and released, or extend Preorderline with modes, settings and payment handling from code.

Preorderline's hooks are WordPress actions and filters. Put the examples in a small custom plugin or your child theme's functions.php. Preorderline Pro is built on the same hooks.

Data

Where Key Value
Product or variation meta _preorderline_mode launch, off (a variation only), an add-on's mode, or empty
_preorderline_date Local date and time, Y-m-d\TH:i, or empty
_preorderline_message The product's own availability text
Order item meta _preorderline_date Release timestamp (0 without a date). Marks the line as a pre-order
_preorderline_released When the line was released
Order meta _preorderline_charge upfront (Preorderline Pro also uses release and deposit)
_preorderline_released When the order was released
Order status wc-pre-ordered

Extendiment\Preorderline\Preorder and Extendiment\Preorderline\Orders read them for you, for example Preorder::is_active( $product ), Preorder::date( $product ) and Orders::waiting_items( $order ).

Actions

preorderline_order_preordered

An order entered the Pre-ordered status. Gets the order and its previous status.

add_action( 'preorderline_order_preordered', function ( $order, $from ) {
	// e.g. tag the customer in your mailing list.
}, 10, 2 );

preorderline_order_released

An order's pre-orders were released and it moved on. Gets the order, the ID of the Preorderline email that's sent (preorderline_customer_released for a paid order, empty when Preorderline has none for it) and details for the email.

add_action( 'preorderline_order_released', function ( $order, $email, $data ) {
	error_log( 'Pre-order released: #' . $order->get_order_number() );
}, 10, 3 );

preorderline_product_released

A product's (or a variation's) pre-orders were released. Gets its ID and the number of orders that moved on.

preorderline_loaded

Fires once Preorderline has loaded (on plugins_loaded, only when WooCommerce is active). Hook an add-on's setup to it. PREORDERLINE_VERSION is defined from then on.

Filters for add-ons

Filter Use it to
preorderline_modes Add a pre-order mode (key => label). Stored as _preorderline_mode.
preorderline_is_active Say whether a product in your mode takes pre-orders right now ($active, $product, $mode).
preorderline_settings Add WooCommerce settings fields to Settings → Products → Pre-orders, before the texts.
preorderline_product_fields (action) Print fields in the Pre-order tab, after the release date ($product).
preorderline_variation_fields (action) Print fields in a variation's Pre-order fields ($loop, $variation, $parent).
preorderline_save_product (action) Save your fields ($product, $row; $row is null for a product). ProductTab::posted( $field, $row ) reads a posted value.
preorderline_cart_item_rows Add rows under a pre-ordered cart item ($rows, $cart_item, $product; each row a key and value).
preorderline_order_item_rows Add rows under a waiting order line ($rows, $item, $order).
preorderline_payment_text What customers are told about paying, in their order notice and the Pre-order received email ($text, $order).
preorderline_customer_notice The notice above the order details ($message, $order; HTML).
preorderline_payment_label The payment part of a Packboard card, e.g. "Paid" ($label, $order).
preorderline_list_columns / preorderline_list_column Add columns to WooCommerce → Pre-orders, and fill or change cells ($html, $column, $product).
preorderline_handles_payment Return true when your add-on takes the payment of orders paid on release or with a deposit ($handled, $order, $kind).
preorderline_release_order Take over how a released order moves on, once per order ($result, $order; return handled true when you moved it on and emailed the customer, or add data for the email).

Example: a different button text for one category

add_filter( 'woocommerce_product_single_add_to_cart_text', function ( $text, $product ) {
	$id = $product->get_parent_id() ?: $product->get_id();
	if ( Extendiment\Preorderline\Preorder::is_active( $product ) && has_term( 'books', 'product_cat', $id ) ) {
		return 'Reserve your copy';
	}
	return $text;
}, 30, 2 );

Run it after priority 20, where Preorderline sets its own button text.