{"id":2966,"date":"2025-08-18T07:54:10","date_gmt":"2025-08-18T04:54:10","guid":{"rendered":"https:\/\/jasonblackeye.com\/?p=2966"},"modified":"2026-02-19T19:32:32","modified_gmt":"2026-02-19T17:32:32","slug":"how-to-build-a-custom-woo-return-system-with-bricks-form-custom-fields-php","status":"publish","type":"post","link":"https:\/\/jasonblackeye.com\/el\/how-to-build-a-custom-woo-return-system-with-bricks-form-custom-fields-php\/","title":{"rendered":"How to Build a Custom Woo Return System with Bricks Form, Custom Fields &amp; PHP"},"content":{"rendered":"<p>Tired of handling customer return requests through email? A dedicated return system can streamline the process, improve customer service, and keep all your requests organized. In this tutorial, I&#8217;ll show you how to build a complete, <strong>lightweight return system<\/strong> for your WooCommerce store using a Custom Post Type (CPT), the Bricks Builder form element, and just a few lines of PHP code.<\/p>\n\n\n\n<p class=\"has-background\" style=\"border-radius:20px;background-color:#f4f4f4;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)\">If you&#8217;re looking for another way to streamline your WooCommerce workflow, be sure to check out my new plugin, <strong><a href=\"https:\/\/jasonblackeye.com\/i-built-a-quick-stock-adjust-plugin-for-woocommerce\/\" data-type=\"post\" data-id=\"2928\">Woo Quick Stock Adjust<\/a>.<\/strong> It makes managing product stock a breeze, directly from your WooCommerce product list.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69dc5e42a4f44&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69dc5e42a4f44\" class=\"wp-block-image size-large has-custom-border wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2-1024x683.webp\" alt=\"bricks forms return gallery 2\" class=\"wp-image-3000\" style=\"border-radius:20px\" srcset=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2-1024x683.webp 1024w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2-300x200.webp 300w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2-768x512.webp 768w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2-1536x1024.webp 1536w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2-18x12.webp 18w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-2.webp 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"\u039c\u03b5\u03b3\u03ad\u03b8\u03c5\u03bd\u03c3\u03b7\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>This method avoids bulky, expensive plugins and gives you full control. We&#8217;ll use the <a href=\"https:\/\/www.advancedcustomfields.com\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">Advance Custom Fields (ACF)<\/a> plugin to create the <strong>necessary fields<\/strong> for your return requests.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Features<\/strong><\/h4>\n\n\n\n<p>This custom solution gives you a powerful, yet simple, returns management system:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Dedicated Request Management<\/strong>: All return requests are saved as a custom post type called &#8220;Returns,&#8221; creating a central hub for all requests instead of getting lost in your inbox.<\/li>\n\n\n\n<li><strong>User-Friendly Form:<\/strong> Customers submit their requests through a simple, custom-designed form built with Bricks Builder.<\/li>\n\n\n\n<li><strong>Instant Request Status:<\/strong> The system automatically saves new requests with a default status of &#8220;In Progress,&#8221; keeping your team instantly informed.<\/li>\n\n\n\n<li><strong>Intuitive Admin Interface:<\/strong> The system adds key information directly to the &#8220;Returns&#8221; list view in your WordPress admin dashboard. You&#8217;ll see the customer&#8217;s name, phone number, order ID, and the product they want to return at a glance.<\/li>\n\n\n\n<li><strong>Visual Status Badges<\/strong>: Requests are visually color-coded with badges\u2014for example, yellow for &#8220;In Progress&#8221; and blue for &#8220;Completed&#8221;\u2014making it easy to see the status of each return.<\/li>\n\n\n\n<li><strong>Quick Actions<\/strong>: A &#8220;Quick Complete&#8221; link appears on each return in the list view, allowing you to change a request&#8217;s status to &#8220;Completed&#8221; with a single click.<\/li>\n\n\n\n<li><strong>Admin Menu Notifications<\/strong>: A red notification badge appears next to the &#8220;Returns&#8221; menu in the admin sidebar, showing you the number of open &#8220;In Progress&#8221; requests that need your attention.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Create the \u2018Returns\u2019 Custom Post Type and Fields<\/h4>\n\n\n\n<p>Before adding any code, you must create the foundation for your system: the Custom Post Type (CPT) and its fields. This is where all the information from the return requests will be stored.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create the Custom Post Type: Using <a href=\"https:\/\/www.advancedcustomfields.com\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">ACF<\/a>, create a new CPT with the following details:<br><strong>Slug<\/strong>: return (this is critical, it must match the code)<br><strong>Plural Name<\/strong>: Returns<br><strong>Singular Name:<\/strong> Return<\/li>\n\n\n\n<li>Create the Custom Fields: Next, create a field group and link it to the &#8216;Returns&#8217; CPT. Make sure the Attribute Name of each field matches exactly with the name referenced in the PHP code, as shown below:<\/li>\n<\/ol>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table is-style-stripes has-small-font-size\"><table class=\"has-fixed-layout\" style=\"border-style:none;border-width:0px\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">Field Label<\/th><th class=\"has-text-align-left\" data-align=\"left\">Attribute Name (for the form)<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\">Order No.<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_order_id<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Order Email<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_order_email<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Full Name<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_name<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Phone<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_phone<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Reason for Return<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_reason<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Product for Return<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Product Details<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product_info<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Product for Exchange<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product_change<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Exchange Product SKU<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product_change_sku<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Bank<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_bank<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">IBAN<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_iban<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 2: Building the Return Form with Bricks Builder<\/strong><\/h4>\n\n\n\n<p>Now that your custom post type and fields are ready, it&#8217;s time to build the form that customers will use to submit their requests.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3-1024x683.webp\" alt=\"bricks forms return gallery 3\" class=\"wp-image-3001\" style=\"border-radius:20px\" srcset=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3-1024x683.webp 1024w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3-300x200.webp 300w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3-768x512.webp 768w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3-1536x1024.webp 1536w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3-18x12.webp 18w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-3.webp 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a New Page<\/strong>: Create a new page in WordPress, title it &#8220;Return Request&#8221; (or similar), and open it with Bricks Builder.<\/li>\n\n\n\n<li><strong>Add the Form Element<\/strong>: Drag the Form element onto the canvas.<\/li>\n\n\n\n<li><strong>Configure Form Actions<\/strong>: In the form settings, go to the Form Actions tab and select <strong>Custom Action<\/strong>. This is the critical step that links the form to the first PHP snippet you will add.<\/li>\n\n\n\n<li><strong>Create the Form Fields<\/strong>: Delete the default fields and create new ones, making sure the Attribute Name of each field matches exactly with the names you defined in Step 1 and the PHP code.<\/li>\n<\/ol>\n\n\n\n<p>Here&#8217;s a <strong>guide<\/strong> for the form fields and their corresponding Attribute Name you must enter:<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table is-style-stripes has-small-font-size\"><table class=\"has-fixed-layout\" style=\"border-style:none;border-width:0px\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">Field Type<\/th><th class=\"has-text-align-left\" data-align=\"left\">Field Label<\/th><th class=\"has-text-align-left\" data-align=\"left\">Attribute Name <\/th><th class=\"has-text-align-left\" data-align=\"left\">Description<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">Order No.<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_order_id<\/td><td class=\"has-text-align-left\" data-align=\"left\">For the customer&#8217;s order ID.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Email<\/td><td class=\"has-text-align-left\" data-align=\"left\">Order Email<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_order_email<\/td><td class=\"has-text-align-left\" data-align=\"left\">For the order&#8217;s email address.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">Full Name<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_name<\/td><td class=\"has-text-align-left\" data-align=\"left\">For the customer&#8217;s name.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Tel<\/td><td class=\"has-text-align-left\" data-align=\"left\">Phone<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_phone<\/td><td class=\"has-text-align-left\" data-align=\"left\">For the customer&#8217;s phone number.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Select<\/td><td class=\"has-text-align-left\" data-align=\"left\">Reason for Return<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_reason<\/td><td class=\"has-text-align-left\" data-align=\"left\">A dropdown for the return reason.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">Product for Return<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product<\/td><td class=\"has-text-align-left\" data-align=\"left\">The name or SKU of the product.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Textarea<\/td><td class=\"has-text-align-left\" data-align=\"left\">Product Details<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product_info<\/td><td class=\"has-text-align-left\" data-align=\"left\">Any additional info about the product.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">Product for Exchange<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product_change<\/td><td class=\"has-text-align-left\" data-align=\"left\">The name or SKU of the exchange product.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">Exchange Product SKU<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_product_change_sku<\/td><td class=\"has-text-align-left\" data-align=\"left\">The SKU of the exchange product.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">Bank<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_bank<\/td><td class=\"has-text-align-left\" data-align=\"left\">The name of the customer&#8217;s bank.<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Text<\/td><td class=\"has-text-align-left\" data-align=\"left\">IBAN<\/td><td class=\"has-text-align-left\" data-align=\"left\">return_iban<\/td><td class=\"has-text-align-left\" data-align=\"left\">The customer&#8217;s IBAN for the refund.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3: Adding the PHP Code Snippets<\/h4>\n\n\n\n<p>You&#8217;ll need to add these three PHP snippets to your website. The best practice is to add them to your child theme&#8217;s functions.php file or in WP Code or Code Snippets.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69dc5e42a63d5&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69dc5e42a63d5\" class=\"wp-block-image size-large has-custom-border wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" data-id=\"3005\" src=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1-1024x683.webp\" alt=\"bricks forms return gallery 1\" class=\"wp-image-3005\" style=\"border-radius:15px\" srcset=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1-1024x683.webp 1024w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1-300x200.webp 300w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1-768x512.webp 768w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1-1536x1024.webp 1536w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1-18x12.webp 18w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-1.webp 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"\u039c\u03b5\u03b3\u03ad\u03b8\u03c5\u03bd\u03c3\u03b7\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69dc5e42a6669&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69dc5e42a6669\" class=\"wp-block-image size-large has-custom-border wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" data-id=\"3006\" src=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4-1024x683.webp\" alt=\"bricks forms return gallery 4\" class=\"wp-image-3006\" style=\"border-radius:15px\" srcset=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4-1024x683.webp 1024w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4-300x200.webp 300w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4-768x512.webp 768w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4-1536x1024.webp 1536w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4-18x12.webp 18w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-4.webp 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"\u039c\u03b5\u03b3\u03ad\u03b8\u03c5\u03bd\u03c3\u03b7\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69dc5e42a68d8&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69dc5e42a68d8\" class=\"wp-block-image size-large has-custom-border wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" data-id=\"3007\" src=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5-1024x683.webp\" alt=\"bricks forms return gallery 5\" class=\"wp-image-3007\" style=\"border-radius:15px\" srcset=\"https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5-1024x683.webp 1024w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5-300x200.webp 300w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5-768x512.webp 768w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5-1536x1024.webp 1536w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5-18x12.webp 18w, https:\/\/jasonblackeye.com\/wp-content\/uploads\/2025\/08\/Bricks-Forms-Return-Gallery-5.webp 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"\u039c\u03b5\u03b3\u03ad\u03b8\u03c5\u03bd\u03c3\u03b7\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>1. Bricks Form Action<\/strong><\/p>\n\n\n\n<p>This snippet tells your Bricks form what to do when a user submits it. It creates a new &#8220;Return&#8221; custom post and saves the form data as custom fields.<\/p>\n\n\n\n<p><strong>Important<\/strong>: You must change the form ID and ensure your form field names match the names in the code.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code has-white-color has-text-color has-background has-link-color has-small-font-size wp-elements-0e5999ef9d7d15648fefdefab3f11e9a\" style=\"border-radius:20px;background-color:#252525;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)\"><code>\/**\n * Custom action for Bricks form submission.\n * This script creates a new 'return' post type and saves the form data.\n *\/\nadd_action( 'bricks\/form\/custom_action', function( $form ) {\n    \/\/ Get all fields from the form submission\n    $fields = $form-&gt;get_fields();\n\n    \/\/ --- Check for the correct form ID ---\n    $form_id = $fields&#91;'formId'] ?? '';\n    \/\/ CHANGE 'mlniuq' TO YOUR BRICKS FORM ID\n    if ( $form_id !== 'mlniuq' ) {\n        return;\n    }\n\n    \/\/ --- Sanitize and retrieve field values ---\n    \/\/ The names in $fields&#91;'name'] MUST match the names of your form fields\n    $order_id           = sanitize_text_field( $fields&#91;'return_order_id'] ?? '' );\n    $order_email        = sanitize_email( $fields&#91;'return_order_email'] ?? '' );\n    $name               = sanitize_text_field( $fields&#91;'return_name'] ?? '' );\n    $phone              = sanitize_text_field( $fields&#91;'return_phone'] ?? '' );\n    $reason             = sanitize_text_field( $fields&#91;'return_reason'] ?? '' );\n    $product            = sanitize_text_field( $fields&#91;'return_product'] ?? '' );\n    $product_info       = sanitize_textarea_field( $fields&#91;'return_product_info'] ?? '' );\n    $product_change     = sanitize_text_field( $fields&#91;'return_product_change'] ?? '' );\n    $product_change_sku = sanitize_text_field( $fields&#91;'return_product_change_sku'] ?? '' );\n    $bank               = sanitize_text_field( $fields&#91;'return_bank'] ?? '' );\n    $iban               = sanitize_text_field( $fields&#91;'return_iban'] ?? '' );\n\n    \/\/ --- Create the new post with a temporary title ---\n    $post_id = wp_insert_post(&#91;\n        'post_type'   =&gt; 'return', \/\/ This must match your Custom Post Type slug\n        'post_title'  =&gt; 'Temporary Return Request',\n        'post_status' =&gt; 'publish',\n    ]);\n\n    \/\/ --- If the post was created, save the data ---\n    if ( $post_id &amp;&amp; !is_wp_error( $post_id ) ) {\n\n        \/\/ --- GENERATE A UNIQUE TITLE ---\n        \/\/ Combine the current date with the newly created post's ID\n        $final_title = wp_date('dmY') . '-' . $post_id;\n\n        \/\/ --- UPDATE THE POST ---\n        \/\/ Update the post with the final title and the custom 'in_progress' status\n        wp_update_post(&#91;\n            'ID'          =&gt; $post_id,\n            'post_title'  =&gt; $final_title,\n            'post_status' =&gt; 'in_progress',\n        ]);\n\n        \/\/ Save all the custom fields\n        update_post_meta( $post_id, 'return_order_id', $order_id );\n        update_post_meta( $post_id, 'return_order_email', $order_email );\n        update_post_meta( $post_id, 'return_name', $name );\n        update_post_meta( $post_id, 'return_phone', $phone );\n        update_post_meta( $post_id, 'return_reason', $reason );\n        update_post_meta( $post_id, 'return_product', $product );\n        update_post_meta( $post_id, 'return_product_info', $product_info );\n        update_post_meta( $post_id, 'return_product_change', $product_change );\n        update_post_meta( $post_id, 'return_product_change_sku', $product_change_sku );\n        update_post_meta( $post_id, 'return_bank', $bank );\n        update_post_meta( $post_id, 'return_iban', $iban );\n\n        \/\/ Send a success message back to the form\n        $form-&gt;set_result(&#91;\n            'action'  =&gt; 'custom_action',\n            'type'    =&gt; 'success',\n            'message' =&gt; '\u2705 Your return request has been submitted successfully!',\n        ]);\n    } else {\n        \/\/ Send an error message if something went wrong\n        $form-&gt;set_result(&#91;\n            'action'  =&gt; 'custom_action',\n            'type'    =&gt; 'danger',\n            'message' =&gt; '\u274c An error occurred while saving the request. Please try again.',\n        ]);\n    }\n}, 10, 1 );<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>2. Admin Columns &amp; Badge<\/strong><\/p>\n\n\n\n<p>This snippet customizes the admin list view for your &#8220;Returns&#8221; CPT. It <strong>adds new columns<\/strong>, displays the custom field data within them, and shows <strong>a status badge<\/strong>. It also adds a notification badge to the &#8220;Returns&#8221; menu item.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code has-white-color has-text-color has-background has-link-color has-small-font-size wp-elements-a762ae296368819da15362212802f74a\" style=\"border-radius:20px;background-color:#252525;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)\"><code>\/**\n * Adds and customizes admin columns for the 'return' CPT.\n *\/\n\n\/\/ 1. Add the new columns\nadd_filter( 'manage_return_posts_columns', 'set_custom_edit_return_columns' );\nfunction set_custom_edit_return_columns($columns) {\n    $new_columns = &#91;\n        'cb'              =&gt; $columns&#91;'cb'],\n        'title'           =&gt; __( 'Return No.', 'textdomain' ),\n        'status'          =&gt; __( 'Status', 'textdomain' ),\n        'return_name'     =&gt; __( 'Full Name', 'textdomain' ),\n        'return_phone'    =&gt; __( 'Phone', 'textdomain' ),\n        'return_order_id' =&gt; __( 'Order No.', 'textdomain' ),\n        'return_product'  =&gt; __( 'Product for Return', 'textdomain' ),\n        'date'            =&gt; $columns&#91;'date']\n    ];\n\n    return $new_columns;\n}\n\n\/\/ 2. Display the data in the new columns\nadd_action( 'manage_return_posts_custom_column' , 'custom_return_column_content', 10, 2 );\nfunction custom_return_column_content( $column, $post_id ) {\n    switch ( $column ) {\n        case 'return_name' :\n            echo esc_html( get_post_meta( $post_id , 'return_name' , true ) );\n            break;\n\n        case 'return_phone' :\n            echo esc_html( get_post_meta( $post_id , 'return_phone' , true ) );\n            break;\n\n        case 'return_order_id' :\n            echo '&lt;strong&gt;' . esc_html( get_post_meta( $post_id , 'return_order_id' , true ) ) . '&lt;\/strong&gt;';\n            break;\n\n        case 'return_product' :\n            echo esc_html( get_post_meta( $post_id , 'return_product' , true ) );\n            break;\n\n        case 'status' :\n            $status = get_post_status( $post_id );\n            $status_label = '';\n            $background_color = '#e0e0e0'; \/\/ Default Grey\n\n            if ( $status === 'in_progress' ) {\n                $status_label = 'In Progress';\n                $background_color = '#ffc107'; \/\/ Yellow\n            } elseif ( $status === 'completed' ) {\n                $status_label = 'Completed';\n                $background_color = '#0d6efd'; \/\/ Blue\n            } else {\n                $status_obj = get_post_status_object( $status );\n                $status_label = $status_obj ? $status_obj-&gt;label : $status;\n            }\n\n            printf(\n                '&lt;span style=\"background-color: %s; color: %s; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; white-space: nowrap;\"&gt;%s&lt;\/span&gt;',\n                esc_attr( $background_color ),\n                $background_color === '#ffc107' ? '#000' : '#fff',\n                esc_html( $status_label )\n            );\n            break;\n    }\n}\n\n\/**\n * Adds a notification badge to the 'Returns' submenu item.\n *\/\nadd_action( 'admin_menu', 'add_in_progress_returns_bubble_to_submenu', 99 );\nfunction add_in_progress_returns_bubble_to_submenu() {\n    global $submenu;\n\n    \/\/ Define the CPT slug (always lowercase)\n    $cpt_slug = 'return';\n    \/\/ Define the parent menu slug (WooCommerce)\n    $parent_slug = 'woocommerce';\n\n    \/\/ If no WooCommerce submenu exists, stop.\n    if ( ! isset( $submenu&#91; $parent_slug ] ) ) {\n        return;\n    }\n\n    \/\/ 1. Get the count of posts with 'in_progress' status\n    $count_posts = wp_count_posts( $cpt_slug );\n    $in_progress_count = $count_posts-&gt;in_progress ?? 0;\n\n    \/\/ 2. If the count is greater than zero, proceed\n    if ( $in_progress_count &gt; 0 ) {\n\n        \/\/ 3. Search for the CPT's submenu item within the parent menu\n        foreach ( $submenu&#91; $parent_slug ] as $key =&gt; $value ) {\n\n            \/\/ The URL we are looking for is for our CPT\n            $menu_url = 'edit.php?post_type=' . $cpt_slug;\n\n            \/\/ If the correct submenu item is found\n            if ( isset($value&#91;2]) &amp;&amp; $value&#91;2] === $menu_url ) {\n\n                \/\/ 4. Add the notification badge\n                $submenu&#91; $parent_slug ]&#91; $key ]&#91;0] .= ' &lt;span class=\"awaiting-mod\"&gt;&lt;span class=\"pending-count\"&gt;' . esc_html( $in_progress_count ) . '&lt;\/span&gt;&lt;\/span&gt;';\n\n                \/\/ Stop the loop once found\n                break;\n            }\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>3. Custom Statuses &amp; Quick Actions<\/strong><\/p>\n\n\n\n<p>This snippet creates the <strong>two custom statuses<\/strong> for your &#8220;Returns&#8221; CPT (&#8220;In Progress&#8221; and &#8220;Completed&#8221;) and adds a quick action link to the list view, allowing you to easily change a request&#8217;s status.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code has-white-color has-text-color has-background has-link-color has-small-font-size wp-elements-4ef72929286eeac2db3557b379274b78\" style=\"border-radius:20px;background-color:#252525;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)\"><code>\/**\n * Creates custom post statuses for the 'return' CPT.\n *\/\n\n\/\/ 1. Register the new statuses with WordPress\nfunction register_custom_return_statuses() {\n\n    \/\/ Status: In Progress\n    register_post_status('in_progress', &#91;\n        'label'                       =&gt; _x( 'In Progress', 'post' ),\n        'public'                      =&gt; true,\n        'exclude_from_search'         =&gt; false,\n        'show_in_admin_all_list'      =&gt; true,\n        'show_in_admin_status_list'   =&gt; true,\n        'label_count'                 =&gt; _n_noop( 'In Progress &lt;span class=\"count\"&gt;(%s)&lt;\/span&gt;', 'In Progress &lt;span class=\"count\"&gt;(%s)&lt;\/span&gt;' ),\n    ]);\n\n    \/\/ Status: Completed\n    register_post_status('completed', &#91;\n        'label'                       =&gt; _x( 'Completed', 'post' ),\n        'public'                      =&gt; true,\n        'exclude_from_search'         =&gt; false,\n        'show_in_admin_all_list'      =&gt; true,\n        'show_in_admin_status_list'   =&gt; true,\n        'label_count'                 =&gt; _n_noop( 'Completed &lt;span class=\"count\"&gt;(%s)&lt;\/span&gt;', 'Completed &lt;span class=\"count\"&gt;(%s)&lt;\/span&gt;' ),\n    ]);\n}\nadd_action( 'init', 'register_custom_return_statuses' );\n\n\n\/\/ 2. Add the new statuses to the post editor dropdown\nfunction add_custom_statuses_to_post_editor() {\n    global $post;\n    if ( ! $post || $post-&gt;post_type !== 'return' ) {\n        return;\n    }\n    \/\/ This script ensures the correct value is selected in the dropdown\n    $script = \"\n        &lt;script&gt;\n        jQuery(document).ready(function($){\n            $('select&#91;name=\\\"post_status\\\"]').append('&lt;option value=\\\"in_progress\\\"&gt;In Progress&lt;\/option&gt;');\n            $('select&#91;name=\\\"post_status\\\"]').append('&lt;option value=\\\"completed\\\"&gt;Completed&lt;\/option&gt;');\n\n            \/\/ Set the current post's status as selected\n            var currentStatus = '{$post-&gt;post_status}';\n            if (currentStatus === 'in_progress' || currentStatus === 'completed') {\n                $('select&#91;name=\\\"post_status\\\"]').val(currentStatus);\n            }\n        });\n        &lt;\/script&gt;\n    \";\n    echo $script;\n}\nadd_action( 'admin_footer-post.php', 'add_custom_statuses_to_post_editor' );\nadd_action( 'admin_footer-post-new.php', 'add_custom_statuses_to_post_editor' );\n\n\/**\n * Adds a \"Complete\" quick action to the returns list.\n *\/\n\n\/\/ Part A: Add the \"Complete\" link below each request\nadd_filter( 'post_row_actions', 'add_quick_complete_action_link', 10, 2 );\nfunction add_quick_complete_action_link( $actions, $post ) {\n    \/\/ Check if we are on the 'return' CPT and if the request is NOT already completed\n    if ( $post-&gt;post_type === 'return' &amp;&amp; $post-&gt;post_status !== 'completed' ) {\n        \/\/ Create the URL for the action with a security check (nonce)\n        $url = add_query_arg(&#91;\n            'action' =&gt; 'mark_return_as_completed',\n            'post_id' =&gt; $post-&gt;ID,\n            '_wpnonce' =&gt; wp_create_nonce('complete_return_nonce_' . $post-&gt;ID)\n        ]);\n\n        \/\/ Add the link to the list of actions\n        $actions&#91;'mark_completed'] = sprintf( '&lt;a href=\"%s\" style=\"color:#0d6efd;\"&gt;Completed&lt;\/a&gt;', esc_url( $url ) );\n    }\n    return $actions;\n}\n\n\/\/ Part B: The code that executes when the link is clicked\nadd_action( 'admin_action_mark_return_as_completed', 'handle_quick_complete_action' );\nfunction handle_quick_complete_action() {\n    \/\/ Get the post ID from the URL\n    $post_id = isset($_GET&#91;'post_id']) ? intval($_GET&#91;'post_id']) : 0;\n\n    \/\/ Security check (nonce) to ensure the request is valid\n    if ( ! $post_id || ! isset($_GET&#91;'_wpnonce']) || ! wp_verify_nonce($_GET&#91;'_wpnonce'], 'complete_return_nonce_' . $post_id) ) {\n        wp_die('The request is not valid.');\n    }\n\n    \/\/ Change the post status to \"Completed\"\n    wp_update_post(&#91;\n        'ID'          =&gt; $post_id,\n        'post_status' =&gt; 'completed',\n    ]);\n\n    \/\/ Redirect back to the previous page (the list view)\n    wp_redirect( wp_get_referer() );\n    exit();\n}<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Keep in mind that this system is <strong>fully customizable<\/strong>. You can add or remove form fields and custom fields as you see fit. Just remember that for the system to work correctly, the Attribute Name you use in your Bricks form must exactly match the name of the custom field in ACF and the field name in the PHP code.<\/p>","protected":false},"excerpt":{"rendered":"<p>Learn how to build a complete return request system for your WooCommerce store. This tutorial uses a custom post type, Bricks Builder, and three simple PHP snippets. Manage returns efficiently and improve your customer service.<\/p>","protected":false},"author":1,"featured_media":3029,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[13],"tags":[],"class_list":["post-2966","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/posts\/2966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/comments?post=2966"}],"version-history":[{"count":0,"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/posts\/2966\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/media\/3029"}],"wp:attachment":[{"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/media?parent=2966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/categories?post=2966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jasonblackeye.com\/el\/wp-json\/wp\/v2\/tags?post=2966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}