less than a minute read • Updated 9 minutes ago
Interact with the cart server-side
How to create and modify carts via server-side requests instead of browser-initiated links and forms.
In addition to standard browser-initiated cart links and forms, you can create and modify carts via server-side requests. This is useful when you have existing cart functionality on your own system and want to hand off to Foxy only for checkout, or when you need to construct carts programmatically before presenting them to the customer.
Two approaches
1. The /cart endpoint
The simplest approach. Make server-side requests to the /cart endpoint using the same parameters you would use in a standard cart link, with output=json so you can parse the response.
https://YOURSTORE.foxycart.com/cart?name=Product+Name&price=10.00&output=json
2. The Hypermedia API
The Foxy Hypermedia API (hAPI) offers more flexibility and functionality than the /cart endpoint. If you are already building against the hAPI for other parts of your integration, using a consistent approach may be preferable.
See the Foxy API documentation for details.
Common use case
The most common reason to interact with the cart server-side is if you already have cart functionality within your own system and want to use Foxy purely as a hosted checkout page. See Using Foxy without the cart for more on this approach.
Notes
Server-side requests to the
/cartendpoint must include a valid session ID to modify an existing customer session.For a full list of cart parameters, see Cart parameters reference.