Skip to main content
Glama

woolworths_update_cart_quantity

Change product quantities in your Woolworths shopping cart by specifying the stockcode and desired amount to update your order.

Instructions

Update the quantity of a product in the shopping cart/trolley

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stockcodeYesThe product stockcode/ID
quantityYesNew quantity

Implementation Reference

  • The main handler function for the 'woolworths_update_cart_quantity' tool. It sends a POST request to the Woolworths trolley update API with the specified stockcode and new quantity, using session cookies for authentication.
    async function handleUpdateCartQuantity(args: any): Promise<any> { const stockcode = args.stockcode; const quantity = args.quantity; const url = `https://www.woolworths.com.au/api/v3/ui/trolley/update`; try { const data = await makeWoolworthsRequest(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ items: [ { stockcode, quantity, source: "ProductDetail", diagnostics: "0", searchTerm: null, evaluateRewardPoints: false, offerId: null, profileId: null, priceLevel: null, }, ], }), }); return { success: true, cart: data, }; } catch (error: any) { return { success: false, error: error.message, }; } }
  • The tool schema definition, including name, description, and inputSchema with required stockcode (number) and quantity (number). Part of the TOOLS array registered for ListTools.
    { name: "woolworths_update_cart_quantity", description: "Update the quantity of a product in the shopping cart/trolley", inputSchema: { type: "object", properties: { stockcode: { type: "number", description: "The product stockcode/ID", }, quantity: { type: "number", description: "New quantity", }, }, required: ["stockcode", "quantity"], }, },
  • src/index.ts:667-669 (registration)
    Registration in the switch statement of the CallToolRequestSchema handler, which dispatches tool calls to the corresponding handleUpdateCartQuantity function.
    case "woolworths_update_cart_quantity": result = await handleUpdateCartQuantity(args || {}); break;
  • Helper function used by the handler to make authenticated API requests to Woolworths, including cookie headers from the session.
    async function makeWoolworthsRequest( url: string, options: any = {} ): Promise<any> { if (sessionCookies.length === 0) { throw new Error( "No session cookies available. Please use woolworths_get_cookies first." ); } const headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", Accept: "*/*", "Accept-Language": "en-US,en;q=0.9", Origin: "https://www.woolworths.com.au", Referer: "https://www.woolworths.com.au/", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", Priority: "u=1, i", Cookie: getCookieHeader(), ...options.headers, }; const response = await fetch(url, { ...options, headers, }); if (!response.ok) { const errorText = await response.text(); throw new Error( `API request failed: ${response.status} ${response.statusText}. ${errorText}` ); } return response.json(); }
  • Helper function to format session cookies into a Cookie header string, used in makeWoolworthsRequest.
    function getCookieHeader(): string { return sessionCookies.map((c) => `${c.name}=${c.value}`).join("; "); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elijah-g/Woolworths-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server