'stored'=> true of hook_line_item

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Hey guys.

In the API of hook_line_item http://www.ubercart.org/docs/api/hook_line_item you write, that if stored == true, the line will be saved in the database.

I'm not sure, but for me it seems, that this doesn't really works, doesn't it? (Or I don't understand it Smiling )

If it works: Where is it stored? And how can I get the value?

greetings
Mic

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Yeah, I'm not too proud of the line item API, but I believe it is storing line items fine. I know Blake used it for a coupon module a while back. Line item data would be saved to the uc_order_line_items table if it's working.

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Then it doesn't work Eye-wink

I use this in uc_methodfee. http://www.ubercart.org/comment/1240/Here-improved-file-I

<?php
function uc_methodfee_line_item() {
 
$items[] = array(
   
'id' => 'methodfee',
   
'title' => t('Method Fee'),
   
'weight' => 9,
   
'default' => FALSE,
   
'stored' => TRUE,
   
'calculated' => TRUE,
   
'display_only' => TRUE,
   
'callback' => 'uc_line_item_methodfee',
  );
?>

according to the API, now should be a new row in uc_order_line_items... but it's totally empty.

same, when I change 'id' => 'methodfee' to 'id' => 'generic'.

thanks for any hints.

Nice weekend everybody!
Mic

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Aww, bummer. I'll look into it. I really need to revise three APIs, the checkout panes, line items, and order actions. I'm all ears for any improvement you may have. Getting it to store data when it should will be a good starting place. Eye-wink

Posts: 8
Joined: 08/08/2007
Bug FinderGetting busy with the Ubercode.

Ya, I just took a quick look through the coupon module and realized that I was inserting the row into the line items table manually.

<?php
db_query
("INSERT INTO {uc_order_line_items} (order_id, type, title, amount, weight) VALUES (%d, 'coupon', 'Coupon Discount: \'%s\'', -%f, 0)", $arg1->order_id, $coupon_result->code, $coupon_result->amount);
?>

Posts: 67
Joined: 08/10/2007

a coupon module?

where?!!!

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

hehe It's a custom module developed by Blake:

http://boldsource.com/ubercart-coupon-module-rev-2