Announcement

Collapse
No announcement yet.

Query Database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Query Database

    Does anyone know how to query the 3dcart database for product availability information? Basically, I know the product code, but I want to find out whether it is in stock, or not. (And then do something in the HTML code, depending on whether the product is in stock, or not.) In essence, I need to know how to send the query and then respond to the result. I'm a Delphi programmer, so in Delphi it's pretty simple:

    If ProductInStock then
    Do Something
    Else
    Do Something Else.

    Can this be done?

    Here's a more realistic example:

    If ProductInStock then
    HTML text colored GREEN
    Else
    HTML text colored RED
    www.stsi.com
    Network Infrastructure and Fiber Optics (AMP/Tyco, APC, Belden, Corning, Hubbell, Leviton, Ortronics, Panduit), Audio, Computer, and Video Cables, and much more!

  • #2
    Depending on what you are trying to do exactly, there is very simple solutions ie. You can set the "IN STOCK" variable on the language to be "<font color=green>IN STOCK</font>" so it will display green for you on the product page.

    You could also add a hidden field inside the form on the listing template

    HTML Code:
    <input type=hidden value="[stock]" name=mystock>
    and now you have a hidden text field with the stock, you could do some javascript to check the value and make changes to the page

    HTML Code:
    if (document.myform.mystock.value>0)
    {
    
    }
    Last, you could use the API, but this is going to require that you learn webservices. Its not a bad idea to learn if you are a programmer, because everyone is using web services now, but, yeah its going to be a big learning curve.

    Link to the api:

    https://support.3dcart.com/index.php...emid=127&nav=0
    ----------------------------
    Gonzalo Gil
    3dCart Support
    800-828-6650 x111

    Comment


    • #3
      The problem I have is that I want to use this code on an extra page. (So the [stock] variable doesn't seem to work.) How do I tell the system that I want to get status on a particular product number? (At that point, I can use the [stock] variable, or any other variable for that matter.)
      www.stsi.com
      Network Infrastructure and Fiber Optics (AMP/Tyco, APC, Belden, Corning, Hubbell, Leviton, Ortronics, Panduit), Audio, Computer, and Video Cables, and much more!

      Comment


      • #4
        Yeah, that won't work, [stock] is a field that depicts the # of items in stock for a product, so, it would never work on a content page since there is no way to associate a content page to a product the software would have no idea that you wanted the stock of a particular product there so it would ignore the [stock] tag.

        For this specific task, then yes, the API would be the way to go, you could make a script that queries the API, and call that script with AJAX on the page passing the part# and it would return the stock.
        ----------------------------
        Gonzalo Gil
        3dCart Support
        800-828-6650 x111

        Comment


        • #5
          Yes, that's exactly the problem I'm seeing. (On the extra pages, these variables don't seem to work, since there was not way to tell the software what product I wanted to get the results for...)

          I see that we can use different listing templates for particular products. Would it be possible to modify one of those templates for my purpose, since they do have access to the product information? (On the other hand, I still don't understand how I would get information about a specific set of products.)

          Here is a link to EXACTLY what I am trying to accomplish: http://store.stsi.com/Panduit-Jack-C...nce_ep_48.html

          The table that you see has links to a bunch of products on our store. However, because of limited quantities on some of these products, I'd like to change the link color (or possibly disable the link entirely) on products that aren't in stock. If I could query the database to find out whether each of these products is in stock, this would be easy. Unfortunately, this doesn't appear to be easy, so far. :)

          I know a little javascript, but not ajax. I'll look into the API a little more.
          www.stsi.com
          Network Infrastructure and Fiber Optics (AMP/Tyco, APC, Belden, Corning, Hubbell, Leviton, Ortronics, Panduit), Audio, Computer, and Video Cables, and much more!

          Comment

          Working...
          X