Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
gjh42
In tpl_product_info_display.php, the variable that holds the product's model number is $products_model. The brand would be $manufacturers_name.
There will be different variable names for these in some other pages like product listing, and some pages would not have the information readily available (if the page does not handle products).
Perfect, exactly what i was looking for. Is there a list anywhere of all the product page variables? The ones I need are:
Brand (check)
Part Number (check)
Product Name
Product Sale Price
Condition
Not all are required, but they'd be nice to have.
Thank you again for your help gjh!
Re: Help a newbie install a piece of javascript with product vars on a product page
Just look through tpl_product_info_display.php - most of the product variables there are remarkably intuitive.
"Condition" is not a standard Zen Cart database field or variable, so if you want that for every product you will need to do some serious modification. You might be able to hijack some other text field that you will not be using to carry the condition information.
The sale price is embedded in some very complex coding called with the zen_get_products_display_price() function, as it can depend on several other conditions as to what displays. There may be a function that can be used to retrieve just the sale price; if so, it would probably be found in /includes/functions/functions_lookups.php. DO NOT edit anything in that file!
I still think you are reinventing the wheel with what you are probably doing. Javascript is not the right way to handle basic page functionality; it can and should all be done with PHP.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
gjh42
I still think you are reinventing the wheel with what you are probably doing. Javascript is not the right way to handle basic page functionality; it can and should all be done with PHP.
I must agree with Glenn... I can't see what you are trying to achieve with all of this, that isn't already available to you - unless of course you are intending to use the ZC "engine" for different purposes from what it was intended.
The variables you have listed (with the exception of a few that are not part of the core Dbase schema) are ALREADY all possible to render in a product info page (and in many other places), and you have the "luxury" of being able to "switch" the majority of these on or off, via simple toggles in the webshop admin area. There are several HUNDRED configurable options available to you - either through these admin area switches, or via some very simple edits to existing php files.
So just WHY you are trying to re-invent the wheel is a puzzle.
But... you are free to make whatever changes you wish. It is OpenSource software afterall.
If you download a copy of the software and look in the zc_install folder, open the MAIN SQL file in a plain text editor, and you will see ALL the dbase tables and ALL the fields. This will give you an overview of what tables carry the variables you are after.
As Glenn says, JS is not the way to manage this... You should code your customisations in PHP.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
jhkaplan
Maybe I'm not explaining it correctly, but most of what you said above is wrong. But if you're not here to help, please move on. I'm looking for constructive help, not to be told I dont belong.
Everybody is welcome here, and I don't recall saying "you don't belong".
You said: "I'm pretty new to ZenCart, so I dont understand what you mean by 'switched on or off in various places in the admin panel."
... which to me is quite a direct admission that you do not know what you are doing (with Zencart).
My comments are frank, I admit, and I do not wish to offend, but if you have not even botherd to examine the user functions available to you, through an interface that a complete non-tecchie could understand, then one must assume you don't know how this system works.
So I do apologise if you took offence... but I still recommend you take some time to at least learn the basics of the admin area. To me that is fundamental of you intend to inflict (probably unneccessary) changes on the code.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
schoolboy
Everybody is welcome here, and I don't recall saying "you don't belong".
You said: "I'm pretty new to ZenCart, so I dont understand what you mean by 'switched on or off in various places in the admin panel."
... which to me is quite a direct admission that you do not know what you are doing (with Zencart).
My comments are frank, I admit, and I do not wish to offend, but if you have not even botherd to examine the user functions available to you, through an interface that a complete non-tecchie could understand, then one must assume you don't know how this system works.
So I do apologise if you took offence... but I still recommend you take some time to at least learn the basics of the admin area. To me that is fundamental of you intend to inflict (probably unneccessary) changes on the code.
I did see how to turn vars on/off in the admin, and knew immediately this is not what i was looking to do. I didnt take offense, i just hate internet commentors who waste time by not helping when someone asks for help, that's all.
Re: Help a newbie install a piece of javascript with product vars on a product page
Ok let's forget about the javascript part of it, I think it's throwing everyone off. If I were to just want to create a 'box' that had a list of all the product attributes I mentioned (brand, partnumber, price), what would that code look like? All i need is the text values, no styling, no borders, nothing.
In the PHP file, what is the minimum i'd need to get those 3 values to show up?
Re: Help a newbie install a piece of javascript with product vars on a product page
Sometimes what a question really needs is a swift kick and "you shouldn't be doing that, or doing it in that way", not enabling a wrong path.
From your PM, I see that you are trying to make some sort of "verified by" badge which is typically done with js. I should really have insisted on your explaining the actual business reason/result you wanted rather than just the detail of what variable you wanted to pick up; then we all would have understood what you were after.
Apparently this badge includes the display of the product name, model, brand, etc., though I don't see how or where from the demo you showed me.
Javascript does not import PHP variables directly. If you want to use the value of a PHP variable in js, you need to echo the variable.
Code:
// * Product Page Fields //
'Brand' : '$manufacturers_name',
'MPN' : '$products_model',
//'RetailerSKU' : '',
'ProductName' : '$products_name',
//'ProductPrice' : 'XXXXX',
//'Condition' : 'XXXXX',
//'StockStatus' : 'XXXXX'
}});
</script>
needs to be like
Code:
// * Product Page Fields //
'Brand' : '<?php echo $manufacturers_name;?>',
'MPN' : '<?php echo $products_model;?>',
//'RetailerSKU' : '',
'ProductName' : '<?php echo $products_name;?>',
//'ProductPrice' : 'XXXXX',
//'Condition' : 'XXXXX',
//'StockStatus' : 'XXXXX'
}});
</script>
Re: Help a newbie install a piece of javascript with product vars on a product page
You rock, that solved it. Thank you so much!
Re: Help a newbie install a piece of javascript with product vars on a product page
I see now what you are doing... you are pulling all of the technical info from the manufacturer's website and displaying it in tabs instead of saving it directly in your database and displaying it from there.