{"id":15163,"date":"2024-10-30T10:07:52","date_gmt":"2024-10-30T17:07:52","guid":{"rendered":"https:\/\/codedcommerce.com\/?page_id=15163"},"modified":"2024-10-30T10:07:52","modified_gmt":"2024-10-30T17:07:52","slug":"checkout-block-custom-validation","status":"publish","type":"woo-code","link":"https:\/\/codedcommerce.com\/woo\/checkout-block-custom-validation\/","title":{"rendered":"Checkout Block custom validation"},"content":{"rendered":"\n<pre class=\"wp-block-code language-php\"><code>add_action( 'woocommerce_store_api_checkout_order_processed', function( $order ) {\n\n\t\/\/ Get Customer Note\n\t$note = $order->get_customer_note();\n\n\t\/\/ Skip If Empty\n\tif( ! $note ) {\n\t\treturn;\n\t}\n\n\t\/\/ Require Valid Email Address\n\tif( ! is_email( $note ) ) {\n\t\t$message = 'Valid email address must be provided in the order note field.';\n\t\t$order->update_status( 'failed', $message );\n\t\tthrow new Exception( $message );\n\t\treturn;\n\t}\n\n} );<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-15163","woo-code","type-woo-code","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/woo-code\/15163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/woo-code"}],"about":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/types\/woo-code"}],"wp:attachment":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/media?parent=15163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}