I use drupal6 and UC2. I am working on a view which exports order details into an excel file such as - address and total order amount. Total amount field is crucial for me - Would it be possible to use views php and check if payment method is COD then get total amount. If payment method is different than COD then result would be nothing or 0?

Thank you

1 Answer 1


You can certainly do that. If you setup a view and tell it to grab Ubercart Order data it will allow you to access information on orders such as the payment type, amount, order id, etc.

So if you grab the following information you'll be set to feed it into the Views PHP field.

  1. Payment Method
  2. Order Total (Exclude this from the display)

Then if you add the Global: PHP field you need to put the following into the Value code field:

if ($data->uc_orders_payment_method == "cod") {
  return number_format($data->uc_orders_order_total, 2, '.', ',');
} else {
  return number_format(0, 2, '.', ',');

And this in the output code field:

  print $value;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.