Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate product stock in uniCenta oPos 3.70 #1

Open
roopendra opened this issue Oct 26, 2014 · 0 comments
Open

Validate product stock in uniCenta oPos 3.70 #1

roopendra opened this issue Oct 26, 2014 · 0 comments

Comments

@roopendra
Copy link

First I would like to give many thanks for your great effort to making unicenta web frontend in PHP. I am using your code. Everything seems to work for me except few changes on db connection script.

I am facing problem while validating product stock using instock function. in uniCenta oPos 3.70 there is no table found named VARIATIONSET and VARIATION. Do you have any idea in this ? Thanks !!

function instock($dbc, $productId, $variationFlag = false)
{
    /* Checks if a product is in stock by looking
     * for at-leat ONE item instock for the $productId in 
     * the VARIATIONSET table.
     * 
     * If the $variationFlag is set, $productId is presumed to be a 
     * variationset id, in the VARIATIONSET table. The function then  checks only 
     * the specified product variation stock level, for example 
     * only checking a 'Black T-shirt' in size 'small'
     */
     $productId = cleanString($dbc, $productId);

     $q = "
     SELECT VALUE,
        ATTRIBUTEVALUE.ID AS 'AttrId'
        FROM PRODUCTS
        JOIN VARIATIONSET ON
        PRODUCTS.ID = VARIATIONSET.FK_PRODUCT_ID
        JOIN VARIATION ON
        VARIATIONSET.ID = VARIATION.FK_VARIATION_SET
        JOIN ATTRIBUTEVALUE ON
        VARIATION.FK_ATTRIBUTE_VALUE = ATTRIBUTEVALUE.ID
        JOIN ATTRIBUTE ON
        ATTRIBUTEVALUE.ATTRIBUTE_ID = ATTRIBUTE.ID
        WHERE PRODUCTS.ID = '$productId'
        AND VARIATIONSET.STOCK_LEVEL > 0
        GROUP BY VALUE";

    if($variationFlag)
    {
        $q = "SELECT STOCK_LEVEL FROM VARIATIONSET 
            WHERE ID = '$productId'";
    }//End $variationFlag is set, only check stock level for that specific product variation

    $r = mysqli_query($dbc, $q);

    if(mysqli_num_rows($r) > 0) //Atleast one product variation in-stock
    {
        return true;
    }else{
        return false; //Product is not in-stock
    }

}//End instock($dbc, $productId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant