Diesel Items
// Hook into WooCommerce checkout validation
add_action( 'woocommerce_checkout_process', 'validate_checkout_origin' );
function validate_checkout_origin() {
// Retrieve the origin attribute (replace with how you're storing or getting the 'origin')
$user_origin = ''; // For example, if it's stored in user meta, use get_user_meta()
if ( isset( $_SESSION['user_origin'] ) ) {
$user_origin = $_SESSION['user_origin'];
}
// If 'origin' is not set or is unknown, prevent checkout and show an error message
if ( empty( $user_origin ) || $user_origin == 'unknown' ) {
wc_add_notice( __( 'Your origin is unknown. You cannot proceed with the checkout at this time.', 'your-text-domain' ), 'error' );
}