'; wp_nonce_field( 'agentomise_product_access', 'agentomise_product_access_nonce' ); woocommerce_wp_checkbox( array( 'id' => self::META, 'label' => 'Exclude from agentic shopping', 'description' => 'Hide this product from Agentomise and block agent purchases, including all its variations. Normal WooCommerce shopping is unaffected.', 'desc_tip' => true, ) ); echo ''; } public function save( $product ) { $nonce = isset( $_POST['agentomise_product_access_nonce'] ) && is_string( $_POST['agentomise_product_access_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['agentomise_product_access_nonce'] ) ) : ''; if ( ! wp_verify_nonce( $nonce, 'agentomise_product_access' ) || ! current_user_can( 'edit_post', $product->get_id() ) ) { return; } if ( isset( $_POST[self::META] ) && $_POST[self::META] === 'yes' ) { $product->update_meta_data( self::META, 'yes' ); } else { $product->delete_meta_data( self::META ); } } public static function excluded( $product ) { if ( ! $product ) { return false; } // Read current metadata rather than a possibly stale product object's cached metadata. if ( get_post_meta( $product->get_id(), self::META, true ) === 'yes' ) { return true; } return $product->is_type( 'variation' ) && get_post_meta( $product->get_parent_id(), self::META, true ) === 'yes'; } }