TransWikia.com

Programmatically get product name by using order variable

Drupal Answers Asked by Selva on January 7, 2021

I need to get specific product name with order variable($order) in Ubercart. How can I achieve this programmatically.

Also suggest me if there is any other way to get product name programmatically.

Looking forward this answer

2 Answers

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.

Answered by danuddara on January 7, 2021

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

Answered by developer on January 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP