WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Read Customer Email from ws_users
  • Print
Pages: [1]   Go Down

Author Topic: Read Customer Email from ws_users  (Read 5358 times)

Offline ChochkoBG

  • Posts: 22
Read Customer Email from ws_users
« on: June 01, 2014, 12:28:34 AM »
Hello guys,

Is there a way, when a customer select product and continue with filling the form details to check if the User is Logged In, and if the User is Logged In to insert the E-mail Address and Confirm E-mail Address text in the fields and also if the User is not Logged In - the field to be empty ?

I think this script have to use ws_users from the database.

Thanks!!!
Logged

Offline ChochkoBG

  • Posts: 22
Re: Read Customer Email from ws_users
« Reply #1 on: June 01, 2014, 02:09:40 AM »
OK, I fixed it.

If anyone want to do the same, you have to add the following code into /$WSB/modules/bakery/view_form.php
on line 95

Here is the Code:

Code: [Select]
// Insert Customer E-Mail Address in the Order Form
// Author: ChochkoBG
// Version: 1.0
// Get existing values from database
$sql = "SELECT email FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."'";
$rowset = $database->query($sql);
if($database->is_error()) $error[] = $database->get_error();
$row = $rowset->fetchRow();
// insert values into form
$tpl->set_var('$cust_email', $row['email']);

if (!isset($cust_email) || $cust_email == '') {
$cust_email = $row['email'];
}
        if (!isset($cust_confirm_email) || $cust_confirm_email == '') {
$cust_confirm_email = $row['email'];
}

This code will read the information from the User Account (The E-mail Address) and If the User is Logged In with his account, it will insert the E-Mail Address and Confirm E-Mail Address in the Customer Order Form.

Thanks!!!
Logged

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3087
  • Gender: Female
Re: Read Customer Email from ws_users
« Reply #2 on: June 01, 2014, 11:35:29 AM »
Quote from: ChochkoBG on June 01, 2014, 02:09:40 AM
Code: [Select]
// Insert Customer E-Mail Address in the Order Form
// Author: ChochkoBG
// Version: 1.0
// Get existing values from database
$sql = "SELECT email FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."'";
$rowset = $database->query($sql);
if($database->is_error()) $error[] = $database->get_error();
$row = $rowset->fetchRow();
// insert values into form
$tpl->set_var('$cust_email', $row['email']);

if (!isset($cust_email) || $cust_email == '') {
$cust_email = $row['email'];
}
        if (!isset($cust_confirm_email) || $cust_confirm_email == '') {
$cust_confirm_email = $row['email'];
}

maybe that's a bit more easier. ;)
Code: [Select]
<?php
// insert values into form
$tpl->set_var('$cust_email', $wb->get_email());
if (!isset($cust_email) || $cust_email == '') {
$cust_email = $wb->get_email();
}
        if (!isset(
$cust_confirm_email) || $cust_confirm_email == '') {
$cust_confirm_email = $wb->get_email();
}
Note: you took the UID by get_user_id() from the object $wb.  If that UID exists, then also the users email exists in the object $wb and you can use the methods of $wb.
You can find user related methods in class.wb from line 235 to 283 (WB-2.8.3)

Logged
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"We need education to cope with digitalization - and NOT the digitalization of education.!"

Tägliches Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline ChochkoBG

  • Posts: 22
Re: Read Customer Email from ws_users
« Reply #3 on: June 01, 2014, 11:50:37 AM »
Yes, your method is better.

Thanks!!!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Read Customer Email from ws_users
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2