Hi,
You can indeed implement the onBeforeOrderCreate event in a custom plugin to change the value of order_shipping_method dynamically during the order creation.
To do that, you need to create your own Joomla plugin of the group "hikashop".
A joomla plugin has two files:
- a PHP file to implement ( for example changeshippingmethod.php )
- a XML file to define it (for example changeshippingmethod.xml )
And both in a zip you can install through the Joomla extensions installer screen.
Here is an example for the PHP file:
<?php
// No direct access
defined('_JEXEC') or die;
class plgHikashopChangeShippingMethod extends JPlugin
{
public function onBeforeOrderCreate(&$order, &$do)
{
// Update the shipping method for the order
$order->order_shipping_method = 'my_shipping_method';
}
}
And for example the XML file:
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="hikashop" method="upgrade">
<name>PLG_HIKASHOP_CHANGESHIPPINGMETHOD</name>
<author>Your Name</author>
<creationDate>January 2021</creationDate>
<copyright>Copyright (C) 2021 Your Name. All rights reserved.</copyright>
<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
<authorEmail>your@email.com</authorEmail>
<authorUrl>https://yourwebsite.com</authorUrl>
<version>1.0.0</version>
<description>PLG_HIKASHOP_CHANGESHIPPINGMETHOD_DESC</description>
<files>
<filename plugin="changeshippingmethod">changeshippingmethod.php</filename>
</files>
<config>
</config>
</extension>