I need to get the product name using the $order variable in Ubercart. How can I achieve?


In ubercart uc_products table stores the product details. You can get product id from the $orders array and can fetch the required product data from uc_products table.

$query = "SELECT * FROM uc_products WHERE nid = ". $pid;

Refer the links for more details https://www.drupal.org/node/1940926

  • Thanks for your answer. I know this but I have to get product order details only based on order variable $order – Selva Mar 27 '17 at 15:43

Here's the link that you have to check uc_order_get_product_list. ubecart API will help you alot:

you will get an array with the products when you pass the $order variable to it.

$product_list = uc_order_get_product_list($order)

check the $product_list variable and you'll find the product name/ node ids there.

if it's only node ids [node_load] method in Drupal will help you to get the product title. (https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_load/7.x)

work with [devel] (https://www.drupal.org/project/devel) module and development will be easier for you in drupal. use dsm ($variable) to display the variable content. it works like var_dump($variable) in PHP but has a more developer friendly interface for drupal.

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