import { useEffect, useState } from "react" import { Check, Copy } from "lucide-react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" const shortcode = "[swift_commerce_search]" export function AjaxSearchShortcodeTab() { const [copied, setCopied] = useState(false) const [copyError, setCopyError] = useState(false) useEffect(() => { if (!copied) return const timeout = window.setTimeout(() => setCopied(false), 2000) return () => window.clearTimeout(timeout) }, [copied]) const copyShortcode = async () => { setCopyError(false) try { await navigator.clipboard.writeText(shortcode) setCopied(true) } catch { // HTTP installations may not provide the Clipboard API. const focusedElement = document.activeElement const textArea = document.createElement("textarea") textArea.value = shortcode textArea.style.position = "fixed" textArea.style.opacity = "0" document.body.appendChild(textArea) textArea.select() try { const success = document.execCommand("copy") setCopied(success) setCopyError(!success) } catch { setCopyError(true) } finally { textArea.remove() if (focusedElement instanceof HTMLElement) focusedElement.focus() } } } return ( Shortcode Add live product search to a page, post, or widget area.
{shortcode}
{copyError &&

Could not copy. Select the shortcode and copy it manually.

}

Paste this into a WordPress Shortcode block. It uses your saved General, Search, and Appearance settings. For Elementor, you can also use the Ajax Search widget.

) }