• Resolved Soptep

    (@soptep)


    Hello Alex, thanks for the great plugin.

    I would like to ask two things if you could help me:
    1) I have a plugin that calculates the order’s total weight. Your plugin can read and display correctly the value. The field has the name: “plain_orders_order_weight”. My problem is that the weight is in grams and I would like to export it as Kg, so I would like to return this value after dividing it by 1000. How can I implement this?

    2) I would like the field order total amount (order_total) to be displayed as is if the payment method is Cash on Delivery (cod) or zero otherwise.

    Best Regards!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hello

    1. Hook name is “woe_get_order_value_{fieldname}”. So code should be

    add_filter('woe_get_order_value_order_weight', function ($value, $order, $fieldname) {
    	return round($value/1000,3); // not sure if you need round()
    },10,3);

    2. You can add something like this to section “Misc Settings” too

    add_filter('woe_get_order_value_order_total', function ($value, $order, $fieldname) {
    	if(  $order->get_payment_method() != "cod")
    		$value = 0;
    	return $value;
    },10,3);
    Thread Starter Soptep

    (@soptep)

    Great Alex, it works as expected! I was a little bit confused about the hook names, but now you clarified it.

    Thanks a lot!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome.

    you can hover label in “Setup fields” to see internal field name.
    see https://imgur.com/a/Ij9pV7J

    have a good weekend.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Modify Fields’ is closed to new replies.