| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
What is the Smarty variable for Provider company name? | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() 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. |
|||||||
#2
|
|||||||
|
|||||||
![]() 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. |
|||||||
#3
|
|||||||||
|
|||||||||
![]() 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. |
|||||||||
#4
|
|||||||
|
|||||||
![]() I am making some progress on understanding this system of web design
![]() 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. |
|||||||
#5
|
|||||||||
|
|||||||||
![]() 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. |
|||||||||
#6
|
|||||||
|
|||||||
![]() 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. |
|||||||
#7
|
|||||||||
|
|||||||||
![]() 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. |
|||||||||
#8
|
|||||||||
|
|||||||||
![]() Quote:
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 |
|||||||||
#9
|
|||||||
|
|||||||
![]() 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. |
|||||||
#10
|
|||||||
|
|||||||
![]() 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. |
|||||||
|
|||
X-Cart forums © 2001-2020
|