Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

STILL NEED HELP Getting an added field to show up

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-10-2003, 06:38 PM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default STILL NEED HELP Getting an added field to show up

I have the "How Did You Hear About Us" mod from this post: http://forum.x-cart.com/viewtopic.php?t=2931 and need to have the field displayed in the order details viewed in the admin.

I added this to the main/history_order.tpl:
Code:
<tr> <td valign="top">{$lng.lbl_how_heard}</td> <td valign="top">{$customer.hear}</td> </tr>
The label shows up, but no data. I can change it to some other fields and they show up. I looked in func.php where I believe it is getting the $userdata by querying all fields from the user table and putting them in an array which is eventually translated to the $customer array.

What am I missing??? Any help is greatly appreciated.
__________________
-Ken
X-Cart User / Developer Since April 2003
(Varying versions, multiple client sites, 3.x through 4.4.x)
www.pointbweb.com
Reply With Quote
  #2  
Old 11-10-2003, 09:53 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Is the data getting saved to the database?
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 11-11-2003, 06:20 AM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default

Yep - the data is in there. I tested other fields from the array i.e. $customer.language and that spits out ok. Some other fields would not output either though. Is there some smarty> assign thing I need?
__________________
-Ken
X-Cart User / Developer Since April 2003
(Varying versions, multiple client sites, 3.x through 4.4.x)
www.pointbweb.com
Reply With Quote
  #4  
Old 11-11-2003, 12:06 PM
 
Kanyon71 Kanyon71 is offline
 

Senior Member
  
Join Date: Oct 2002
Location: Lutz, FL
Posts: 128
 

Default

So you changed the code to add this new piece to the database not the parts that are normally there. Did you also create the new table in the database itself? Have you also gone in and verified that the data is actually in the dataase using you MySQL admin?
__________________
Kanyon71
http://www.web-wizards.com
For hosting solutions that fully support X-Cart!
Mention the forums for a discounted package!
Reply With Quote
  #5  
Old 11-11-2003, 06:14 PM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default

It is a field added to the Customers table and it all works fine as far as inputting data from the registration form and pulling it back up when editing the profile, but I need it to show up in the orders history in the admin area.
__________________
-Ken
X-Cart User / Developer Since April 2003
(Varying versions, multiple client sites, 3.x through 4.4.x)
www.pointbweb.com
Reply With Quote
  #6  
Old 11-12-2003, 03:22 PM
 
val@valcohen.com val@valcohen.com is offline
 

Newbie
  
Join Date: Sep 2003
Location: Long Beach, CA, USA
Posts: 6
 

Default ASSIGN the value to the variable

Smarty needs to have the value of the variable "hear" assigned to it -- it can't look it up directly.

You need something like

$mail_smarty->assign("hear",$customer.hear);

in the code that CALLS the history_order.tpl template

then in the template, {$hear} will echo the value passed to it.

Without passing a value, $hear is undefined (and likely empty), which is why you don't see its value in the output.

Does this help?
__________________
X-Cart Gold 3.4.4; X-Affiliate 3.4.4; PHP 4.3.2; MySQL 4.0.15-standard; Apache 1.3.28; Red Hat Linux 7.1
Reply With Quote
  #7  
Old 11-13-2003, 02:06 PM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default

Close, but no cigar. I tried several variations of that and still no data. What I would really like is an understanding of what is happening programmatically when you pull up the order details in the admin. I see a trail of the following relevant php files:
func.php - used to get the $userdata - it looks like it pulls the entire customers table into $userdata:
Code:
# # Get information associated with user # function func_userinfo($user,$usertype) { global $sql_tbl; $userinfo = func_query_first("SELECT $sql_tbl[customers].*, $sql_tbl[countries].country FROM $sql_tbl[customers], $sql_tbl[countries] WHERE $sql_tbl[customers].login='$user' AND $sql_tbl[customers].usertype='$usertype' AND $sql_tbl[countries].code=$sql_tbl[customers].b_country"); $userinfo["passwd1"] = stripslashes(text_decrypt($userinfo["password"])); $userinfo["passwd2"] = stripslashes(text_decrypt($userinfo["password"])); $userinfo["password"] = stripslashes(text_decrypt($userinfo["password"])); $userinfo["card_number"] = text_decrypt($userinfo["card_number"]); $userinfo["b_statename"] = func_get_state($userinfo["b_state"]); $userinfo["b_countryname"] = func_get_country($userinfo["b_country"]); $userinfo["s_statename"] = func_get_state($userinfo["s_state"]); $userinfo["s_countryname"] = func_get_country($userinfo["s_country"]); $email = $userinfo["email"]; if(func_query_first("SELECT email FROM $sql_tbl[maillist] WHERE email='$email'")) $userinfo["newsletter"]="Y"; return $userinfo; }

