Beispiel #1
0
<?php

require "../pos-dbc.php";
require_once "../functions.php";
checkAuth();
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE ^ E_DEPRECATED);
$code = mysql_real_escape_string($_POST['code']);
$result = mysql_query("SELECT * FROM inventory WHERE product_code = '{$code}' LIMIT 1;") or die(mysql_error());
$response = new stdClass();
if (mysql_num_rows($result) > 0) {
    $row = mysql_fetch_assoc($result);
    $response->response = $row;
    if (isset($_POST['time'])) {
        //check the discount
        $discount = get_disc($_POST['time'], $row);
        $response->response["product_disc"] = $discount;
        if ($discount > 0) {
            //renamed name to display disount
            $response->response["product_name"] = "{$row["product_name"]} ({$discount}% OFF)";
        }
    }
} else {
    $response->error = "This product was not found";
}
echo json_encode($response);
//merged discount-checker-function from ajax/get-discount.php
function get_disc($time, $data)
{
    $discount = 0;
    $p = $data["product_code"];
    $c = $data["product_category"];
Beispiel #2
0
 function the_disc($d)
 {
     $slug = $d["slug"];
     echo '<div class="disc product ' . get_disc($slug, 'slug') . '" data-product-slug="' . get_disc($slug, 'slug') . '"><a href="' . get_disc($slug, 'link') . '">' . get_disc($slug, 'thumbnail') . '</a><img class="remove-from-bag" src="' . get_stylesheet_directory_uri() . '/images/trash-icon.gif" alt="remove" /><span class="disc-name">' . get_disc($slug, 'name') . '</span></div>';
 }