### Get Customer Response Example (with data) Source: https://docs.simpler.so/api/get-customer Example of a Get Customer API response with actual customer data. ```json { "request_id": "d1280b05-ca5c-4af2-8dcb-6ae81572dcba", "customer": { "first_name": "John", "last_name": "Doe", "email": "test@simpler.so" }, "addresses": [ { "first_name": "John", "last_name": "Doe", "phone": "+4412345678", "street": "128 City Road", "city": "London", "postcode": "EC1V 2NX", "country": "GB" } ], "loyalty_profile": { "member_since": "2025-05-01", "current_points_balance": 1500, "tier": "Platinum" } } ``` -------------------------------- ### C# HttpClient Example for Products Feed Source: https://docs.simpler.so/api/get-products-feed Demonstrates how to use HttpClient in C# to make a GET request to the products feed endpoint. Includes setting the Accept and X-Simpler-CRC headers. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.myonlinestore.com/simpler/v1/products/feed"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Simpler-CRC", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Example Source: https://docs.simpler.so/api/pickup-stores Demonstrates how to make a GET request to the store pickup API using C#'s HttpClient. Ensure to include the 'Accept' and 'X-Simpler-CRC' headers. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.myonlinestore.com/simpler/v1/stores"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Simpler-CRC", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Customer Request Body Example (from schema) Source: https://docs.simpler.so/api/get-customer Example of the JSON body for the Get Customer API request, as defined by the schema. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "email": "string", "session_id": "string" } ``` -------------------------------- ### HTTP POST Request Example Source: https://docs.simpler.so/api/get-customer Example of an HTTP POST request to the Get Customer endpoint using HttpClient in C#. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.myonlinestore.com/simpler/v1/customer"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Simpler-CRC", ""); var content = new StringContent("{\n \"request_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"email\": \"string\",\n \"session_id\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Example for Get Orders Source: https://docs.simpler.so/api/get-orders Demonstrates how to use HttpClient in C# to make a POST request to the Get Orders API. Includes setting headers and request body. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.myonlinestore.com/simpler/v1/reporting"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Simpler-CRC", ""); var content = new StringContent("{\n \"request_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"from\": \"string\",\n \"pageLimit\": 0,\n \"currentPage\": 0\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Products API Request Body Example Source: https://docs.simpler.so/api/get-product-details This example demonstrates the structure of a valid JSON request body for the Get Products API. It includes required fields like request_id, currency, and items, along with optional attributes. ```json { "request_id": "af4ebaa6-7f47-4163-85af-d5b82a8cf4b0", "currency": "USD", "items": [ { "id": "product-id-1", "quantity": 1, "attributes": { "attr_color": "val_black" } } ] } ``` -------------------------------- ### Get Customer Request Body Example Source: https://docs.simpler.so/api/get-customer Example of the JSON body required for the Get Customer API request. ```json { "request_id": "d1280b05-ca5c-4af2-8dcb-6ae81572dcba", "email": "test@simpler.so", "session_id": "sess_b609d893-a2eb-40ff-939e-7b46cd52f1fa" } ``` -------------------------------- ### Get Orders Response Example with Data Source: https://docs.simpler.so/api/get-orders An example of a populated response from the Get Orders API, showing actual order details and pagination. ```json { "request_id": "fdde53a4-4d6d-4de5-b3e1-e3d5fe2a9c03", "total_pages": 12, "items": [ { "order_id": 29, "payment_method": "Simpler Checkout", "is_guest": true, "country_code": "GR", "cart_size": 1, "total_paid": 36.46, "created_at": "2023-09-13 11:53:11" }, { "order_id": 40, "payment_method": "GPAY", "is_guest": false, "country_code": "FR", "cart_size": 4, "total_paid": 108.3, "created_at": "2023-12-13 05:12:11" } ] } ``` -------------------------------- ### Get Customer Response Schema Example Source: https://docs.simpler.so/api/get-customer Example of the JSON schema for a successful Get Customer API response. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "customer": { "first_name": "string", "last_name": "string", "email": "string" }, "addresses": [ { "first_name": "string", "last_name": "string", "phone": "string", "street": "string", "city": "string", "postcode": "string", "region": "string", "country": "string", "notes": "string", "dni": "string" } ], "loyalty_profile": { "member_since": "2024-07-29", "current_points_balance": 0, "tier": "string" } } ``` -------------------------------- ### Example Product Response (Nike Air Max 90) Source: https://docs.simpler.so/api/get-products-feed This is an example of a product response for a shoe, including details like stock, SKU, description, image URL, price, shipping status, categories, and variations. ```json { "id": "123456", "title": "Nike Air Max 90", "stock": 15, "sku": "NIKE-AM90-BLK-42", "description": "Comfortable running shoe with visible Air cushioning.", "image_url": "https://www.mystore.com/assets/img/nike-air-max-90.jpg", "price_cents": 2000, "shippable": true, "categories": [ "Shoes", "Running Shoes" ], "url": "https://www.mystore.com/products/hyperion-elements-jacket", "variations": [ { "id": "123456", "title": "Nike Air Max 90", "stock": 15, "sku": "NIKE-AM90-BLK-42", "description": "Comfortable running shoe with visible Air cushioning.", "image_url": "https://www.mystore.com/assets/img/nike-air-max-90.jpg", "price_cents": 2000, "shippable": true, "categories": [ "Shoes", "Running Shoes" ], "attributes": { "Size": "XL", "Color": "White" } } ], "options": [ { "id": "string", "title": "string", "values": [ { "id": "string", "title": "string" } ] } ] } ``` -------------------------------- ### Bad Request - Out of Stock Example Source: https://docs.simpler.so/api/get-quotation This example illustrates a bad request response specifically for an 'OUT_OF_STOCK_PRODUCT' error, detailing the product that is unavailable. ```json { "message": "Product 'product-id-1' is out of stock", "code": "OUT_OF_STOCK_PRODUCT" } ``` -------------------------------- ### Product Details Example Response Source: https://docs.simpler.so/api/get-product-details This is an example of a successful API response for product details. It includes specific product information, available options, and variations with their respective attributes. ```json { "request_id": "af4ebaa6-7f47-4163-85af-d5b82a8cf4b0", "items": [ { "id": "123456", "sku": "product-id-2", "title": "Product 2", "description": "Product 2 description", "image_url": "https://www.mystore/com/assets/img/product-2.jpg", "stock": 3, "price_cents": 2000, "shippable": true, "options": [ { "id": "attr_color", "title": "Color", "values": [ { "id": "val_black", "title": "Black" }, { "id": "val_white", "title": "White" } ] }, { "id": "attr_size", "title": "Size", "values": [ { "id": "val_s", "title": "S" }, { "id": "val_m", "title": "M" } ] } ], "variations": [ { "id": "1234567", "sku": "product-id-2-1", "title": "Product 2-1", "stock": 2, "description": "Product 2-1 description", "image_url": "https://www.mystore/com/assets/img/product-2-1.jpg", "price_cents": 2200, "shippable": true, "attributes": { "attr_size": "val_s", "attr_color": "val_black" } }, { "id": "12345678", ``` -------------------------------- ### Get Orders Request Body Example Source: https://docs.simpler.so/api/get-orders Example of a request body for fetching order data. Includes required fields like request_id, from, pageLimit, and currentPage. ```json { "request_id": "2b605b36-8643-4b3f-af14-9496014f65cb", "from": "2023-09-02 15:04:05", "pageLimit": 10, "currentPage": 2 } ``` -------------------------------- ### Install Simpler Checkout Hyvä Module Source: https://docs.simpler.so/guides/integrations/magento/hyva-theme Install the Hyvä compatibility package alongside the base module using Composer and enable it. ```bash composer require simpler/magento-checkout-hyva bin/magento module:enable Simpler_CheckoutHyva bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy bin/magento cache:clean ``` -------------------------------- ### Example Product Response (Basic T-Shirt) Source: https://docs.simpler.so/api/get-products-feed An example response for a basic apparel item, showing standard product details like ID, SKU, title, description, image, stock, price, shipping, categories, and URL. ```json { "id": "789012", "sku": "BASIC-TEE-BLK", "title": "Basic T-Shirt Black", "description": "A comfortable everyday cotton t-shirt in black.", "image_url": "https://www.mystore.com/assets/img/basic-tee-black.jpg", "stock": 50, "price_cents": 1999, "shippable": true, "categories": [ "Apparel", "T-Shirts" ], "url": "https://www.mystore.com/products/basic-tee-black" } ``` -------------------------------- ### Install Simpler Checkout Magento 2 Module Source: https://docs.simpler.so/guides/integrations/magento/installation Install the Simpler Checkout module using Composer and run Magento setup commands. ```bash composer require simpler/magento-checkout bin/magento module:enable Simpler_Checkout bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy # optional but highly suggested bin/magento cache:clean ``` -------------------------------- ### Product Schema Example Source: https://docs.simpler.so/api/get-products-feed This is an example of a single product object within the products feed. It includes basic product information like ID, title, stock, SKU, description, image URL, price, shippable status, categories, and URL. ```json { "id": "123456", "title": "Nike Air Max 90", "stock": 15, "sku": "NIKE-AM90-BLK-42", "description": "Comfortable running shoe with visible Air cushioning.", "image_url": "https://www.mystore.com/assets/img/nike-air-max-90.jpg", "price_cents": 2000, "shippable": true, "categories": [ "Shoes", "Running Shoes" ], "url": "https://www.mystore.com/products/hyperion-elements-jacket" } ``` -------------------------------- ### Product Variations Schema Example Source: https://docs.simpler.so/api/get-products-feed This example demonstrates how product variations are represented. Each variation can have its own ID, title, stock, SKU, description, image URL, price, shippable status, categories, and specific attributes. ```json { "id": "123456", "title": "Nike Air Max 90", "stock": 15, "sku": "NIKE-AM90-BLK-42", "description": "Comfortable running shoe with visible Air cushioning.", "image_url": "https://www.mystore.com/assets/img/nike-air-max-90.jpg", "price_cents": 2000, "shippable": true, "categories": [ "Shoes", "Running Shoes" ], "attributes": { "1": "34" } } ``` -------------------------------- ### Product Request JSON Body Example Source: https://docs.simpler.so/api/get-product-details This is an example of the JSON payload required for product-related POST requests. It includes fields for request ID, currency, metadata, and item details with attributes. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "currency": "EUR", "metadata": [ { "key": "string", "value": "string" } ], "items": [ { "id": "string", "quantity": 0, "attributes": { "Size": "XL", "Color": "White" } } ] } ``` -------------------------------- ### Example Store Pickup Response Source: https://docs.simpler.so/api/pickup-stores Provides concrete examples of the JSON response structure for the store pickup API, demonstrating different strategies ('append', 'expand', 'merge') and optional fields like country codes and store IDs. ```json [ { "strategy": "append", "title": "Title", "stores": [ { "id": "1", "title": "Store 1" }, { "id": "2", "title": "Store 2", "country_codes": [ "GR", "CY" ] }, { "id": "3", "title": "Store 3 (GR, store view 1 only)", "country_codes": [ "GR" ], "store_ids": [ "1" ] } ] }, { "strategy": "expand", "shipping_id": "Parent Id", "title": "Title 2", "stores": [ { "id": "4", "title": "Store 4" }, { "id": "5", "title": "Store 5" } ] }, { "strategy": "merge", "stores": [ { "id": "6", "title": "Store 6" } ] } ] ``` -------------------------------- ### Example Product Response (Hyperion Elements Jacket) Source: https://docs.simpler.so/api/get-products-feed This response details a jacket product, including its options for color and size, and specific variations with their own SKUs and attributes. ```json { "id": "123456", "sku": "HEJ-JACKET", "title": "Hyperion Elements Jacket", "description": "Lightweight jacket with wind resistance.", "image_url": "https://www.mystore.com/assets/img/hej-jacket.jpg", "stock": 3, "price_cents": 5100, "shippable": true, "categories": [ "Apparel", "Jackets" ], "url": "https://www.mystore.com/products/hej-jacket", "options": [ { "id": "attr_color", "title": "Color", "values": [ { "id": "val_black", "title": "Black" }, { "id": "val_white", "title": "White" } ] }, { "id": "attr_size", "title": "Size", "values": [ { "id": "val_s", "title": "S" }, { "id": "val_m", "title": "M" } ] } ], "variations": [ { "id": "1234567", "sku": "HEJ-JACKET-S-BLK", "title": "Hyperion Elements Jacket - S / Black", "stock": 2, "description": "Lightweight jacket with wind resistance. Size S, Black.", "image_url": "https://www.mystore.com/assets/img/hej-jacket-s-black.jpg", "price_cents": 5100, "shippable": true, "attributes": { "attr_size": "val_s", "attr_color": "val_black" } }, { "id": "12345678", "sku": "HEJ-JACKET-M-BLK", "title": "Hyperion Elements Jacket - M / Black", "stock": 3, "description": "Lightweight jacket with wind resistance. Size M, Black.", "image_url": "https://www.mystore.com/assets/img/hej-jacket-m-black.jpg", "price_cents": 5100, "shippable": true, "attributes": { "attr_size": "val_m", "attr_color": "val_black" } }, { "id": "123456789", "sku": "HEJ-JACKET-S-WHT", "title": "Hyperion Elements Jacket - S / White", "stock": 0, "description": "Lightweight jacket with wind resistance. Size S, White.", "image_url": "https://www.mystore.com/assets/img/hej-jacket-s-white.jpg", "price_cents": 5100, "shippable": true, "attributes": { "attr_size": "val_s", "attr_color": "val_white" } } ] } ``` -------------------------------- ### Get Orders Request Body Example (Schema) Source: https://docs.simpler.so/api/get-orders A basic example of the request body structure for the Get Orders API, as defined by the schema. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "from": "string", "pageLimit": 0, "currentPage": 0 } ``` -------------------------------- ### C# HttpClient Example for Product Request Source: https://docs.simpler.so/api/get-product-details This snippet demonstrates how to make a POST request to the product endpoint using HttpClient in C#. It includes setting the necessary headers like Accept and X-Simpler-CRC, and constructing the JSON request body. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.myonlinestore.com/simpler/v1/products"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Simpler-CRC", ""); var content = new StringContent("{\n \"request_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"currency\": \"EUR\",\n \"metadata\": [\n {\n \"key\": \"string\",\n \"value\": \"string\"\n }\n ],\n \"items\": [\n {\n \"id\": \"string\",\n \"quantity\": 0,\n \"attributes\": {\n \"Size\": \"XL\",\n \"Color\": \"White\"\n }\n }\n ]\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Quotation Request Body Example Source: https://docs.simpler.so/api/get-quotation This is an example of the JSON request body required for the Get Quotation endpoint. It includes details for the quotation, shipping, and invoice. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "metadata": [ { "key": "string", "value": "string" } ], "quotation": { "items": [ { "id": "string", "quantity": 0, "attributes": { "Size": "XL", "Color": "White" } } ], "currency": "EUR", "ship_to": { "first_name": "string", "last_name": "string", "phone": "string", "street": "string", "city": "string", "postcode": "string", "region": "string", "country": "string", "notes": "string" }, "email": "user@example.com", "coupon": "string", "invoice": { "tax_id": "123456789", "company_name": "Acme Corp S.A.", "activity": "Retail Trade", "tax_authority": "Athens IRS", "company_address": "123 Commerce St, Athens, 10431, Greece" } } } ``` -------------------------------- ### Get Orders Response Schema Example Source: https://docs.simpler.so/api/get-orders Example of the response schema for the Get Orders API, detailing the structure of the returned order items and pagination information. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "items": [ { "simpler_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "order_id": "string", "payment_method": "string", "is_guest": true, "country_code": "string", "cart_size": 0, "total_paid": 0, "created_at": "string" } ], "total_pages": 0 } ``` -------------------------------- ### Example Product Response (Nike Air Max 90 with Attributes) Source: https://docs.simpler.so/api/get-products-feed This response includes attributes and titled attributes for a product, demonstrating how specific characteristics like size and color are represented. ```json { "id": "123456", "title": "Nike Air Max 90", "stock": 15, "sku": "NIKE-AM90-BLK-42", "description": "Comfortable running shoe with visible Air cushioning.", "image_url": "https://www.mystore.com/assets/img/nike-air-max-90.jpg", "price_cents": 2000, "shippable": true, "categories": [ "Shoes", "Running Shoes" ], "url": "https://www.mystore.com/products/basic-tee-black", "attributes": { "Size": "XL", "Color": "White" }, "titled_attributes": { "Size": "XL", "Color": "White" } } ``` -------------------------------- ### Pickup Stores Controller Example Source: https://docs.simpler.so/guides/interface/tutorials/pickup-stores This PHP controller demonstrates how to structure the response for the Pickup Stores API, including different strategies like 'append', 'expand', and 'merge'. ```php class SimplerPickupStoresController extends AbstractController { public function getData(Request $request): Response { $response = [ [ "strategy" => "append", "title" => "Title", "stores" => [ [ "id" => "1", "title" => "store 1" ], [ "id" => "2", "title" => "store 2" ] ] ], [ "strategy" => "expand", "shippingId" => "parent", "title" => "Title 2", "stores" => [ [ "id" => "3", "title" => "store 3" ], [ "id" => "4", "title" => "store 4" ] ] ], [ "strategy" => "merge", "stores" => [ [ "id" => "5", "title" => "store 5" ] ] ] ]; return $this->json($response); } } ``` -------------------------------- ### Get Quotation API Response Example Source: https://docs.simpler.so/api/get-quotation This JSON object represents a successful response from the Get Quotation API, detailing all aspects of a quote. ```json { "request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "quotes": [ { "items": [ { "id": "string", "quantity": 0, "attributes": { "Size": "XL", "Color": "White" }, "subtotal_net_cents": 0, "subtotal_tax_cents": 0, "subtotal_cents": 0, "cost_net_cents": 0, "cost_tax_cents": 0, "cost_cents": 0 } ], "shipping_option": { "id": "string", "name": "string", "type": "LOCAL_PICKUP", "net_cents": 0, "tax_cents": 0, "total_cents": 0 }, "total_cents": 0, "discount_cents": 0, "fees": [ { "title": "string", "cost_cents": 0 } ], "payment_methods": [ { "id": "string", "name": "string", "type": "COD", "net_cents": 0, "tax_cents": 0, "total_cents": 0 } ], "loyalty_profile": { "external_id": "string", "available_coupons": [ { "code": "string", "description": "string", "expires": "2024-07-29", "discount_cents": 0, "metadata": {} } ], "metadata": {} }, "addons": [ { "type": "GIFT_WRAP", "options": [ { "id": "string", "net_cents": 0, "tax_cents": 0, "total_cents": 0 } ] } ] } ] } ``` -------------------------------- ### Partial Get Quotation API Response Example Source: https://docs.simpler.so/api/get-quotation This JSON object shows a partial response from the Get Quotation API, focusing on item details within a quote. ```json { "request_id": "af4ebaa6-7f47-4163-85af-d5b82a8cf4b0", "quotes": [ { "items": [ { "id": "product-id-1", "quantity": 1, "subtotal_net_cents": 800 ``` -------------------------------- ### Simple Product Example Source: https://docs.simpler.so/guides/interface/tutorials/product-feed This JSON object represents a single, standalone product in the feed. Ensure all required fields are present and correctly formatted. ```json { "products": [ { "id": "789012", "sku": "BASIC-TEE-BLK", "title": "Basic T-Shirt Black", "description": "A comfortable everyday cotton t-shirt in black.", "image_url": "https://www.mystore.com/assets/img/basic-tee-black.jpg", "stock": 50, "price_cents": 1999, "shippable": true, "categories": ["Apparel", "T-Shirts"], "url": "https://www.mystore.com/products/basic-tee-black" } ] } ``` -------------------------------- ### C# HttpClient Example for Get Quotation Source: https://docs.simpler.so/api/get-quotation Demonstrates how to make a POST request to the Get Quotation endpoint using HttpClient in C#. Ensure the X-Simpler-CRC header is correctly set. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.myonlinestore.com/simpler/v1/quote"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Simpler-CRC", ""); var content = new StringContent("{\n \"request_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"metadata\": [\n {\n \"key\": \"string\",\n \"value\": \"string\"\n }\n ],\n \"quotation\": {\n \"items\": [\n {\n \"id\": \"string\",\n \"quantity\": 0,\n \"attributes\": {\n \"Size\": \"XL\",\n \"Color\": \"White\"\n }\n }\n ],\n \"currency\": \"EUR\",\n \"ship_to\": {\n \"first_name\": \"string\",\n \"last_name\": \"string\",\n \"phone\": \"string\",\n \"street\": \"string\",\n \"city\": \"string\",\n \"postcode\": \"string\",\n \"region\": \"string\",\n \"country\": \"string\",\n \"notes\": \"string\"\n },\n \"email\": \"user@example.com\",\n \"coupon\": \"string\",\n \"invoice\": {\n \"tax_id\": \"123456789\",\n \"company_name\": \"Acme Corp S.A.\",\n \"activity\": \"Retail Trade\",\n \"tax_authority\": \"Athens IRS\",\n \"company_address\": \"123 Commerce St, Athens, 10431, Greece\"\n }\n }\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Quotation Request Example Source: https://docs.simpler.so/api/get-quotation This example demonstrates the structure of a JSON request body to obtain a quotation for a shopping cart. It includes item details, shipping information, and optional coupon codes. ```json { "request_id": "af4ebaa6-7f47-4163-85af-d5b82a8cf4b0", "metadata": [ { "key": "website id", "value": "1" } ], "quotation": { "currency": "EUR", "items": [ { "id": "product-id-1", "quantity": 1 }, { "id": "product-id-1", "quantity": 1, "attributes": { "attr_color": "black" } } ], "coupon": "CouponCode", "ship_to": { "first_name": "John", "last_name": "Doe", "phone": "00301234567890", "street": "Vasilissis Sofias 2", "city": "Athens", "postcode": "10021", "region": "Attica", "country": "GR", "notes": "Please give me a phone call 30' prior to delivery" } } } ``` -------------------------------- ### Apply Discounts for Returning Customers Source: https://docs.simpler.so/guides/interface/tutorials/discounts This snippet demonstrates how to apply discounts for returning customers by using their email address to retrieve customer data and set it on the cart. The `calculateTotals` method should then account for customer-specific discounts. ```php class SimplerQuoteController extends AbstractController { public function postData(Request $request): Response { $requestData = json_decode($request->getContent(), true); $response = [ 'request_id' => $requestData['request_id'], 'quotes' => [] ]; $cart = CartService::createCart(); if ($email = $request['quotation']['email']) { $customer = CustomerService::getByEmail($email); if ($customer) { $cart->setCustomerId($customer->id); } } try { $this->addQuotationItemsToCart($request['quotation']['items'], $cart); if ($coupon = $request['quotation']['coupon']) { $this->applyCoupon($coupon, $cart); } $shippingAddress = $request['quotation']['address']; $options = ShippingService::getShippingOptions($cart, $shippingAddress); foreach ($options as $option) { $cart->setSelectedShippingOption($option); // your calculateTotals method should take into account the customer and apply the discount // if this is not the case you can use the `customer` record to calculate the total discount in a separate function $cart->calculateTotals(); $response['quotes'][] = $this->buildQuote($cart, $option); } return $this->json($response); } finally { $cart->delete(); } } } ``` -------------------------------- ### Retrieve Pricing and Format Response Source: https://docs.simpler.so/guides/interface/tutorials/basic-flow This controller extends the previous example by retrieving pricing information from the cart and formatting the response. It ensures monetary values are handled precisely in cents. ```php class SimplerQuoteController extends AbstractController { public function postData(Request $request): Response { $requestData = json_decode($request->getContent(), true); // let's initialize our response $response = [ 'request_id' => $requestData['request_id'], // we'll be returning a single quote for this example 'quotes' => [ [ 'items' => [] ] ] ]; $cart = CartService::createCart(); try { $this->addQuotationItemsToCart($requestData['quotation']['items'], $cart); // now that we've have a cart with the requested items, retrieve the resolved line items to build the response $response = $this->addLineItemsToResponse($cart->getLineItems(), $response, $cart->getGrandTotal()); // build our response json, and we're done return $this->json($response); } finally { $cart->delete(); } } private function addLineItemsToResponse($lineItems, $response, $grandTotal) { foreach ($lineItems as $item) { $response['quotes'][0]['items'][] = [ 'id' => $item->getProduct()->getSKU(), 'quantity' => $item->getQuantity(), 'subtotal_cents' => $item->getTotalCost(), ]; } $response['total_cents'] = $grandTotal; return $response; } } ``` -------------------------------- ### Example Product Feed Response Source: https://docs.simpler.so/api/get-products-feed This JSON structure represents a typical response from the get products feed API, detailing product information including title, stock, description, image URL, price, shipping availability, and attributes. ```json { "products": [ { "id": "9876543210", "sku": "HEJ-JACKET-S-WHT", "title": "Hyperion Elements Jacket - S / White", "stock": 0, "description": "Lightweight jacket with wind resistance. Size S, White.", "image_url": "https://www.mystore.com/assets/img/hej-jacket-s-white.jpg", "price_cents": 5300, "shippable": true, "attributes": { "attr_size": "val_s", "attr_color": "val_white" } }, { "id": "1234567890", "sku": "HEJ-JACKET-M-WHT", "title": "Hyperion Elements Jacket - M / White", "stock": 0, "description": "Lightweight jacket with wind resistance. Size M, White.", "image_url": "https://www.mystore.com/assets/img/hej-jacket-m-white.jpg", "price_cents": 5300, "shippable": true, "attributes": { "attr_size": "val_m", "attr_color": "val_white" } } ] } ``` -------------------------------- ### Initialize Simpler Quick Buy Button Source: https://docs.simpler.so/guides/interface/tutorials/basic-flow Instantiate the Simpler Quick Buy Button using the Simpler singleton within a script tag on your product page. Ensure the DOM is loaded before execution. This script targets a specific container for the button. ```javascript window.addEventListener('DOMContentLoaded', () => { Simpler.checkout({ appId: 'YOUR_SIMPLER_APP_ID', currency: 'EUR', items: [{ id: '', quantity: 1 }], target: document.getElementById('simpler-checkout-container') }); }) ``` -------------------------------- ### Handle Simpler Product Details Request Source: https://docs.simpler.so/guides/interface/tutorials/basic-flow Implement a controller to handle requests from the Simpler platform for product details. This controller decodes the request, fetches product information using CatalogService, and formats it according to the Platform Interface API. ```php class SimplerProductsController extends AbstractController { public function postData(Request $request): Response { $requestData = json_decode($request->getContent(), true); $response = [ 'request_id' => $requestData['request_id'], 'items' => [] ]; foreach ($requestData['items'] as $item) { try { $product = CatalogService::getProductBySKU($item['id']); $response['items'][] = [ 'id' => $product->getSKU(), 'title' => $product->getTitle(), 'description' => $product->getDescription(), 'image_url' => $product->getImageURL(), 'shippable' => $product->requiresShipping() ]; } catch (ProductNotFoundException $e) { return new JsonResponse([ 'code' => 'PRODUCT_NOT_FOUND', 'message' => 'The product was not found' ], 400); } } return $this->json($response); } } ``` -------------------------------- ### Error Response Example Source: https://docs.simpler.so/api/refund-order This example shows the JSON structure for an error response from the refund API, indicating a missing required property. ```json { "error": "missing required property order_id" } ``` -------------------------------- ### Bad Request - Schema Example Source: https://docs.simpler.so/api/get-quotation This example shows the structure of a bad request response, including a request ID, a message, and an error code. ```json { "request_id": "string", "message": "string", "code": "INAPPLICABLE_COUPON" } ``` -------------------------------- ### Successful Quotation Response Example Source: https://docs.simpler.so/api/get-quotation This is an example of a successful response when a quotation is generated. It includes details about items, shipping, fees, discounts, and addons. ```json { "quotations": [ { "items": [ { "id": "product-id-1", "quantity": 1, "subtotal_net_cents": 800, "subtotal_tax_cents": 200, "subtotal_cents": 1000, "cost_net_cents": 700, "cost_tax_cents": 200, "cost_cents": 900 } ], "shipping_option": { "id": "ups-courier", "type": "DELIVERY", "name": "UPS courier (2-3 working days)", "net_cents": 400, "tax_cents": 100, "total_cents": 500 }, "fees": [ { "title": "Last pieces", "cost_cents": -200 } ], "total_cents": 1200, "discount_cents": 100, "addons": [ { "type": "GIFT_WRAP", "options": [ { "id": "fancy", "net_cents": 100, "tax_cents": 0, "total_cents": 100 }, { "id": "basic", "net_cents": 50, "tax_cents": 5, "total_cents": 55 } ] } ] }, { "items": [ { "id": "product-id-1", "quantity": 1, "subtotal_net_cents": 800, "subtotal_tax_cents": 200, "subtotal_cents": 1000, "cost_net_cents": 700, "cost_tax_cents": 200, "cost_cents": 900 } ], "shipping_option": { "id": "same-day-delivery", "type": "DELIVERY", "name": "Same day delivery", "net_cents": 800, "tax_cents": 200, "total_cents": 1000 }, "fees": [ { "title": "Last pieces", "cost_cents": -200 } ], "total_cents": 1700, "discount_cents": 100, "addons": [ { "type": "GIFT_WRAP", "options": [ { "id": "fancy", "net_cents": 100, "tax_cents": 0, "total_cents": 100 }, { "id": "basic", "net_cents": 50, "tax_cents": 5, "total_cents": 55 } ] } ] } ] } ```