Skip to main content

Location of onBeforeOrderCreate Plugin

More
3 years 8 months ago #348110 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.

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

More
3 years 8 months ago - 3 years 8 months ago #348114 by nicolas
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:
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'; } }
And for example the XML file:
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.

More
3 years 8 months ago #348154 by JF
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
Powered by Kunena Forum