Skip to content
Advertisement

Get a custom calculations as WooCommerce admin bulk orders action

i want to make order totals go under a calculation formula.

i have drivers whom salary is per order. they deliver paid and unpaid orders. so They collect unpaid cod payments from the customers.At the end of the day i calculate how much do i have to collect from them deducting their salary from the amount.( this happen on daily basis)

the formula is [ (‘cod’ orders totals ) – (delivered orders Numbers) x 1.5 ]

this is an example

assume that we’ve received 3 orders and the driver collected them for delivery .. so at the end of the day the driver has to bring the cash back .. here i want to know how much i have to collect from him deducting his salary

JavaScript

the result is (55.5) is amount of money i have to collect from the driver

i dont know if this have to be on the same admin orders page or a new page .. i imagine that in the orders management section in WC or on the separate page , i can check the orders from the order list that i want to make the calculations for and from the bulk actions drop box i choose for example [ CALCULATION 1 ] , and then the result is shown

Advertisement

Answer

You can use the following code that will allow you on bulk order selection to calculate the amount to collect from the driver as defined in your question:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and works.

This custom bulk action (on the Orders list bulk action dropdown):

enter image description here

The result of the calculation in a dismissible message box:

enter image description here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement