Jump to content

Dealer prices and inventory API


system53

Recommended Posts

Burti made a small software for those of us.

Some developing purchasing, etc I did.

 

The code is as follows.

 

<?php
header('Content-Type: text/html; charset=utf-8');

// AŞAĞI KISIMI DÜZENLEMEYİN
// DO NOT EDIT BELOW

// 10-45-21 ile başlayan alana ürün id'lerini girin, sağ tarafada bayi fiyatını girin
$products = array(
  10 => '350 TL',
  45 => '500 TL',
  21 => '110 TL',
  35 => '122 TL',
  85 => '235 TL',
  32 => '125 TL',
);
// ! AŞAĞI KISIMI DÜZENLEMEYİN
// ! DO NOT EDIT BELOW

require('configuration.php');
$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
$mysqli->set_charset('utf8');
if ($mysqli->connect_error) {
  die('Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error);
}

$type='';

if(count($products)>0){
  $ids = '';
  foreach($products AS $key => $val){
     $key = intval($key);
     $ids .= "id = '".$key."' OR ";
  }
  $ids = rtrim($ids,' OR ');
  $query = $mysqli->query("SELECT id,qty,name,description FROM tblproducts WHERE $ids");
  if(isset($_REQUEST["type"])){
     if($_REQUEST["type"] == 'json'){
        $type='json';
     }
  }
  $rowJson = array();
  if($type == ''){
     echo '<table>
     <thead>
        <tr>
           <th>ID</th>
           <th>QTY</th>
           <th>NAME</th>
           <th>DESC</th>
           <th>SPECIAL PRICE</th>
           <th>ORDER</th>
        </tr>
     </thead>
     <tbody>
     ';
  }
  while($row=$query->fetch_assoc()){
     $row["price"] = $products[$row["id"]];
     if($type == 'json'){
        $rowJson[] = $row;
     }else if($type == ''){
        echo '
           <tr>
              <td>'.$row["id"].'</td>
              <td>'.$row["qty"].'</td>
              <td>'.$row["name"].'</td>
              <td>'.$row["description"].'</td>
              <td>'.$row["price"].'</td>
              <td><a href="cart.php?a=add&pid='.$row["id"].'?type=json"target="_blank">Order</a></td>
           </tr>
        ';
     }
  }
  if($type == ''){
     echo '</tbody></table>';
     die();
  }
  if(count($rowJson) > 0){
     die(json_encode($rowJson));
  }

}


 

In sight everything works fine.

But normally should be like this.

 

Your link to the end of any products "?type=json" is added. the dealer price is not specified.

 

So the following should be like.

 

Regular Price: 200 USD - https://WHMCS/cart.php?a=add&pid=1

Dealer Price: 100 USD - https://WHMCS/cart.php?a=add&pid=1?type=json ( The price doesn't change. )

 

 

Thank you in advance.

Is there something that is missing in the software.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated