Location of onBeforeOrderCreate Plugin

  • Posts: 42
  • Thank you received: 3
1 year 3 months ago #348110

-- 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.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
1 year 3 months ago #348114

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>

Last edit: 1 year 3 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 3
1 year 3 months ago #348154

Thanks for your detailed reply, it saved me :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.052 seconds
Powered by Kunena Forum