Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display price from database


Guest

Recommended Posts

Hello all,

 

I am relatively new to php coding - I've become decent at dissecting the code I'm looking at; however, I have never been good at all the logic behind it all and writing code from complete scratch. I have a problem I have been trying to resolve on my own reading through the board and searching google and yahoo but I come up blank every single time. Like I said I'm not great at coding from scratch so if anyone is kind enough to help me with my problem I'd need as straightforward and simple an answer as possible.

 

My issue is that I'd like to create a custom page for my site(also the code I require would go into an email newsletter) that displays MANY products on it. It really won't have an product information displayed other than the price and an add to cart button. I've found the way to add a specific item to the cart with the following code from the HTML output of a specific test product info page:

 

<form name="cart_quantity" action="http://frag-addicts.com/store/product_info.php?products_id=1&action=add_product" method="post"> <table border="0" cellpadding="0" cellspacing="0" width="100%">

<tbody>

<tr>

<td><table class="infoBox" border="0" cellpadding="2" cellspacing="1" width="100%">

<tbody><tr class="infoBoxContents">

<td><table border="0" cellpadding="2" cellspacing="0" width="100%">

<tbody><tr>

<td>

<input name="products_id" value="1" type="hidden"> <input src="product_info.php_files/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " border="0" type="image"></td>

</tr>

</tbody></table></td>

</tr>

</tbody></table></td>

</tr>

</tbody></table>

</form>

 

The thing I do NOT know how to do is call that very same specific items price from the database. The whole OSC setup is written to call all the information on the page load...I'm just not bright enough to figure out how the heck to code it so it displays the product price...

 

I'd also like to be able to take the price and multiply it by a percentage to achieve a new price(reason being is I need the same products price displayed twice...both times changed by a percentage basically for a "what we'd buy it for" price and then a "what we'd sell it for" price) if this is even possible.

 

Can anyone please help? I've been looking all over and feel like a complete idiot since it's the one thing I can't seem to figure out.

 

Thanks in advance.

 

- Scott

Link to comment
Share on other sites

What frequency are you anticipating sending the newsletter? Depending on this and how many products you may want to just hard code the prices??

I know it's not the answer you were looking for but it may be quicker and easier

 

Just a thought.

dubz

 

Seriously...? NOBODY will respond? ..................................
Link to comment
Share on other sites

Hmm well what exactly do you mean by hard code the prices? I also have another project I'm anticipating using OSCommerce for but the individual product info pages won't be suitable for it. There will be too many products in each section to simply click the categories link and display. A buddy of mine wants me to make a coin website for his collectible coin business. So what I'd like to do is just put a price and add to cart button in the same table cell. Each coin comes in various condition grades so I'd have a table with roughly 4 or 5 columns each containing a price and add to cart button. So when you said hard code the price it may just be what I'm looking for and I didn't describe it right?

 

I'd just like to be able to have the price for "product 1" and the add to cart button for "product 1" but I just don't know how to get the price to display...

Link to comment
Share on other sites

Hmm well what exactly do you mean by hard code the prices? I also have another project I'm anticipating using OSCommerce for but the individual product info pages won't be suitable for it. There will be too many products in each section to simply click the categories link and display. A buddy of mine wants me to make a coin website for his collectible coin business. So what I'd like to do is just put a price and add to cart button in the same table cell. Each coin comes in various condition grades so I'd have a table with roughly 4 or 5 columns each containing a price and add to cart button. So when you said hard code the price it may just be what I'm looking for and I didn't describe it right?

 

I'd just like to be able to have the price for "product 1" and the add to cart button for "product 1" but I just don't know how to get the price to display...

 

By hard coding he means inserting the prices yourself .. no database calls ... when designing it you just insert the prices that each item will cost manually..

Link to comment
Share on other sites

I have also been trying to get the answer to the question for weeks. :blink:

 

I was beginning to suspect I was being ignored for being too ignorant. :huh:

 

I have separate prices by quantity and am trying to find out how to display just the lowest price instead of the highest price.

 

Anyway - let me know if you find out and I'll do the same! :)

Link to comment
Share on other sites

I will certainly let you know IF I ever get an answer to this question. I find it hard to believe that nobody has posted an answer to this...with all the other stuff you see people doing on here SOMEONE here has to friggen know how to do this. I apologize if I'm just too ignorant for the rest of the community - SOMEONE please be kind enough to instruct me how to do a database call for a specific items price using the product id. It really doesn't do me any good to manually insert the items price because it doesn't save me any time...the products prices are in constant flux...changing ATLEAST once a week. It's too inefficient to change the items price in TWO places...

Link to comment
Share on other sites

SOMEONE please be kind enough to instruct me how to do a database call for a specific items price using the product id.

 

FOR PRODUCT WITH PRODUCT ID 312:

 

MYSQL command:

select products_price from `products` where products_id = '312';

 

OSCommerce PHP command:

<?php
$db_query = tep_db_query('select products_price from ' . TABLE_PRODUCTS . ' where products_id = "312"');
?>

 

That will place the database call into $db_query ... then just grab the value from there ...

Link to comment
Share on other sites

betatech

 

In response the below quoted post in regards to your 'coin project'.

 

Have you looked into using attributes? It can be used in many different ways and may be work for you. Let's say you take a coin in the worst quality and make that your base price. Then every 'upgrade' for the same coin would be an adder of $x.xx. This can be easily done and you'd be able to 'add to cart' for a particular coin in a certain condition.

 

