House1234

+Clients
  • Content count

    2
  • Joined

  • Last visited


House1234's Activity

  1. House1234 added a post in a topic: Nexus Adjust Stock via API   

    Thanks for that :)
     
    In the end I gave up and ended up doing it this way... I tested it on my dev system and it seemed to work ok, have been live with it for the last two days.
    <?php class stock { function __construct() { //Try to connect to the SQL database try { $this->dbh = new PDO('mysql:host=host;dbname=db', 'username', 'password'); } //If the connection failed catch(PDOException $e) { //Print the error message print "Error!: MySQL Connection Error, Please try again or tell an Admin! <br/>"; //Kill the script die(); //End of MySQL connect } } /* * Query Manager */ public function query($query, $attr = false) { $stmt = $this->dbh->prepare($query); (is_array($attr)) ? $stmt->execute($attr) : $stmt->execute(); return $stmt; } function debug($on, $data) { if ($on) { echo "<br />" . $data . "<br />"; } } /* * $id: package ID * $amount: Amount stock should be adjusted to * $debug: print messages to screen/Cron Log */ function adjustStock($id, $amount, $debug = FALSE) { //If both the id and amount are a number if (is_numeric($id) && is_numeric($amount)) { //Check for a package with the given id try { $stmt = $this->query("SELECT p_id, p_stock FROM nexus_packages WHERE p_id = :p_id", array(':p_id'=>$id)); } catch (Exception $e) { throw new Exception("Error Processing Request", 1); } $data = $stmt->fetch(PDO::FETCH_ASSOC); $currentAmount = $data['p_stock']; //If a package is found with the given id if ($stmt->rowCount() > 0) { //Check if the stock needs updating if ($currentAmount <> $amount) { //Update the stock try { $stmt = $this->query("UPDATE nexus_packages SET p_stock = :amount WHERE p_id = :p_id", array(':p_id'=>$id, ':amount'=>$amount)); } catch (Exception $e) { throw new Exception("Error Processing Request", 1); } //If the stock was updated if ($stmt->rowCount() > 0) { $this->debug($debug, "1. Package: $id has had it's stock set to $amount"); } else { $this->debug($debug, "2. Package: $id could have it's stock set to $amount"); } } else { $this->debug($debug, "3. Package: $id already has $amount in stock"); } } else { $this->debug($debug, "4. Package $id was not found in the database"); } } else { $this->debug($debug, "5. Both the Package and the Amount must be numeric"); } } } $stock = new stock; //$stock->adjustStock(2, 4, TRUE); $stockToAdjust = array( //Package 1 Example array(27, 5), //Package 2 example array(28, 7), ); //print_r($stockToAdjust); $debug = FALSE; foreach ($stockToAdjust as $row) { $stock->adjustStock($row[0], $row[1], $debug); } ?>
  2. House1234 added a post in a topic: Nexus Adjust Stock via API   

    Hey,
     
    Due to the high cost of some of our products and getting charge backs we are losing money (We have MaxMind Anti Fraud and the strict fraud rules). Because of this I would like to set the product stock to around 5. This way only 5 products can be brought a day, every 24 hours I would run a Cron job to reset the stock.
     
    I was looking through the API documentation for Nexus but I could not find a function to Adjust the stock for a product. Just wondering if there is one?
     
    Reason I want to use the API and not just modify the column in the database via a SQL Statement of my own creation is because I don't know if there are audit logs of stock change, or if anything else needs to be changed at the same time.
     
    Table is: nexus_packages
    Column is: p_stock
     
    Any help would be much appreciated.
  3. House1234 added a post in a topic: User Group Access   

    hold the ctrl button when clicking on groups.
  4. House1234 added a post in a topic: Rare   

    Hey, Brilliant Skin.
     
    But noticed when a user has a long name this happens
     

  5. House1234 added a post in a topic: Additional pay gateways needed   

    Google Checkout would be great!

About Me

Status Feed