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

Trying to understand the coding

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-29-2014, 02:03 PM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default 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
__________________
Version 4.7.2
Reply With Quote
  #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
  #3  
Old 05-30-2014, 03:22 AM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default 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
__________________
Version 4.7.2
Reply With Quote
  #4  
Old 05-30-2014, 07:46 AM
 
Thomasb134 Thomasb134 is offline
 

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

Default 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.
__________________
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
  #5  
Old 05-30-2014, 08:30 AM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default 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
__________________
Version 4.7.2
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 07:39 AM.

   

 
X-Cart forums © 2001-2020