2

There are some transactions which are made using drupal commerce module along with commerce ccavenue module. I have the order ids, transaction ids and list of line items purchased in each of the orders. But the problem is I if a product price is updated in past then I am not able to find the cost of the product in the past order when the product was purchased.

Is there any place where drupal stores product price for a particular order anywhere.

2 Answers 2

0

Yes, Commerce Module does store product amount of past order... You can retrieve using below details...

To get full details of order

$order = commerce_order_load($order_id);
$view_mode = "administrator";
print entity_view('commerce_order', array($order->order_id => $order), $view_mode, NULL, TRUE);

To be more specific

  $order = commerce_order_load($order_id);
  foreach ($order->commerce_line_items['und'] as $line) {
    $line_item = commerce_line_item_load($line['line_item_id']);
    drupal_set_message("<pre>" . print_r($line_item,1) . "</pre>");
  }

There is no chance it gets new price instead of old price since it gets tracked in field_data_commerce_unit_price table in database ... All you need to do is divide by 100 if decimal places are 2 in order line item amount...

enter image description here

4
  • I used commerce_order_load and commerce_line_item_load but its giving current price of product.
    – user24595
    Commented Apr 11, 2014 at 4:53
  • Just to make sure.. Purchase products and record order number.. Go and change product price.. Then execute above code using commerce_order_load and commerce_line_item_load.. You should get previous product price..
    – Anil Sagar
    Commented Apr 11, 2014 at 5:09
  • Sure, I will follow the same
    – user24595
    Commented Apr 11, 2014 at 5:14
  • Hi, the above answer did not solve the problem. So waiting for more answers
    – user24595
    Commented Apr 17, 2014 at 11:45
0

I think you can try and use :

https://www.drupal.org/project/commerce_line_item_revision

that could activate the line items you are seeking

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.