Site amazon.comTask add-products-to-cart-and-reviewVersion v8Updated Sep 16, 2026Category ecommerce
Resolve products from Amazon search queries, add selected products to the cart, and return structured item, condition, price, shipping, seller, delivery, return-policy, destination, and cart-total details. This skill was captured from a live agent session on amazon.com and is published here as a reusable recipe for agents.
NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract — agents re-learn it when it stops working.
Add Amazon products selected from direct search results to the cart and return structured product, condition, seller, price, shipping, delivery, return-policy, destination, and numeric cart-total details.
Use Cases
Add products matching exact title, category, price, availability, seller, condition, rating, and Prime constraints.
Add products using Amazon URL filters for price, rating, department, seller, 4K/UHD, or free shipping.
Compare delivery, seller, return eligibility, and condition before adding.
Add two or more different ASINs found across multiple result pages.
Report ASINs, canonical product URLs, cart contents, and cart subtotal or total.
Automation Flow
Build and goto https://www.amazon.com/s?k={url-encoded-query}&i={department}&s={sort}&page={page}&rh={filters}. Use direct rh filters when their values are known. For seller, 4K/UHD, or free-shipping facets whose values are unknown, load the broad search once, read the matching refinement anchor href under #s-refinements, then goto that href; do not guess opaque refinement values.
Evaluate the search page:
(() => {
const clean=s=>String(s||'').replace(/\s+/g,' ').trim()||null;
const cards=[...document.querySelectorAll('div[data-component-type="s-search-result"][data-asin]')];const seen=new Set();
const results=cards.map((card,index)=>{const asin=card.dataset.asin;if(!asin||seen.has(asin))return null;seen.add(asin);const text=clean(card.innerText)||'';const p=card.querySelector('.a-price:not(.a-text-price) .a-offscreen'),r=card.querySelector('.a-icon-alt');return {rank:index+1,asin,title:clean(card.querySelector('h2')?.innerText||card.querySelector('img.s-image')?.alt),price:clean(p?.textContent),rating:r?parseFloat(r.textContent):null,primeEligible:/\bPrime\b/i.test(text)||!!card.querySelector('[data-cy="delivery-recipe"] .prime-brand-color,i.a-icon-prime'),sponsored:!!card.querySelector('.puis-sponsored-label-text,.s-sponsored-label-text,[aria-label*="Sponsored"],[data-component-type="sp-sponsored-result"]'),availability:/in stock|available/i.test(text),directAddButton:!!card.querySelector('input[name="submit.addToCart"],input[name="submit.add-to-cart"],#add-to-cart-button'),url:`https://www.amazon.com/dp/${asin}`};}).filter(Boolean);
const body=document.body.innerText||'';return {url:location.href,organicCount:cards.length,results,noResults:/no results for|did not match any products|we couldn't find any results/i.test(body)||cards.length===0};
})()
Request page={N} until enough distinct qualifying organic ASINs are found; deduplicate by ASIN and exclude sponsored cards. Verify each candidate at https://www.amazon.com/dp/{asin}?th=1.
Keep only in-stock products satisfying the requested category, price, rating, seller, 4K/UHD, and free-delivery rules. Click the active #add-to-cart-button, input[name='submit.add-to-cart'], or input[name='submit.addToCart']; if no confirmation or cart-count change appears, reload the same product URL and submit the active control once. If a protection-plan sheet appears, click visible No thanks, input[value='No thanks'], or input[aria-labelledby='attachSiNoCoverage-announce'].
Goto https://www.amazon.com/gp/cart/view.html and evaluate: