I am trying to integrate the DHL eCommerce API with my Laravel. I have tried to crack the WordPress WooCommerce code and felt it is a waste of time. With my continuous effort, I cracked the code of OpenCart and got the code to create a shipment draft.But actually, I want to create the shipment label through APIs, but OpenCart does not provide this feature, and WooCommerce has it. Could anyone help me?
Available documentation of DHL API integration Manual_WooCommerce_plug-in_EN.pdf
Just to be clear,
- We already have an admin panel for our ecommerce website made with Laravel. So, I don’t need another admin panel made with WordPress.
- The first option, If anyone can provide code for laravel without WordPress, it will be great.
- Second option, I am looking to, I can insert the data of orders to WordPress database and call the DHL label create function from my Laravel code, and after creating the label, I will empty the entries I inserted into the database to save memory. This is a stupid option if nothing works due to the lack of documentation available online. Because I am not a WordPress expert, could anyone help me?
Cracked sample code from opencart below, and please help me to create CreateShipmentLabel
function
<?php
class ControllerExtensionShippingDhlparcel
{
private $db;
private $url = "https://connector.dhlparcel.nl/api/V2/webhook/.............";
public function __construct()
{
$this->db = new mysqli('localhost', 'root', '', 'opencart');
}
public function webhook($orderStatusId = 2)
{
$order = $this->getOrder(1);
$data_string = json_encode($order);
$ch = curl_init($this->url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch,CURLOPT_HTTPHEADER,
[
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'dhlparcel-connector: opencart',
]
);
curl_exec($ch);
}
public function getOrder(int $order_id): array
{
return $shipment_data;
}
public function CreateShipmentLabel(){
// please help me create this function
}
}
$model = new ControllerExtensionShippingDhlparcel();
$model->webhook();