Hi,
You need to develop a HikaShop plugin and implement in it the event onBeforeOrderCreate and onBeforeOrderUpdate:
www.hikashop.com/support/documentation/6...#onBeforeOrderCreate
In them, you want to have your PHP code to:
- potentially load the data of the order from the database if not already available in $order (
www.hikashop.com/support/documentation/6...umentation.html#code
)
- substract the subtotal and coupon values. You'll want to do a var_dump() of the data to check that you have what you need for your calculations and how to access it. For example, when the order is being created, you'll have the value of the coupon in $order->order_discount_price and the whole data of the coupon in $order->cart->coupon, and you'll have the subtotal object in $order->cart->total ( $order->cart->total->price_value_with_tax or $order->cart->total->price_value based on whether you want the subtotal with or without taxes )
- set the result of your calculation in $order->xxx where xxx is the column name of your custom field. The save of the order afterwards will automatically save the value to the database for you.