Hello,
Could you try this code ?
// set total =0, if payment <> COD
add_filter('woe_get_order_value_order_total', function ($value, $order, $item, $product) {
if( $order->payment_method != "cod")
$value = 0;
return $value;
}, 10, 4);
thanks, Alex
Sorry, I think that is not for me.
I need a meta_key like “COD value” for exporting in csv file like this:
“name”, “address”, “total order value”, “cod”
“Mirko Salvati”, “via Atzori 55”, “14.99”, “0” <— This is order without COD
“Francesco Salvati”, “via Atzori 55”, “14.99”, “14.99” <— This order is with COD
Meanwhile I tried your code but It return a HTTP ERROR 500..
Here is updated code.
Please, use this plugin to add it https://ww.wp.xz.cn/plugins/code-snippets/
// add new order field
add_filter('woe_get_order_fields', function ($fields) {
$fields['cod_amount'] = array( 'label' => 'COD Total Amount', 'colname' => 'COD Total Amount', 'checked' => 1 );
return $fields;
});
// set value , if payment == COD
add_filter('woe_get_order_value_cod_amount', function ($value, $order, $fieldname) {
if( $order->payment_method == "cod")
$value = $order->get_total();
else
$value = 0;
return $value;
}, 10, 3);
-
This reply was modified 8 years, 6 months ago by
algol.plus.