- Posts: 15
- Thank you received: 0
Execute specific files or functions
13 years 3 months ago #110379
by Teonnyn
Execute specific files or functions was created by Teonnyn
Is it possible to execute specific functions after purchase of certain items - IE, in order to create a digital item shop?
I'd like to be able to create a system that allows people to buy items that get added to their players database/inventory system.
I'd like to be able to create a system that allows people to buy items that get added to their players database/inventory system.
Please Log in or Create an account to join the conversation.
13 years 3 months ago #110380
by nicolas
Replied by nicolas on topic Execute specific files or functions
Yes, you can create a hikashop plugin and implement the onAfterOrderUpdate trigger and check the order_status of the order in it and if it is confirmed, then you can do the processing you need:
www.hikashop.com/en/support/documentatio...l#onAfterOrderUpdate
www.hikashop.com/en/support/documentatio...l#onAfterOrderUpdate
Please Log in or Create an account to join the conversation.
13 years 3 months ago #110408
by Teonnyn
Replied by Teonnyn on topic Execute specific files or functions
What would be the best way to check if it's certain products - dynamically if possible? For instance, a T-shirt shouldn't trigger an "Add to Inventory" command but a in-game credit purchase should.
Please Log in or Create an account to join the conversation.
13 years 3 months ago #110418
by nicolas
Replied by nicolas on topic Execute specific files or functions
In the $order variable, you will get he id of the order like that:
$order->order_id
So you can simply load the full order like that:
$class = hikashop_get('class.order');
$fullOrder = $class->loadFullOrder($order->order_id);
and then loop on the products list to check the products:
foreach($fullOrder->products as $product){
if($product->order_product_code=='in-game credit product code'){
//custom code
}
}
$order->order_id
So you can simply load the full order like that:
$class = hikashop_get('class.order');
$fullOrder = $class->loadFullOrder($order->order_id);
and then loop on the products list to check the products:
foreach($fullOrder->products as $product){
if($product->order_product_code=='in-game credit product code'){
//custom code
}
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.143 seconds