6 replies [Last post]
michels's picture
Offline
Uber DonorBug FinderInternationalizationizer
Joined: 08/12/2007
Juice: 205
Was this information Helpful?

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: 'stored'=> true of hook_line_item

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.

michels's picture
Offline
Uber DonorBug FinderInternationalizationizer
Joined: 08/12/2007
Juice: 205
Then it doesn't work I use

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Then it doesn't work I use

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

blucches@drupal.org's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/08/2007
Juice: 30
Re: Re: Then it doesn't work I use

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);
?>
Miso's picture
Offline
Joined: 08/10/2007
Juice: 134
a coupon module? where?!!!

a coupon module?

where?!!!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: a coupon module? where?!!!

hehe It's a custom module developed by Blake:

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