Skip to main content
Glama

get_quote

Calculate shipping costs and USDC payment amount for hats purchased with cryptocurrency, then receive the wallet address to complete your transaction.

Instructions

Get a shipping quote and USDC payment amount for a product. Returns the wallet address to send payment to.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
variant_idYesShopify variant ID
shipping_nameYesRecipient full name
shipping_address1YesStreet address
shipping_cityYesCity
shipping_stateYesState (2-letter code)
shipping_zipYesZIP code
shipping_countryNoCountry code (default: US)

Implementation Reference

  • main.py:307-350 (handler)
    The `get_quote` handler calculates the product price and shipping, generates a unique quote ID, stores the quote details, and returns the payment instructions in USDC on the Base network.
    async def get_quote(request: Request):
        body = await request.json()
        variant_id = body.get("variant_id")
        quantity = body.get("quantity", 1)
        address = body.get("shipping_address", {})
    
        # Get variant price from Shopify
        data = await shopify_get(f"variants/{variant_id}.json")
        variant = data["variant"]
        unit_price = float(variant["price"])
        subtotal = unit_price * quantity
    
        # Standard shipping estimate (US $5, international $15)
        country = address.get("country_code", "US")
        shipping = 5.0 if country == "US" else 15.0
        total_usdc = round(subtotal + shipping, 2)
    
        quote_id = make_quote_id(variant_id, quantity)
        _quotes[quote_id] = {
            "variant_id": variant_id,
            "quantity": quantity,
            "total_usdc": total_usdc,
            "shipping_address": address,
            "expires_at": time.time() + 600,  # 10 min
            "product_title": variant.get("title", ""),
        }
    
        return {
            "quote_id": quote_id,
            "product": variant.get("title", ""),
            "quantity": quantity,
            "subtotal_usdc": subtotal,
            "shipping_usdc": shipping,
            "total_usdc": total_usdc,
            "payment_wallet": PAYMENT_WALLET,
            "network": "base",
            "token": "USDC",
            "token_contract": USDC_CONTRACT,
            "instructions": (
                f"Send exactly {total_usdc} USDC on Base network to {PAYMENT_WALLET}, "
                f"then call place_order with the transaction hash and this quote_id."
            ),
            "expires_in": "10 minutes",
        }

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/masonicGIT/shop-mcp-server'

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