X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   STILL NEED HELP Getting an added field to show up (https://forum.x-cart.com/showthread.php?t=5181)

kpriest 11-10-2003 06:38 PM

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.

funkydunk 11-10-2003 09:53 PM

Is the data getting saved to the database?

kpriest 11-11-2003 06:20 AM

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?

Kanyon71 11-11-2003 12:06 PM

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?

kpriest 11-11-2003 06:14 PM

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.

val@valcohen.com 11-12-2003 03:22 PM

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?

kpriest 11-13-2003 02:06 PM

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?

kpriest 11-15-2003 11:03 PM

Any ideas from the gurus??


All times are GMT -8. The time now is 05:49 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.