Hi,
No, the code would have to be added as a plugin.
Here is a base code for the plugin you could write:
<?php
// Ensure that the cURL library is included
if (!function_exists('curl_init')) {
die('cURL is not installed!');
}
class plgHikashopOrderStatusUpdate extends JPlugin
{
public function onAfterOrderUpdate(&$order)
{
// Check if the order status has changed
if ($order->old->order_status != $order->order_status) {
// Set up cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/api/order_status_update");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "order_id={$order->order_id}&status={$order->order_status}");
// Send request and close cURL handle
curl_exec($ch);
curl_close($ch);
}
}
}
and the XML file of the plugin:
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.8" type="plugin" group="hikashop" method="upgrade">
<name>PLG_HIKASHOP_ORDERSTATUSUPDATE</name>
<author>Your Name</author>
<creationDate>January 2021</creationDate>
<copyright>Copyright (C) 2021 Your Company. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>you@example.com</authorEmail>
<authorUrl>http://www.example.com</authorUrl>
<version>1.0.0</version>
<description>Sends a cURL request to a server when the order status is updated in Hikashop.</description>
<files>
<filename plugin="orderstatusupdate">orderstatusupdate.php</filename>
</files>
<config>
</config>
</extension>
You can easily create the ZIP install file yourself once you write the code for the cURL request by following these steps:
Create a new directory on your computer and navigate to it.
Create a new text file called orderstatusupdate.php and paste the PHP code for the plugin into it.
Create a new text file called orderstatusupdate.xml and paste the XML code for the plugin into it.
Select both orderstatusupdate.php and orderstatusupdate.xml in your file explorer, right-click on them, and choose "Send to > Compressed (zipped) folder". This will create a new ZIP file called orderstatusupdate.zip containing both of the files.
You can then upload the ZIP file via the Joomla extensions installer to install the plugin and then publish it.