xlplugins
9/25/2017 - 11:41 AM

Navigate to thank You page based on order item meta

Navigate to thank You page based on order item meta

<?php
add_filter( 'xlwcty_after_rules', 'xlwcty_filter_for_meta', 10, 3 );

function xlwcty_filter_for_meta( $bool, $page_id, $order_id ) {


	if ( false === $bool || empty( $page_id ) ) {
		return $bool;
	}
 
	if ( 'YOUR_PAGE_ID' != $page_id ) { //REPLACE YOUR_PAGE_ID with the ID you want to navigate page to
		return $bool;
	}

	$is_quote  = false;
	$get_order = XLWCTY_Core()->data->get_order();

	$items = $get_order->get_items();

	foreach ( $items as $item ) {

		if ( $item instanceof WC_Order_Item_Product ) {
			if ( 'yes' == $item->get_meta( 'request_a_quote' ) ) {  // modify meta key and the value here to perform your custom key value check 
				$is_quote = true;
				break;
			}
		}
	}

	return $is_quote;

}