Reply
Highlighted
Member
Posts: 1
Registered: ‎02-14-2012

Line Item integration in PHP

I have been pulling my hair out trying to figure out why this does not work!  I have tried everything.  I found a few posts that were helpful and got me somewhere, but it is STILL not working!  I am not getting any error messages, it is just simply not showing up!  All other information is passing through just fine!  Can some one please help!  Here is the code I'm using;

 

$get_items_sql = "SELECT variable FROM some table;
$get_items_res = mysqli_query($mysqli, $get_lineitems_sql) or die(mysqli_error($mysqli));
while ($row = mysql_fetch_array($get_items_res)) {

  if ($row['sel_item_id'] == 1) {
$this->line_item  = $row['sel_item_id'] . '<|>' . substr($row['sel_item_nam'],0,30) . '<|>' . $row['sel_item_size'] . ' <br>Color: ' . $row['sel_item_color'] . '<|>' . $row['sel_item_qty'] . '<|>' . $row['sel_item_price'] . '<|>Y';
}else {
$this->addLineItem($row['sel_item_id'], substr($row['sel_item_nam'],0,30), $row['sel_item_size'] . '<br>Color: ' . $row['sel_item_size'], $row['sel_item_qty'], $row['sel_item_price'], 'Y');
}
}
foreach( $this as $value )
    { $post_string .= "&x_line_item=" . urlencode( $value ); }

 

I think that I am either missing something or I have something I don't need.  I have tried changing this $this to $sale, but that doesn't change a thing, actually I can rename $this to $anything and nothing changes!

 

Any Suggestions???????

Thanks

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: Line Item integration in PHP

[ Edited ]

Without going through all of your code, you might first try changing mysql_fetch_array to mysql_fetch_assoc. Also, if you're just going to code for $this->addLineItem anyway, you may as well use it all the time, it should work the same regardless of how many line items you have (up to 30).