Add a Click-to-Copy Coupon Code to an Elementor Page with Addon Elements and AI
A coupon code with a copy button and its end date, typed in or read from your WooCommerce coupon, previewed before it goes live.
Prerequisites
A site connected to WPVibe running Elementor 3.27 or newer (free is enough) and Addon Elements for Elementor 1.15.1 or newer (tested on 1.15.1, the free version, with Elementor 4.3.6) on WordPress 6.9 or newer, with an administrator account and the WPVibe plugin up to date. A published page built with Elementor. The coupon code, and its last day if it has one. WooCommerce, if the code is a WooCommerce coupon.
My WordPress site uses Elementor and the free Addon Elements for Elementor plugin. Add a section with the heading "[section heading, for example 10% off your first order]" and a coupon code that visitors copy with one click to my page [page title]. Code: [the code]. [Last day: date, or no end date.] Button text: "[button text, for example Copy the code]". Put it [before the section that starts with X, or at the end of the page].
1. Run discover_abilities with category addon-elements. If eae/list-widgets and eae/get-widget-schema are not both listed, stop and tell me to install and activate Elementor and the free Addon Elements for Elementor plugin (1.15.1 or newer): its AI tools load only while Elementor is active. Run site_info and check its features include content_edit; if not, stop and tell me to update the WPVibe plugin. Run eae/list-widgets and check eae-coupon-code is in the list; if it isn't, stop and tell me to switch it on in wp-admin under Addon Elements, then ask again.
2. Find my page with rest_api GET /wp/v2/pages with search set to [page title], status publish and fields id,title,link. If several match, list them and ask which one; if none match, stop and tell me. PAGE_ID is its id, PAGE_URL its link, and SITE_URL my site's address. Read it with rest_api GET /wp/v2/pages/PAGE_ID with context edit, fields id,modified,meta and max_length 400000. If meta._elementor_edit_mode is not builder, stop and tell me the page isn't built with Elementor. If the read was cut, stop before changing anything and tell me the page is too large for this recipe. MODIFIED is its modified date. meta._elementor_data is the layout, a JSON array: note the id of each top-level element in order, with the first heading or text inside it.
3. Find where the section goes. Before a section: NEXT_ID is the id of the top-level element whose heading or text starts with what I named; if you can't tell which one I meant, list the top-level elements with their first heading and ask. At the end of the page: TAIL is the last 40 characters of meta._elementor_data exactly as stored (after decoding the REST response, so backslashes in the value stay as they are).
4. Run eae/get-widget-schema with input widget eae-coupon-code, and set run_ability's own max_length to 100000, not in the input (some widgets' settings run past WPVibe's default length). If WPVibe still cuts the result, read it in parts: call it again with offset 100, then 200, then 300 and so on, until the offset reaches total_controls (given near the top of the first reply), keeping the keys from every part; parts may overlap; if it says truncated true, call it again with offset next_offset. Read every part before you build. Use only the keys it lists, plus the ones named here. Any key you leave out falls back to the widget's demo content (AAA-9867-123, Coupon Code, Expire Date, Expiry Date Not added), so set every text I gave you. Give each new element an id of 8 random lowercase hex characters that is not already in the layout, and each repeater row its own _id of 7. The section is one container (container_type flex, flex_direction column, content_width boxed) with id NEW_ID, holding a heading widget (title [section heading], header_size h2) and one eae-coupon-code widget. Check whether the code is a WooCommerce coupon: run rest_api GET /wc/v3/coupons with code set to my code and fields id,code,status,date_expires (if that route doesn't exist, WooCommerce isn't active). It finds published coupons only, and WooCommerce codes ignore upper and lower case, so compare them that way. If WooCommerce is active and no coupon matches, tell me and ask whether to show the code as typed text anyway (WooCommerce won't accept it at checkout unless the coupon exists and is published) before you go on. If a coupon matches, WooCommerce stores its code in lower case and the widget shows it that way: if my code has capitals, tell me and ask whether to use the WooCommerce coupon (code shown in lower case) or typed text (my capitals, same end date; WooCommerce still accepts it at checkout). A WooCommerce end date (date_expires) is the first day the code stops working, so the coupon's last day is the day before it; if that differs from the last day I gave, tell me before you go on. Before either branch: if the last day is before today, stop and ask me, because the offer has ended (and WooCommerce would refuse the code). If you use the WooCommerce coupon: source dynamic and dynamic_coupon its id as text. The widget always shows a WooCommerce coupon's date line, printing date_expires as a UTC date, which is not the last day, so write the date yourself: sta_exp_dt_msg Valid until and the coupon's last day written out (for example Valid until December 30, 2026), with no ExpireDate token in it; if the coupon has no end date, sta_exp_dt_msg as an empty string, or it says Expiry Date Not added. If you use typed text (no WooCommerce coupon, or I chose typed text): source static, sta_coupon_code my code, and with an end date sta_exp yes, sta_expire_date as YYYY-MM-DD and sta_exp_dt_msg Valid until %%ExpireDate%%; with no end date sta_exp set to an empty string, because the widget otherwise shows a made-up date 30 days ahead. In both branches: coupon_type standard, sta_layout click, sta_title my button text, after_copy_button Copied!, and sta_show_code left at its default, so the code shows beside the button.
5. Save the section on a new draft page first: rest_api_write POST /wpvibe/v1/elementor/save-page with title the page title followed by (AI preview), status draft, page_template elementor_header_footer, and data an array holding only the section. PREVIEW_ID is the id it returns. Give me the preview link, SITE_URL/?page_id=PREVIEW_ID&preview=true (it opens only while I'm logged in), describe the section, and wait for my yes. Nothing on my live page has changed yet. If I say no, ask what to change, make it on the same preview page (save-page again with id PREVIEW_ID and the whole new section), and show me again; if I want none of it, skip to the last step.
6. On my yes, read the page again as in step 2; if its modified date is no longer MODIFIED or its top-level ids are not the ones from step 2, stop and tell me someone edited it. Never resend or retype the page's whole layout: add the section with one small edit, rest_api_write POST /wpvibe/v1/content/edit with target_type meta, post_id PAGE_ID and meta_key _elementor_data, the section written as one compact JSON object. Before a section: old_content is {"id":"NEXT_ID" (with the brace and quotes in front), new_content is the section, a comma, then that same old_content. At the end of the page: run POST /wpvibe/v1/content/search with the same target and pattern TAIL. If it matches exactly once and its snippet runs to the end of the value (snippet_starts_at_char plus the snippet's length is line_length, or line_length is absent because the snippet is the whole value, and it ends with the final closing square bracket), take the snippet's last 60 to 120 characters, copied exactly, as old_content, and as new_content the same text with a comma and the section added just before that final bracket. If not, try once more with the last 20 characters; if that fails too, stop and ask me which section to put it before. content/edit changes only text that matches exactly once and refuses an edit that would leave the layout's JSON broken; if it refuses, tell me what it said. Never use replace_all. Keep the old_content and new_content you used: swapping them is the undo.
7. Read the page again as in step 2 and check every top-level id from step 2 is still there in the same order, with NEW_ID where I wanted it. If not, undo the edit (content/edit with old_content and new_content swapped) and tell me what you saw.
8. Fetch the live page with get_page_html, selector .elementor-element-NEW_ID, and check, in the section's visible text (outside the HTML tags and attributes), that my code (compared ignoring upper and lower case) and my button text is there and none of the demo text (AAA-9867-123, Coupon Code, Expire Date, Expiry Date Not added) is, except words I gave you myself. If the selector matches nothing, undo the edit and tell me. If something is missing or demo text is there, tell me what and offer the undo. That fetch skips page caches, so then run run_wp_cli cache purge --url=PAGE_URL so visitors get the new version too, and tell me what it reported; if my host caches pages, I purge it there. If there is an end date, check the date shown is the last day the code works.
9. Ask whether to trash the preview page. Only on my yes, check with rest_api GET /wp/v2/pages/PREVIEW_ID with fields id,status,title that it is a draft whose title ends (AI preview), then run rest_api_write DELETE /wp/v2/pages/PREVIEW_ID (it goes to the trash; WPVibe doesn't ask for approval on this one, so ask me yourself). Tell me how to undo the change: content/edit on the page with the old_content and new_content you used, swapped. Tell me that if this page was open in the Elementor editor during this, I should reload the editor before saving there, or its older copy replaces the new section. List what you changed so I can spot-check it, and give me the page link and its Elementor edit link, SITE_URL/wp-admin/post.php?post=PAGE_ID&action=elementor. Remind me the code stays on the page after its end date, and offer to take it off then with the undo.
Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:
Run the “Add a Click-to-Copy Coupon Code to an Elementor Page with Addon Elements and AI” recipe from the WPVibe cookbook on my connected site.
A discount code works better when visitors can copy it with one click instead of retyping it at checkout. The free Addon Elements plugin has a Coupon Code widget that does that, and it can read the code and end date straight from a WooCommerce coupon, but left at its defaults it shows an end date nobody chose.
The AI builds the section with your code, or links it to your WooCommerce coupon so the code comes from your store, and saves it on a draft page for you to try. Your live page changes only on your yes, with one small edit the AI keeps a note of, and it checks the page afterwards for your code and the right date.
The date on the widget is only text, written when the AI builds the section: if you change the coupon’s end date in WooCommerce later, ask it to update the section. The code stays on the page after the date passes. With a WooCommerce coupon, WooCommerce stops the code working at checkout; with a code typed in, take the section off when the offer ends, which is one step with the note the AI keeps. If it can’t find the end of your page’s layout, the AI asks which section to put the code before. To create the WooCommerce coupon itself, see Create and Schedule WooCommerce Coupons.
Outcome
A section on your page showing your code with a button that copies it, and its end date if it has one.