Then history_order.php:
Code:
# # $Id: history_order.php,v 1.9 2002/11/14 07:58:19 zorg Exp $ # # Collect infos about ordered products # if ($mode == "invoice" or $mode == "label") { header("Content-Type: text/plain"); header("Content-Disposition: inline; filename=invoice.txt"); $orders = explode(",", $orderid); if ($orders) { $orders_data = array(); foreach ($orders as $orderid) { $order_data = func_order_data($orderid); $order = $order_data["order"]; $customer = $order_data["userinfo"]; $products = $order_data["products"]; $giftcerts = $order_data["giftcerts"]; $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts); } $smarty->assign("orders_data", $orders_data); $_tmp_smarty_debug = $smarty->debugging; $smarty->debugging = false; if ($mode == "invoice") $smarty->display("main/order_invoice_print.tpl"); elseif ($mode == "label") $smarty->display("main/order_labels_print.tpl"); $smarty->debugging = $_tmp_smarty_debug; } exit; } else { $order_data = func_order_data($orderid); $smarty->assign("order", $order_data["order"]); $smarty->assign("customer", $order_data["userinfo"]); $smarty->assign("products", $order_data["products"]); $smarty->assign("giftcerts", $order_data["giftcerts"]); }
And the php file called up: order.php
Code:
# # $Id: order.php,v 1.19 2002/12/10 08:57:10 sdg Exp $ # require "../smarty.php"; require "../config.php"; require "./auth.php"; require "../include/security.php"; # # Collect infos about ordered products # require "../include/history_order.php"; $order = $order_data["order"]; $userinfo = $order_data["userinfo"]; $products = $order_data["products"]; $giftcerts = $order_data["giftcerts"]; if ($mode == "status_change") { # Update order # func_change_order_status($orderid, $status); db_query("update $sql_tbl[orders] set tracking='$tracking', notes='$notes', details='".text_crypt($details)."' where orderid='$orderid'"); header("Location: order.php?orderid=$orderid&mode=status_changed"); exit; } # # Delete order # if ($mode=="delete") { db_query("DELETE FROM $sql_tbl[orders] WHERE orderid='$orderid'"); db_query("DELETE FROM $sql_tbl[order_details] WHERE orderid='$orderid'"); db_query("DELETE FROM $sql_tbl[giftcerts] WHERE orderid='$orderid'"); db_query("DELETE FROM $sql_tbl[partner_payment] WHERE orderid='$orderid'"); db_query("DELETE FROM $sql_tbl[subscription_customers] WHERE orderid='$orderid'"); header("Location: orders.php?".$query_string); exit; } $smarty->assign("main","history_order"); @include "../modules/gold_display.php"; $smarty->display("admin/home.tpl"); ?>
Then the history_order.tpl file has this in it (excerpt of 3 of the fields to be displayed):
Code:
<tr> <td valign="top">{$lng.lbl_fax}</td> <td valign="top">{$customer.fax}</td> </tr> <tr> <td valign="top">{$lng.lbl_email}</td> <td valign="top">{$customer.email}</td> </tr> <tr> <td valign="top">{$lng.lbl_how_heard}</td> <td valign="top">{$customer.hear}</td> </tr>

To reiterate: xcart_customers.hear is the field in the customers table I need to show. It has data in it. The variables $customer.fax and $customer.email show up fine and it looks like they are just pulled from the userdata array in func.php from the SQL query that pulls all fields from the table and assigned through this (I think) in the history_order.php file:
Code:
$smarty->assign("customer", $order_data["userinfo"]);
WHAT IS MISSING?
__________________
-Ken
X-Cart User / Developer Since April 2003
(Varying versions, multiple client sites, 3.x through 4.4.x)
www.pointbweb.com
Reply With Quote
  #8  
Old 11-15-2003, 11:03 PM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default

Any ideas from the gurus??
__________________
-Ken
X-Cart User / Developer Since April 2003
(Varying versions, multiple client sites, 3.x through 4.4.x)
www.pointbweb.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:40 AM.

   

 
X-Cart forums © 2001-2020