Adding PHP and MySQL code

Is there a way to add my own php code and mysql queries in one of the “pages” I create?

Or, what folder and file is the code for the pages I create located?



I just want to be able to fetch data from a new table I created in the database and display the results in one of my “Pages”.

{php} your code {/php}



[url]Search Results for "docsv2" | Smarty

Well Jesse is right, you can write PHP code in a smarty page, but I don’t think that is what you are really after if I understand your post correctly.



Are you saying you created a table with Static data that won’t change, and you just want to put those results on the “Page” you created? Or are you saying your table you created will have data that will be changing or added to over tiem, and you want to write a query that may return different results each time?



I am thinking you probably want to change the fn.catalog.php and other core files to recognize your table and generate smarty variables for you, and then you can easily refer to your table fields something like this:



your_table_name.your_field

Unique2, you have the gist of it.



The reason for this is that on our old website we had products listed that people were not able to purchase - just informational products, no add to cart button. We are an aquarium store, and we don’t want to sell livestock online, but still provide information on each fish.



I wanted to just import our previous table from our old database, and just use the code to display the information. And since there’s thousands of fish, invertebrates, and corals, I’d implement ‘pagination’ in the page too.



Is any of this possible?



If not, is there a way to remove the Add to cart button on certain products only?

[quote name=‘fishtail’]

The reason for this is that on our old website we had products listed that people were not able to purchase - just informational products, no add to cart button. We are an aquarium store, and we don’t want to sell livestock online, but still provide information on each fish.[/QUOTE]



Yeah I get what you trying to do. You may want to look into SnoRocket’s CS-Cart Add-On Solution called “Knowledge Base 3.1” which is compatible with CS-Cart 2.0.11 now. You can view is awesome addon forum here [url]http://www.snorocket.com/forums/forum.php[/url] . You have to sign up first but its totally worth it. Knowledge Base allows you to make writeups about different things on your site so you can refer customers to it, and it makes you look really… “knowledgeable”… if you know what I mean… Sorry, I had to do it… haha.


[quote name=‘fishtail’]

I wanted to just import our previous table from our old database, and just use the code to display the information. And since there’s thousands of fish, invertebrates, and corals, I’d implement ‘pagination’ in the page too.



Is any of this possible?[/QUOTE]



Yeah, you can import tables in CS-Cart. It’s just a MySQL database. I would do it from phpMyAdmin if I were you. Then you just got to put your sql queries in you fn.search.php and fn.catalog.php and some other files in /core/ directory like before. I can help you more if you want I can post more info on this. … Darn I’ve really been meaning to provide a “Create your own custom table FAQ/Tutorial” for the Hints forum cause it gets asked all the time.


[quote name=‘fishtail’]

If not, is there a way to remove the Add to cart button on certain products only?[/QUOTE]



I think so…? Isn’t there something on the product addition page that say “Do Not allow customer to add product to cart” ?? I think you have to make the price of the item 0.00 and then when the customer looks at the “Product” then he/she won’t see a price and no add to cart button. I think its under Zero Price or something. Anyone know if that’s how it works?

Thanks so much unique! I downloaded knowledgebase, and it’s amazing, and exactly what I was looking for our knowledge base tool. I actually started coding a tool similar to that, myself. That saved me weeks of trouble!



And you’re other advice about “zero price” worked partly. The only thing that’s left to do is remove the “In stock” and “Out of stock” message when I enable zero price option. Any idea for the coding of that. I’d have to create an “if” statement in one of the scripts, but don’t know where.

My immediate thought is that you could put an if statement in the buy_now.tpl to not display those fields depending on some condition or criteria. I think the buy_now.tpl or the view.tpl has those fields in it.

I believe that setting the Inventory field in the Products General tab to “do not track” will prevent the “In Stock” / “Out of Stock” labels from displaying.