I'd suggest reading page 19 of the manual which can be downloaded with the OsC package Here

 

In regards to your 'hard coded' question, slav got it on the nose.

 

|dubz|

 

Hmm well what exactly do you mean by hard code the prices? I also have another project I'm anticipating using OSCommerce for but the individual product info pages won't be suitable for it. There will be too many products in each section to simply click the categories link and display. A buddy of mine wants me to make a coin website for his collectible coin business. So what I'd like to do is just put a price and add to cart button in the same table cell. Each coin comes in various condition grades so I'd have a table with roughly 4 or 5 columns each containing a price and add to cart button. So when you said hard code the price it may just be what I'm looking for and I didn't describe it right?

 

I'd just like to be able to have the price for "product 1" and the add to cart button for "product 1" but I just don't know how to get the price to display...

Link to comment
Share on other sites

Forgot to note- page 19 of the PDF named "documentation"

 

|dubz|

 

 

betatech

 

In response the below quoted post in regards to your 'coin project'.

 

Have you looked into using attributes? It can be used in many different ways and may be work for you. Let's say you take a coin in the worst quality and make that your base price. Then every 'upgrade' for the same coin would be an adder of $x.xx. This can be easily done and you'd be able to 'add to cart' for a particular coin in a certain condition.

 

I'd suggest reading page 19 of the manual which can be downloaded with the OsC package Here

 

In regards to your 'hard coded' question, slav got it on the nose.

 

|dubz|

Link to comment
Share on other sites

Kristy

 

If you have not already I'd suggest looking into this contribution, I have not used it but it looks like it may suit your needs assuming you have not implemented price breaks by quantity??

 

|dubz|

I have also been trying to get the answer to the question for weeks. :blink:

 

I was beginning to suspect I was being ignored for being too ignorant. :huh:

 

I have separate prices by quantity and am trying to find out how to display just the lowest price instead of the highest price.

 

Anyway - let me know if you find out and I'll do the same! :)

Link to comment
Share on other sites

Kristy

 

If you have not already I'd suggest looking into this contribution, I have not used it but it looks like it may suit your needs assuming you have not implemented price breaks by quantity??

 

|dubz|

 

 

Hi Thanks for answering I have done the

"Simple Price Break" mod...

 

ie price breaks by quantity ordered...

 

However, most people order a large quantity of products

and small qty are dearer as it is much less economical to break up cartons,

but some people don't need a carton so

I want to be able to offer single items.

 

does that make sense?

 

ie 1-49 items $6- ea

50+ $2.95 ea.

 

I would like to show the price as "Priced from $2.95 ea.

Link to comment
Share on other sites

Kristy-

 

It makes sense, unfortunately due to my lack of use of this contribution, I wouldn't be able to answer that question. Maybe try contacting the author??

 

|dubz|

 

Hi Thanks for answering I have done the

"Simple Price Break" mod...

 

ie price breaks by quantity ordered...

 

However, most people order a large quantity of products

and small qty are dearer as it is much less economical to break up cartons,

but some people don't need a carton so

I want to be able to offer single items.

 

does that make sense?

 

ie 1-49 items $6- ea

50+ $2.95 ea.

 

I would like to show the price as "Priced from $2.95 ea.

Link to comment
Share on other sites

betatech

 

In response the below quoted post in regards to your 'coin project'.

 

Have you looked into using attributes? It can be used in many different ways and may be work for you. Let's say you take a coin in the worst quality and make that your base price. Then every 'upgrade' for the same coin would be an adder of $x.xx. This can be easily done and you'd be able to 'add to cart' for a particular coin in a certain condition.

 

I'd suggest reading page 19 of the manual which can be downloaded with the OsC package Here

 

In regards to your 'hard coded' question, slav got it on the nose.

 

|dubz|

 

I have actually looked at using attributes. Unfortunately it becomes too tedious and defeats the purpose of calling the price from the database to speed things up. The way I intend to design the site is to NOT have an individual product_info.php page for each product because there are simply way too many products. US Coin Collectors have thousands of coins to collect when you start combining denomination and dates. It just makes it way easier to sort through when you display the whole list of coins in a table. For instance the grades sold for Lincoln Wheatback Pennies are from 1909 - 1959 and come in up to 6 different grades. So my table would look something like this:

 

 

Year G VG F VF XF AU Unc

1909 $ $ $ $ $ $ $

1909-S $ $ $ $ $ $ $

 

 

And so on down the line. What I've had absolutely no clue how to do is where you see the $ call the appropriate price. The code given to me above hasn't worked on my test page so I'm obviously doing something wrong. And then I'm too ignorant to figure out how I would do MULTIPLE calls like that and display the right price.

 

<?php
$db_query = tep_db_query('select products_price from ' . TABLE_PRODUCTS . ' where products_id = "312"');
?>

 

and then echoing $products_price didn't work. You'll have to forgive me I'm just so new to PHP and can't seem to find any real explanations to my questions even in books or online tutorials. When I want to call 1909 in G condition and I put the code in, how do I go about placing the next call 1909 in VG condition without duplicating the G condition price call? And on top of that what I tried just didn't work at all. Nothing pops up in the spot I put the echo price code...

 

I do apologize again for being so ignorant to all this but if I can get a clear cut example that works here I can easily figure the rest out. This is just my roadblock and I don't understand 100% how this all works and if I'm missing something. :unsure:

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...