Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Stock Script similar to NodeDeploy / BuyVM
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Stock Script similar to NodeDeploy / BuyVM

zafouharzafouhar Veteran
edited December 2012 in General

I have seen that NodeDeploy and BuyVM have scripts that show the stock status and i was wondering if there is a similar script somewhere available to download/purchase?

Thx

«1

Comments

  • zafouharzafouhar Veteran
    edited December 2012
  • Code it yourself?

  • I believe BlueVM released his script...

  • @HalfEatenPie said: Code it yourself?

    Hey, why are you using that browser you're using just now?

    Code one yourself?

  • Not sure how you would do it but i bet its possible to pull those stats from the WHMCS stock level system and display them externally.

  • @gubbyte said: Hey, why are you using that browser you're using just now?

    Code one yourself?

    I will admit, I don't have any response to this. Touche sir.

  • @GetKVM_Ash said: Not sure how you would do it but i bet its possible to pull those stats from the WHMCS stock level system and display them externally.

    That's what I always imagined was being done.

  • I did find some code from Matt from WHMCS:

    $query = "SELECT qty FROM tblproducts WHERE id='1'"; $result=mysql_query($query); $data = mysql_fetch_array($result); $qty = $data['qty']; if ($qty=="0") { echo("Currently Out Of Stock"); } else { echo("$qty Available"); }

    But the question for me is what is next, i don't really know a lot of coding.

  • Just change

    WHERE id='1'"

    To reflect the product ID in WHMCS.

  • gameongameon Member
    edited December 2012

    is it really required to pull from WHMCS ? if my guess is right the site 'doesbuyvmhavestock.com' when it started was not affiliated to buyvm , yet they could pull the live stats.

    i'm not sure about it though , may be @Francisco can help :)

  • Yep i know that ;) @GetKVM_Ash

    What i am unsure currently is how to get that to display in my stock.php page

  • @zafouhar said: What i am unsure currently is how to get that to display in my stock.php page

    DB connect?

  • You just need to establish a MYSQL connection (Loads of tutorials for that around) and use that code within the PHP code.

    Im not much of a coder myself but i recon its that simple.

  • Yes seems i just managed to code something despite my very limited knowledge:

    <?php $con = mysql_connect("localhost","myusername","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } $query = "SELECT qty FROM tblproducts WHERE id='1'"; $result=mysql_query($query); $data = mysql_fetch_array($result); $qty = $data['qty']; if ($qty=="0") { echo("Currently Out Of Stock"); } else { echo("$qty Available"); } // mysql_query($sql,$con); // some code mysql_close($con); ?>

  • kamalnasserkamalnasser Member
    edited December 2012

    lowendstock.com

  • And i get an error:

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/username/public_html/stock.php on line 10

  • Or just scrape dem pages

  • @zafouhar - Here's some example code for you that will list all of your products in a table.

    http://pastie.org/private/yzzcx25vbg0bspeudyk5a

    Simply fill in the database information and it will display all of your non-hidden products and how much stock they have left. You can apply whatever template you like. I will probably make this into a whmcs "addon" at some point.

  • Thx for that @BlueVM however i get the following error:

    Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/public_html/stock.php on line 17

  • joepie91joepie91 Member, Patron Provider

    @zafouhar said: Thx for that @BlueVM however i get the following error:

    Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/public_html/stock.php on line 17

    That means there were no results from the database query.

  • I coded the NodeDeploy one, I need to recode it at some point.

  • But if i run the query SELECT * FROM tblproducts WHERE hidden != 'on' via phpmyadmin for example it returns 2 rows which is currently correct. @joepie91

  • Is it using the same database user as WHMCS (aka permissions?) or a different database user?

  • Try adding echo mysql_error(); after the mysql_query() line to see the error.

    @joepie91 said: That means there were no results from the database query.

    That means that there was an SQL error.

  • @zafouhar said: But if i run the query SELECT * FROM tblproducts WHERE hidden != 'on'

    @zafouhar said: $query = "SELECT qty FROM tblproducts WHERE id='1'";

    These are two different queries. Do you have a product with ID = 1?

  • I am using the same database user as WHMCS is using @HalfEatenPie

    Yes i have a product with id of 1 @Damian

    I've tried adding echo myself_error() but the message i get remains the same @kamalnasser

  • BlueVMBlueVM Member
    edited December 2012

    @zafouhar - I actually pasted the wrong piece of code try this one instead:

    http://pastie.org/private/2dusfny2urbxf3nkcikumw

    Tested working: https://bluevm.com/test.php

  • DamianDamian Member
    edited December 2012

    If this is going to be part of your WHMCS template, also see http://docs.whmcs.com/SQL_Helper_Functions

    If not going to be part of your WHMCS template, please use mysqli at least, see the BRW at http://us1.php.net/mysql_query

  • You just need to establish a MYSQL connection (Loads of tutorials for that around) and use that code within the PHP code.

    Do not enter the db details there, you have no need to. Include dbconnect.php, you can just fetch results with your query after that.

  • Ok it now works with the updated script that @BlueVM just provided, thx @BlueVM for providing the script and everyone else!

Sign In or Register to comment.