How to use plugin API’s

WPCargo API addon provides four functionalities such as add, update, view all, and track shipment through API.

To view all shipments using API use this URl: http://www.mysite.com/wp-json/wpcargo/v1/api/my-api-key-here/

To Track shipment using API use this URI: http://www.mysite.com/wp-json/wpcargo/v1/api/my-api-key-here/shipment/track/my-shipmentnumber-to-track

To view available shipment fields with field type and field options (select, radio, checkbox, multiselect) using API use this URI: http://www.mysite.com/wp-json/wpcargo/v1/api/my-api-key-here/shipment/fields

HOW TO ADD SHIPMENT USING API

Use this sample code to add shipment using API

Note: Use the correct keys for to avoid fail in updating of shipments:

  • shipment_images – Shipment images in POD
  • wpcargo_status – Shipment Status
  • If the shipment already exist the form submission will be failed to submit.

	<form action="http://www.mysite.com/wp-json/wpcargo/v1/api/my-api-key-here/shipment/add/" method="post" enctype="multipart/form-data" >
	    Images: <input type="file" name="shipment_images[]" multiple="multiple" /><br/>
	    Shipment Number: <input type="text" name="shipment" value="" /><br/>
	    Shipper Name: <input type="text" name="wpcargo_shipper_name" value="" /><br/>
	    Shipper Status: <input type="text" name="wpcargo_status" value="" /><br/>
	    <input type="submit" value="Submit Shipment" />
	</form>

	

This will response array after form submission.
Example reponse: {“id”:”shipmentID”,”message”:”Shipment Updated”,”status”:”success”,”upload_error”:[“No Shipment Images was uploaded.”],”attachment”:[]}

 

HOW TO UPDATE SHIPMENT USING API

Use this sample code to update shipment using API

Note: Use the correct keys for to avoid fail in updating of shipments:

  • shipment – Shipment number. This is the most important field, it is the basis which shipment to be update.
  • shipment_images – Shipment images in POD
  • wpcargo_status – Shipment Status
	<form action="http://www.mysite.com/wp-json/wpcargo/v1/api/my-api-key-here/shipment/update" method="post" enctype="multipart/form-data">
	    <p>Images: <input type="file" name="shipment_images[]" multiple="multiple" /></p>
	    <p>Shipment Number: <input type="text" name="shipment" value="" /></p>
	    <p>Shipper Name: <input type="text" name="wpcargo_shipper_name" value="" /></p>
	    <p>Shipper Status: <input type="text" name="wpcargo_status" value="" /></p>
	    <input type="submit" value="Update Shipment" />
	</form>
	

HOW TO UPDATE SHIPMENT PACKAGES USING API

Note: Use the correct keys for to avoid fail in updating of shipments:

  • shipment – Shipment number. This is the most important field, it is the basis which shipment to be update.
  • wpc-multiple-package – field name for Shipment Packages
	<form action="http://www.mysite.com/wp-json/wpcargo/v1/api/uub7t8xpe4yKZRi3AEENuA9Qtp/shipment/update" method="post" enctype="multipart/form-data">
		<p>Shipment Number: <input type="text" name="shipment" value="" /></p>    
	    <div>
	    	<table class="table table-hover table-sm">
				<thead>
					<tr class="text-center">
					<th><strong>Qty.</strong></th>
					<th><strong>Piece Type</strong></th>
					<th><strong>Description</strong></th>
					<th><strong>Length(cm)</strong></th>
					<th><strong>Width(cm)</strong></th>
					<th><strong>Height(cm)</strong></th>
					<th><strong>Weight (kg)</strong></th>
					<th><strong>Value (£)</strong></th>
					</tr>
				</thead>
				<tbody data-repeater-list="wpc-multiple-package">
					<tr data-repeater-item="">
						<td>
							<input class="form-control" type="number" name="wpc-multiple-package[0][wpc-pm-qty]" value="">
						</td>
						<td>
							<select class="form-control browser-default custom-select" name="wpc-multiple-package[0][wpc-pm-piece-type]"><option value="">-- Select Type --</option><option value="Document">Document</option><option value="Parcel">Parcel</option></select>
						</td>
						<td>
							<textarea class="form-control" name="wpc-multiple-package[0][wpc-pm-description]"></textarea>
						</td>
						<td>
							<input class="form-control" type="number" name="wpc-multiple-package[0][wpc-pm-length]" value="">
						</td>
						<td>
							<input class="form-control" type="number" name="wpc-multiple-package[0][wpc-pm-width]" value="">
						</td>
						<td>
							<input class="form-control" type="number" name="wpc-multiple-package[0][wpc-pm-height]" value="">
						</td>
						<td>
							<input class="form-control" type="number" name="wpc-multiple-package[0][wpc-pm-weight]" value="">
						</td>
						<td>
							<input class="form-control" type="text" name="wpc-multiple-package[0][wpc-pm-value]" value="">
						</td>
					</tr>
				</tbody>
			</table>
	    </div>
	    <input type="submit" value="Update Shipment" />
	</form>
	
0
    0
    Your Cart
    Your cart is emptyReturn to Shop