Le API di commercioVirtuoso.it ti permettono di recuperare tutti gli ordini del tuo negozio in modo programmatico. In questa guida, ti mostreremo come utilizzare l’endpoint /api/v2/orders.json per ottenere tutti gli ordini.
Documentazione API e Sandbox
Puoi visualizzare la lista completa degli Endpoint API e una Sandbox per simulare le chiamate e le risposte direttamente accedendo a: https://api.commerciovirtuoso.it
Recupero degli Ordini
Per recuperare tutti gli ordini, dovrai effettuare una richiesta GET all’endpoint /api/v2/orders.json. Di seguito sono riportati i parametri che puoi utilizzare nella richiesta e un esempio di richiesta cURL.
Endpoint
				
					GET /api/v2/orders.json 
				
			
		| Nome Campo | Tipo | Descrizione | Valore Predefinito | Valori Disponibili | 
|---|---|---|---|---|
| page | integer | Restituisce una pagina specifica dei risultati. | 1 | |
| limit | integer | Restituisce fino a un massimo di risultati per pagina (massimo: 250). | 50 | |
| sort_by | string | Determina il parametro in base al quale gli ordini sono ordinati nella risposta. I parametri disponibili sono: id, orderName, sellerName, gateway, paymentStatus, fulfillment, trackingId, orderPrepareStatus, dateAdd. | id | id, orderName, sellerName, gateway, paymentStatus, fulfillment, trackingId, orderPrepareStatus, dateAdd | 
| sort_order | string | Determina l’ordine di ordinamento. Valori disponibili: 1) asc -> crescente, 2) desc -> decrescente. | desc | asc, desc | 
| filter | string | Cerca solo gli ordini con filtri: sellerId, sellerStoreName, paymentStatus, fulfillment, dateFrom, dateTo. Valori disponibili per payment_status: pending, voided, authorized, paid, partially_paid, refunded, partially_refunded. Valori disponibili per fulfillment: fulfilled, unfulfilled, partial, restocked. | 
Esempio di Corpo del Filtro
				
					{
  "payment_status": "paid",
  "fulfillment": "fulfilled",
  "date_from": "2020-01-01 01:59:59",
  "date_to": "2020-01-01 14:59:59"
} 
				
			
		Esempio di Richiesta
Ecco come fare una richiesta cURL per ottenere tutti gli ordini:
				
					curl -X GET "https://api.commerciovirtuoso.it/api/v2/orders.json?page=1&limit=50&sort_by=id&sort_order=desc" \
-H "accept: application/json" \
-H "Authorization: Bearer LA_TUA_CHIAVE_API" 
				
			
		Esempio di Risposta
La risposta conterrà un elenco di ordini con i dettagli di ciascun ordine. Ecco un esempio di risposta JSON:
“id” è l’ID dell’ordine venditore
“id_shop” è l’ID univoco del venditore
Sono Deprecati i valori: “main_id_order“, e “main_id_shop“.
				
					{
  "orders": [
    {
      "id": "101",
      "main_id_order": "101",
      "main_id_shop": "101",
      "id_shop": "101",
      "total_price": "101.101",
      "payment_status": "paid",
      "customer": "Test Customer",
      "gateway": "Test gateway",
      "order_name": "#101",
      "fulfillment": "fulfilled",
      "mp_shipping": "0",
      "customer_email": "testcustomer@example.com",
      "address1": "test address1",
      "address2": "test address2",
      "company": "test company",
      "city": "test city",
      "zip": "525653",
      "province": "Uttar Pradesh",
      "country": "India",
      "phone": "101",
      "billing_address": "test billing address",
      "shipping_address": "test shipping address",
      "date_add": "2050-09-08 07:58:02",
      "date_upd": "2050-09-08 07:58:02",
      "is_mail_sent": "1",
      "capture_payment_mail": "0",
      "order_placed_mail": "1",
      "is_deleted": "0",
      "order_note": "note",
      "delivery_method": "Delivery method",
      "is_nav_synced": "0",
      "transaction_id": "101",
      "order_prepare_status": "4",
      "main_transaction_id": "101",
      "ref_order_id": "0",
      "token": "54085206dffb86fabf8bf075e43faa90",
      "checkout_token": "",
      "is_paid": "1",
      "tax_inclusive": "0",
      "tax_shipping_comm_type": "{\"shipping_commission_rate\":\"3\",\"tax_commission_rate\":\"3\",\"shipping_commission_type\":\"1\",\"tax_commission_type\":\"1\"}",
      "is_cachable": "0",
      "fulfillment_service_name": "test service",
      "discount_code": "",
      "discount_details": "101",
      "discount_bear_by": "0",
      "commission_calculated_on": "0",
      "discount_difference": "0",
      "order_status_url": "https://permanent-store-url/61341656569/orders/540852000ffb855abf877075e43fa666/authenticate?key=7927344289891aebafa2d0303580625a",
      "fulfillment_earning_cost": "0",
      "is_refunded": "0",
      "gateway_processed": "1",
      "presentment_currency": "INR",
      "payment_flow": "0",
      "restrict_view_order": "0",
      "seller_global_fixed_commission": "0.00",
      "refunded_seller_global_fixed_commission": "0.00",
      "expected_delivery_date": "",
      "risk_recommendation": "",
      "risk_response": "",
      "tip_distribution": "2",
      "tip_amount": "0.00",
      "fixed_transaction_amount": "0.00",
      "percent_transaction_amount": "0.00",
      "transaction_fixed_charge_rule": "0",
      "transaction_bear_by": "0",
      "payment_gateway_fee": "0.00",
      "fee_bear_by": "0",
      "seller_earning_added": "1",
      "total_shipping_charges": "0.00",
      "line_items": [
        {
          "id": "101",
          "main_id_shop": "101",
          "seller_id": "101",
          "order_id": "101",
          "shopify_order_id": "",
          "order_product_id": "101",
          "product_id": "101",
          "shopify_product_id": "101",
          "shopify_variant_id": "101",
          "product_name": "Test",
          "variant_title": "Test / variant",
          "product_price": "101.00",
          "sku": "TESTSKU",
          "note_attribute": "[]",
          "line_discount": "0.00",
          "total_quantity": "1",
          "line_item_id": "101",
          "tax_type": "IGST",
          "tax_rate": "0.0000",
          "tax_type2": "event",
          "tax_rate2": "0.0000",
          "actual_shipping": "0.000",
          "actual_tax": "0.000",
          "unit_commission": "0.000",
          "shipping_commission": "0.000",
          "tax_commission": "0.000",
          "total_commission": "0.000",
          "id_commission_basis": "4",
          "id_commission_type": "1",
          "commission_values": "10.00,0.00",
          "status": "0",
          "cancel_reason_id": "",
          "ndr_awb_number": "",
          "is_returned": "0",
          "penalty_type": "0",
          "penalty_value": "0.0000",
          "shipping_type": "4",
          "shipping_label_link": "",
          "awb_created_as": "",
          "shipping_tax": "101.000",
          "fulfilled_shipping_method": "0",
          "is_store_pickup": "0",
          "fulfillment_location_id": "101",
          "date_add": "2050-07-19T22:05:32+00:00",
          "date_upd": "2050-07-19T22:05:32+00:00",
          "refund_commission": "0.000",
          "vat_type": "0",
          "vat": "0.00",
          "tracking_url": "https://tracking.example.com/",
          "total_actual_shipping": "101"
        }
      ]
    }
  ]
} 
				
			
		 
				 
															