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

What is the Smarty variable for Provider company name?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 12-15-2011, 11:35 PM
 
jake8804 jake8804 is offline
 

Newbie
  
Join Date: Dec 2011
Posts: 6
 

Default What is the Smarty variable for Provider company name?

I am trying to display the Provider's company name on the product details page. My current code is:

<tr>
<td class="property-name">{$lng.lbl_company}</td>
<td class="property-value" colspan="2">{$userinfo.company}</td>
</tr>

Obviously $userinfo is wrong (I got that from the provider account page in admin) but I can't see anything in the debugging console that would work. So can someone tell me what is the correct smarty variable?

Thank you!
__________________
X-Cart 4.4.4 on Unix
Add-ons: Power Filter by *********, BCSE Shipping Per Product.
Reply With Quote
  #2  
Old 12-15-2011, 11:43 PM
 
jake8804 jake8804 is offline
 

Newbie
  
Join Date: Dec 2011
Posts: 6
 

Default Re: What is the Smarty variable for Provider company name?

I see a $product.provider but that would just give me the Provider's # instead of name...
__________________
X-Cart 4.4.4 on Unix
Add-ons: Power Filter by *********, BCSE Shipping Per Product.
Reply With Quote
  #3  
Old 12-15-2011, 11:57 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: What is the Smarty variable for Provider company name?

Unfortunately, I don't think you can accomplish this from within Smarty or a template.

Your going to have to add the provider name to the product array, or initialize a separate variable containing the name. You've got the number, just query the db for the name associated with it and add it to the array or assign it to a new variable.

Hope that helps,
-Mike
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #4  
Old 12-16-2011, 12:40 AM
 
jake8804 jake8804 is offline
 

Newbie
  
Join Date: Dec 2011
Posts: 6
 

Default Re: What is the Smarty variable for Provider company name?

I am making some progress on understanding this system of web design . I COULD run an SQL query directly from the template right now and get the info that way but that is undesirable, yes?

The query will be something like:

SELECT customers.company
FROM customers
JOIN products
ON customers.provider = products.provider;

And then the Smarty assign is:

$smarty->assign('company',$product);

How do I put them together?
Also, I have been trying to figure out which .php file to use to assign variables to $product...which one is it? I am more of a database guy than a web designer lol
__________________
X-Cart 4.4.4 on Unix
Add-ons: Power Filter by *********, BCSE Shipping Per Product.
Reply With Quote
  #5  
Old 12-16-2011, 12:55 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: What is the Smarty variable for Provider company name?

You are right, no queries from the template. Definitely a bad practice.

But that doesn't look like the right way to assign to smarty. What you have there looks like it will assign whatever value $product has to a new smarty variable called company.

It is not going to assign anything to the product array like that.

I have to admit that I am also confused by your query. Join on customers.provider. There is no such column name that I am aware of.

Bear in mind that I have much less experience with x-cart pro than I do with gold. That may be my confusion.

-Mike
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #6  
Old 12-16-2011, 01:34 AM
 
jake8804 jake8804 is offline
 

Newbie
  
Join Date: Dec 2011
Posts: 6
 

Default Re: What is the Smarty variable for Provider company name?

My knowledge of Smarty a few hours ago was zero and it has risen very little so far. You're right about that query not making sense...I should get some sleep haha.

There is a customers.company and products.provider but no way to join the tables. I can't see any table that connects provider to customers.id or customers.company. Maybe I'm too tired...I'll try again tomorrow.
__________________
X-Cart 4.4.4 on Unix
Add-ons: Power Filter by *********, BCSE Shipping Per Product.
Reply With Quote
  #7  
Old 12-16-2011, 01:45 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: What is the Smarty variable for Provider company name?

Sleep helps...sometimes.

{$provider_info} is the variable that is usually initialized with an array containing the provider info:

Array (5)
id => "1"
login => "mike@babymonkeystudios.com"
title => "Mr."
firstname => "Michael"
lastname => "White"

I can't give you a crash course on Smarty, but if you know php, smarty will come naturally over time. It is even easier for me than php itself. I like writing eq or ne instead of == or !=. It truly is a "smart" language- pun intended. :_)

Let me know when you get stuck. Post real code examples and I will help where I can. If you need more than just volunteer support, I can help out professionally as well.

-Mike
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #8  
Old 12-16-2011, 06:40 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: What is the Smarty variable for Provider company name?

Quote:
Originally Posted by jake8804
I am making some progress on understanding this system of web design . I COULD run an SQL query directly from the template right now and get the info that way but that is undesirable, yes?

The query will be something like:

SELECT customers.company
FROM customers
JOIN products
ON customers.provider = products.provider;

And then the Smarty assign is:

$smarty->assign('company',$product);

How do I put them together?
Also, I have been trying to figure out which .php file to use to assign variables to $product...which one is it? I am more of a database guy than a web designer lol

Don't run php code from within the templates - bad practice and slows down everything. You need to find the function that puts the product info together in include/func/func.product.php and modify the query that gets all product info together (or add new one) to include provider's name. No need for other changes or smarty assigns - everythign is done for you by the function and the info will just add to $product array and eventually to $products array on products list pages
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #9  
Old 12-16-2011, 03:46 PM
 
jake8804 jake8804 is offline
 

Newbie
  
Join Date: Dec 2011
Posts: 6
 

Default Re: What is the Smarty variable for Provider company name?

This is from func.product.php:

$product = func_query_first("SELECT $sql_tbl[products].*, $sql_tbl[products].avail-$in_cart AS avail, MIN($sql_tbl[pricing].price) as price $add_fields FROM $sql_tbl[pricing] INNER JOIN $sql_tbl[products] ON $sql_tbl[pricing].productid = $sql_tbl[products].productid AND $sql_tbl[products].productid='$id' $join WHERE 1 ".$login_condition.$p_membershipid_condition.$pric e_condition." GROUP BY $sql_tbl[products].productid");

The problem is that, the way X-Cart is set up, there is no way to join the customers table (where the provider information is also stored) to the products table (where the only reference to the provider is an auto-increment in column products.provider). X-Cart should have put providers in a separate table; then you could easily have a connection between providers and products without creating a many-to-many relationship. Will I have to create an association class/table to eliminate the many-to-many relationship?
__________________
X-Cart 4.4.4 on Unix
Add-ons: Power Filter by *********, BCSE Shipping Per Product.
Reply With Quote
  #10  
Old 12-17-2011, 12:44 PM
 
jake8804 jake8804 is offline
 

Newbie
  
Join Date: Dec 2011
Posts: 6
 

Default Re: What is the Smarty variable for Provider company name?

I decided to just take the easy way out and create an extra field for every vendor/provider with a default value being their company name. Not ideal, but it works since I'll only have 10 to 20 vendors. I also created a "Shop by Vendor" category with the "Vendor" Extra Field linking to each vendor's page. I also made that extra field show up on the product list page. Good 'nuf. :p
__________________
X-Cart 4.4.4 on Unix
Add-ons: Power Filter by *********, BCSE Shipping Per Product.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 08:49 AM.

   

 
X-Cart forums © 2001-2020