- Posts: 42
- Thank you received: 3
Location of onBeforeOrderCreate Plugin
3 years 8 months ago #348110
by JF
Location of onBeforeOrderCreate Plugin was created by JF
-- url of the page with the problem -- :
edumall.satumalaysiahosting.com/
Hi,
May I know where the is code for onBeforeOrderCreate? As I need to set the order_shipping_method field for order that have multivendor.
For single vendor's order, the value of order_shipping_method will be inserted but multivendor's order will not.
Kindly refer the attachment for reference.
Thanks.
Hi,
May I know where the is code for onBeforeOrderCreate? As I need to set the order_shipping_method field for order that have multivendor.
For single vendor's order, the value of order_shipping_method will be inserted but multivendor's order will not.
Kindly refer the attachment for reference.
Thanks.
Please Log in or Create an account to join the conversation.
3 years 8 months ago - 3 years 8 months ago #348114
by nicolas
Replied by nicolas on topic Location of onBeforeOrderCreate Plugin
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:
And for example the XML file:
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:
Code:
<?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';
}
}
Code:
<?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>
Last edit: 3 years 8 months ago by nicolas.
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348154
by JF
Replied by JF on topic Location of onBeforeOrderCreate Plugin
Thanks for your detailed reply, it saved me
Please Log in or Create an account to join the conversation.
Time to create page: 0.196 seconds