View Single Post
  #2  
Old 05-29-2014, 03:37 PM
 
Thomasb134 Thomasb134 is offline
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 789
 

Default 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.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
xcartmods reCAPTCHA for X-Cart Classic
Unix, PHP 7.0 (patched 5.4).
MySQL 5.6
Reply With Quote