Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Export orders to csv with attributs


pmaonline

Recommended Posts

Hi all, i have a product with product_id=100000 and the attribut Color has the id=200000

 

what i need to to is when i export the product ordered, if it has attribut, change it.

 

I made this code :

 

<?php

require('includes/application_top.php');

if (!$HTTP_GET_VARS['submit'])

{

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//DE">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#CCCC33">

<!-- header //-->

<?php require(DIR_WS_INCLUDES.'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

  <table border="0" width="100%" cellspacing="2" cellpadding="2" >

  <tr>

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>

<!-- left_navigation_eof //-->

    </table></td><td valign=top>

<!-- body_text //-->

 

<?php

echo "<center><br><br><br><img src=\"encom1.gif\"><br><br><br><font face=verdana size=2><b>Export</font><br><br>";

echo '<form action="'. $phpself.'">';

echo '<input type="submit" value="Export" name="submit"></form>';

?>

</td>

</table>

<!-- footer //-->

<center><font color="#666666" size="2"></font></center>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php

}

else

{

 

$today=getdate();

$day=$today['mday'];

$month=$today['mon'];

    $year=$today['year'];

$contents5="[EOF]\n";

 

$user_query = mysql_query("SELECT orders.*, orders_products.*, orders_products_attributes.*

FROM (orders left JOIN orders_products ON orders.orders_id=orders_products.orders_id) left JOIN orders_products_attributes ON orders.orders_id=orders_products_attributes.orders_id;");

while($row = mysql_fetch_array($user_query))

{

 

 

  if(date("d,m,Y", strtotime($row[date_purchased]))==date("d,m,Y")) {

 

$contents.=$row[customers_id].";";

 

// PRICE----------------------------------------------------

 

$price1=$row[products_price];

$aa=$row[price_prefix];

$price3=$row[options_values_price];

 

if ( $aa == "+")

{

$total=$price1+$price3;

}

else

{

$total=$price1-$price3;

}

// END------------------------------------------------

 

 

 

if ($row[products_options_values]=="") {

$contents.=$row[products_model].";";

} else {

$contents.=str_replace('r. ','',strstr($row[products_options_values], 'r. ')) .";";

}

  $contents.=$row[orders_id].";";

                      $contents.=$total.";";

  $contents.=$row[products_quantity].";";

  $contents.=$row[payment_method].";";

  $contents.=chr(13).chr(10);

 

 

 

  }

} Header("Content-Disposition: attachment; filename=orders.csv");

print $contents;

print $contents5;

 

}

 

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

This works fine when i order just one product, but for example if i order a product with attributs and another product withought attribut, in the second product(with no attribut) he puts the same product_id and the same price of the first product.

 

 

Can someone help me with this please ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...