Skip to content
Docs
Get RestroPress

Filter

rpress_payment_meta_cart_details

Updated
On this page

Filters the cart details array returned for a payment.

Runs at the end of rpress_get_payment_meta_cart_details(), after each cart line has been given the payment's currency and a subtotal (older orders lacked one). Each entry describes one cart line, including 'id', 'name', 'quantity', 'price', 'subtotal' and 'tax'. Bundled products are appended when the function is called with its $include_bundle_files argument set to true.

Parameters#

ParameterTypeDescription
$cart_detailsarrayList of cart line arrays for the payment.
$payment_idintThe payment (order) ID.

Return value#

array. The cart details.

Example#

add_filter( 'rpress_payment_meta_cart_details', 'my_flag_free_cart_lines', 10, 2 );
function my_flag_free_cart_lines( $cart_details, $payment_id ) {
	foreach ( (array) $cart_details as $key => $line ) {
		$cart_details[ $key ]['is_free'] = empty( $line['price'] );
	}
	return $cart_details;
}

Source#

Applied in:

  • includes/payments/functions.php (line 1293), in rpress_get_payment_meta_cart_details()

See also#

Was this page helpful?