As a site owner you may want to filter / prevent orders from 'Origin' = 'Unknown'.
To use this, you can use the following steps:
Please note: These are development-level steps and should be implemented by your site's developers.
1. Install a Custom Code Plugin:
2. Navigate to the WPCode settings page, and create a code snippet:
3. Name and Save the Snippet
4. Add the Following Code Snippet:
This code checks the order origin during the checkout process and prevents order placement if the origin is “Unknown.”
add_action('woocommerce_checkout_process', 'block_unknown_origin_orders');
function block_unknown_origin_orders() {
// Retrieve the referral source stored in WooCommerce's session or analytics data.
$origin = isset(WC()->session) ? WC()->session->get('wc_referral_source') : null;
// Check if origin is "Unknown" or not set.
if (empty($origin) || strtolower($origin) === 'unknown') {
// Add an error to stop the checkout process.
wc_add_notice(__('We are unable to process your order at this time. Please contact support if the issue persists.'), 'error');
}
}