![]() |
Trying to understand the coding
Guys
I have been looking at the coding, take for example from product.details, what I am trying to understand is where is $product.weight come from, because the database is like xcart_products, so I would expect it to look like $xcart_products.weight, where weight is is the field name I just can't work out where the $product.weight come from. {if $product.weight ne "0.00" or $variants ne ''} I can understand the class=, that looking in the css file Can anyone point me in the right direction I would like to learn a bit more about how it all works Kind regards Peter |
Re: Trying to understand the coding
Big picture view: The table names that are used by the database do not need to match the names assigned in variables or arrays.
Up close and personal: The xcart_products database records have details to ALL your products and have fields for things like the weight. But when a customer is viewing a single catalog page or adding items to the shopping cart an array is created to store the data about the item. The $product array has just the details needed about products being viewed/ordered. This array name could have been called anything; In this case it was called $product since that provides a hint to us mortals on what sort of data it might be. The php code would store the product's weight as $product['weight']. This array variable is called $product.weight in the template code. They are the same thing, just written differently as required by the file type. It helps to find a variable by using a file text search tool. My favorite text editor is Notepad++ and it has such a feature built into it. I start with webmaster mode to get half a clue about the name I should hunt down. Overall the variable name search process is a mix of good old CSI and luck. :) I did a search and one example of populating the $product array is found in \include\func\func.product.php. But there are other files where the data in the $product array is assigned too. FWIW, I can empathize with your struggles. I've been writing embedded firmware for decades, but this php, smarty, and template stuff is foreign to me too. I can manage to handle most of my required customizations but have to avoid the tough stuff. |
Re: Trying to understand the coding
Thomas, Thomas, Thomas what a mind field, thank you so much for taking the time to reply to me I am very greatful. In my mind it's so simple to do but might take me a lifetime to work it out in x-cart lol.
I wouldn' betting that product.list and product.details were written by to differant people because it looks so differant In my own words this is what I want. The idea is to check the product file and skip some wording if ther is anything in the shipping_freight i.e. in product.details somethere under "Our price", here goes. {if xcart_products.shipping_freight > ""} <p> Postage ё8.95 etc etc </p> {/if} > was greater than. Simple, but not in x-cart. Anyway I use Ultraedit, I did look in \include\func\func.product.php and it gives me an idea, the idea is "keep away" lol Thanks again I will battle on Kind regards Peter |
Re: Trying to understand the coding
I used webmaster mode and confirmed the correct name for the freight variable used on a catalog page is $product.shipping_freight. Use this instead of xcart_products.shipping_freight seen in your prototype example.
Please keep in mind that the table names in the xcart database (like xcart_products) are rarely the same names that are assigned after the data is retrieved from the database. The xcart_products data is read into an array and the name used for the array variable can be anything (in this case it is $product[]). There are many member elements (fields) in the $product array (weight, color, price, etc.) and in xcart these usually retain the same name used in the database (but not always!). Webmaster mode will help you hunt down the variable names that need to be used. There's three layers to xcart. (1) Data is stored in SQL tables. (2) To get to the data you need a programming language that can perform the I/O task (read/write data to the database) and do the major logic and math. The HTML language cannot do this on its own. But php is perfect for this job since it is made for database based web applications. (3) The tpl and css files are used to make it look pretty to the human observer. Of course the dirty business inside these three things is where the fun begins. |
Re: Trying to understand the coding
I do use webmaster quite a bit, I will do more studing thanks for all your help in pointing me to the right place and a better understanding
Peter |
All times are GMT -8. The time now is 04:32 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.