Order Status in the Customer (User) Profile

stumed

Hello,
I'm also trying to implement this piece of code but I do not understand exactly where you put this piece of code precisely? Where do you put this code exactly? Does it go into "account / preferences.php?" Does it go into modules / bakery / view_order.php?

Could someone please tell me more about it?

Stumed

seanie_morris

Hi,

I was (re)directed to this thread by freesbee (Christoph) about a question I asked about allowing customers to register. Is this the right thread? And if so, I am missing something HUGE because, I don't know where these codes and CSS blocks are supposed to go, and how they relate to the customer using it. Sorry for the vagueness of my query, I have done a lot of modifications to bakery to customise what I am looking for through trial and error and have been successful most of the time! I just need to fill in a few of the blanks to get going on this one.

:|

Seanie.

ChochkoBG

It's working with your method. Thank you.

Yes, the page is set only for registered users.

I will post the final working code, with nice looking table and fixed security status.

This is the .php code:


//Information about the Customers Orders in the Customers Profile.
//Created by ChochkoBG
//Version 1.0

// Prevent this file from being accessed directly
if (defined('WB_PATH') == false) {
exit("Cannot access this file directly");
}

// Get some default values
require_once(WB_PATH.'/modules/bakery/config.php');

// Take the Results from the Selected DB Tables.
$result = $database->query("SELECT * FROM ws_mod_bakery_customer
INNER JOIN ws_mod_bakery_order
ON ws_mod_bakery_order.order_id = ws_mod_bakery_customer.order_id
WHERE cust_email = '".$wb->get_email()."'");

echo "<table class='profileorders'>
<tr>
<th>№</th>
<th>First Name</th>
<th>Last Name</th>
<th>E-Mail</th>
<th>Company</th>
<th>Country</th>
<th>Address</th>
<th>City</th>
<th>ZIP Code</th>
<th>Phone</th>
<th>Payment Method</th>
<th>SKU</th>
<th>Price</th>
<th>Status</th>
</tr>";

while ($row = $result->fetchRow()) {

  echo "<tr>";
  echo "<td>" . $row['order_id'] . "</td>";
  echo "<td>" . $row['cust_first_name'] . "</td>";
  echo "<td>" . $row['cust_last_name'] . "</td>";
  echo "<td>" . $row['cust_email'] . "</td>";
  echo "<td>" . $row['cust_company'] . "</td>";
  echo "<td>" . $row['cust_country'] . "</td>";
  echo "<td>" . $row['cust_street'] . "</td>";
  echo "<td>" . $row['cust_city'] . "</td>";
  echo "<td>" . $row['cust_zip'] . "</td>";
  echo "<td>" . $row['cust_phone'] . "</td>";
  echo "<td>" . $row['submitted'] . "</td>";
  echo "<td>" . $row['sku'] . "</td>";
  echo "<td>" . $row['price'] . "</td>";
  echo "<td><font color='red'>" . $row['status'] . "</font></td>";
  echo "</tr>";
}

echo "</table>";


This is the template.css code:


table.profileorders {
    margin-left:auto;
    margin-right:auto;
}
table.profileorders th {
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d5e3e4', endColorstr='#b3c8cc',GradientType=0 );
position: relative;
z-index: -1;
}
table.profileorders td {
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ebecda', endColorstr='#ceceb7',GradientType=0 );
position: relative;
z-index: -1;
}
table.profileorders {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.profileorders th {
padding: 0px;
background: #d5e3e4;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Q1ZTNlNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjQwJSIgc3RvcC1jb2xvcj0iI2NjZGVlMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNiM2M4Y2MiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,  #d5e3e4 0%, #ccdee0 40%, #b3c8cc 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d5e3e4), color-stop(40%,#ccdee0), color-stop(100%,#b3c8cc));
background: -webkit-linear-gradient(top,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
background: -o-linear-gradient(top,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
background: -ms-linear-gradient(top,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
background: linear-gradient(to bottom,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
border: 1px solid #999999;
}
table.profileorders td {
padding: 0px;
background: #ebecda;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ViZWNkYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjQwJSIgc3RvcC1jb2xvcj0iI2UwZTBjNiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNjZWNlYjciIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,  #ebecda 0%, #e0e0c6 40%, #ceceb7 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ebecda), color-stop(40%,#e0e0c6), color-stop(100%,#ceceb7));
background: -webkit-linear-gradient(top,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
background: -o-linear-gradient(top,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
background: -ms-linear-gradient(top,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
background: linear-gradient(to bottom,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
border: 1px solid #999999;
}
table.profileorders th p{
margin:0px;
padding:8px;
border-top: 1px solid #eefafc;
border-bottom:0px;
border-left: 1px solid #eefafc;
border-right:0px;
}
table.profileorders td p{
margin:0px;
padding:8px;
border-top: 1px solid #fcfdec;
border-bottom:0px;
border-left: 1px solid #fcfdec;;
border-right:0px;
}


You need to add the .php as a new section or a new page with (Code) type.
You need to paste the template.css code into your template (WB/templates/template/template.css)

Thanks!!!

instantflorian

Hi,

nice idea so far, of course the page has to be set to "registered" or "private" in the frontend.

I'm no coder but afaik there is a WB function to connect to the database so the DB credentials dont have to be written into a code section. (What is in my eyes a security risk, because if the group/user rights settings are not correct, EVERY WB user with backend access sees the DB username and password and could quite easily manipulate it.)

To your question about the table styling - if you give your table al class, eg. shoporders, by changing the line
echo "<div align='center'><table border='1'>
to
echo "<table class='shoporders'>
and get rid of all that <font> and <div align='center'> stuff, you can easily add classes to your template css file to style the table, e.g.

table.shoporders th {
  background-color:#039;
  color:#fff;
}

and so on...


ChochkoBG

Hello guys, I fixed the problem with the db tables and displaying the results from different db tables.

Here is the Working Code, so if you want to display to every Customer (User) there own orders in the User Profile, you can use this code. It's working for me.

You have to add a new page with selected type (module) = Code.


//Information about the Customers Orders in the Customer Profile.
//Created by ChochkoBG
//Version 1.0

// Connecting to the DataBase. Using Manual Defined variables to connect.
$con=mysqli_connect("host","user","password","DB_NAME");

// Checking the connection.
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Take the Results from the Selected DB Tables.
$result = mysqli_query($con,"SELECT * FROM ws_mod_bakery_customer
INNER JOIN ws_mod_bakery_order
ON ws_mod_bakery_order.order_id = ws_mod_bakery_customer.order_id
WHERE cust_email = '".$wb->get_email()."'");

echo "<div align='center'><table border='1'>
<tr>
<th>№</th>
<th>First Name</th>
<th>Last Name</th>
<th>E-Mail</th>
<th>Company</th>
<th>Country</th>
<th>Address</th>
<th>City</th>
<th>ZIP Code</th>
<th>Phone</th>
<th>Payment Method</th>
<th>SKU</th>
<th>Price</th>
<th><font color='red'>Order Status</font></th>
</tr></div>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['order_id'] . "</td>";
  echo "<td>" . $row['cust_first_name'] . "</td>";
  echo "<td>" . $row['cust_last_name'] . "</td>";
  echo "<td>" . $row['cust_email'] . "</td>";
  echo "<td>" . $row['cust_company'] . "</td>";
  echo "<td>" . $row['cust_country'] . "</td>";
  echo "<td>" . $row['cust_street'] . "</td>";
  echo "<td>" . $row['cust_city'] . "</td>";
  echo "<td>" . $row['cust_zip'] . "</td>";
  echo "<td>" . $row['cust_phone'] . "</td>";
  echo "<td>" . $row['submitted'] . "</td>";
  echo "<td>" . $row['sku'] . "</td>";
  echo "<td>" . $row['price'] . "</td>";
  echo "<td>" . $row['status'] . "</td>";
  echo "</tr>";
}

echo "</table>";
mysqli_close($con);


But now I have a question.
How to change the Table Style with CSS Style or Gradients, or with Image ?

Thanks!!!

ChochkoBG

Hello guys,

I almost finish the module for displaying the Ordered Items Status in the Customer Profile.
The module is added like a "Code".

It is taking the information (E-Mail Address) from the Created Account in the Web Site Bakery System and the E-Mail from the Bakery Shop Module.
The both of the E-Mail Addresses must be the same to execute the information in the User Profile Page.

Here is the Code:

//Information about the Customers Orders in the Customer Profile.
//Created by ChochkoBG
//Version 1.0

// Connecting to the DataBase. Using Manual Defined variables to connect. (I'm not sure that you can use WB Connect Method).
$con=mysqli_connect("host","user","password","database");

// Checking the connection.
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Take the Results from the Selected DB Tables.
$result = mysqli_query($con,"SELECT * FROM ws_mod_bakery_customer WHERE cust_email = '".$wb->get_email()."'");
$result_item = mysqli_query($con,"SELECT * FROM ws_mod_bakery_order");

echo "<div align='center'><table border='1'>
<tr>
<th>№</th>
<th>Shipping</th>
<th>Order Status</th>
<th>Company</th>
<th>First Name</th>
<th>Last Name</th>
<th>Address</th>
<th>City</th>
<th>Country</th>
<th>ZIP Code</th>
<th>E-Mail</th>
<th>Phone number</th>
<th>SKU</th>
</tr></div>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['order_id'] . "</td>";
  echo "<td>" . $row['submitted'] . "</td>";
  echo "<td>" . $row['status'] . "</td>";
  echo "<td>" . $row['cust_company'] . "</td>";
  echo "<td>" . $row['cust_first_name'] . "</td>";
  echo "<td>" . $row['cust_last_name'] . "</td>";
  echo "<td>" . $row['cust_street'] . "</td>";
  echo "<td>" . $row['cust_city'] . "</td>";
  echo "<td>" . $row['cust_country'] . "</td>";
  echo "<td>" . $row['cust_zip'] . "</td>";
  echo "<td>" . $row['cust_email'] . "</td>";
  echo "<td>" . $row['cust_phone'] . "</td>";
  while($row = mysqli_fetch_array($result_item)) {
  echo "<td>" . $row['sku'] . "</td>";
  echo "</tr>";
}
}

echo "</table>";

mysqli_close($con);


But I have a problem with the SKU name and the Item Price.
They are in different tables, but the "order_id" is the same in the both tables, so I think it is possible to take the information from the both tables and to match them.

Is there a way to parse them for each order_id to show the necessary information ?

Thanks!!!