0

I've a problem. I'm currently writing a WordPress plugin for WooCommerce which reads out an order for a booking system.

The booking system has an own field for cod costs (costs on delivery / Nachnahmegbühr (deutsch)). The problem is that I can't find a method to read this cost from an order.

If I read out the fees from the order via $order->get_fees(), I can see the cod costs but this is not safe enough cause the fee name is always in the shop language which makes it nearly impossible to read out the cod costs this way (in an international plugin):

 [data:protected] => Array
     (
         [order_id] => 24
         [name] => Zahlungsgebühr
         [tax_class] => 0
         [tax_status] => taxable
         [amount] => 2.16
         [total] => 2.16
         [total_tax] => 0.34
         [taxes] => Array
             (
                 [total] => Array
                     (
                         [6] => 0.344828
                     )
             )
     )

So is there any known way to get this kind of costs?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Mr. Jo
  • 4,946
  • 6
  • 41
  • 100
  • What about reading the data directly from the database? Maybe there is a unique fieldname you can fetch. – Markus Zeller Sep 22 '20 at 16:26
  • There is no COD cost, but for something much more clean and effective, you can clone COD payment gateway extending `WC_Payment_gateway` Class [as shown in this thread (in a custom plugin)](https://stackoverflow.com/questions/63787049/extending-woocommerce-cod-payment-gateway-in-a-plugin/63792485#63792485), see also [this related thread](https://stackoverflow.com/questions/63986726/change-specific-payment-gateway-title-in-woocommerce/64000593#64000593)… Then you can make changes to this cloned payment gateway, to include a cost based on anything that you require, but this is something advanced. – LoicTheAztec Sep 22 '20 at 19:49

0 Answers0