Beispiel #1
0
                $form_buy[$index]->add('Submit', 'submit')->value("Ajouter au panier");
                $form_buy[$index]->bound($_POST);
                //construct a array with the product_id
                array_push($tbx_index, $index);
            }
        }
        //end of for loop in cat
        $error_buy = array();
        $msg_confirm = array();
        foreach ($tbx_index as $value) {
            //which product user wants to buy
            if ($form_buy[$value]->is_valid($_POST)) {
                $infos_product_tobuy = infos_product($value);
                //Dont have enough money in the account
                if (user_balance($_SESSION['id']) < $infos_product_tobuy['product_price']) {
                    $error_buy[] = "Solde insuffisant pour acheter cet objet, vous pouvez recharger votre compte dans la partie Banque";
                } elseif (uniq_prdct_in_cart($value, $_SESSION['id']) != 0) {
                    add_product_incart($value, $_SESSION['id']);
                    $msg_confirm[] = "Achat effectué avec succès, vous disposiez déjà de ce produit dans votre inventaire, votre achat s'est ajouté à votre stock déjà existant";
                } else {
                    buy_product($value, $_SESSION['id']);
                    $msg_confirm[] = "Achat effectué avec succès, le produit a été ajouté a votre inventaire.";
                }
                //end of user_balance
            }
        }
        //end of foreach
        include PATH_VIEW . 'view_store.php';
    }
}
//end of user_connected
Beispiel #2
0
            $form_buy[$index] = new Form('form_buy' . $index);
            $form_buy[$index]->method('POST');
            $form_buy[$index]->add('Submit', 'submit')->value("Ajouter au panier");
            $form_buy[$index]->bound($_POST);
            //construct a array with the product_id
            array_push($tbx_index, $index);
        }
        include PATH_VIEW . 'view_table.php';
    }
    //end of for loop in cat
    $error_buy = array();
    foreach ($tbx_index as $value) {
        //which product user wants to buy
        if ($form_buy[$value]->is_valid($_POST)) {
            $infos_product_tobuy = infos_product($value);
            //Dont have enough money in the account
            if (user_balance($_GET['id']) < $infos_product_tobuy['product_price']) {
                $error_buy[] = "Solde insuffisant pour acheter cet objet, vous pouvez recharger votre compte dans la partie Banque";
            } elseif (uniq_prdct_in_cart($value, $_GET['id']) != 0) {
                buy_product($value, $_GET['id']);
            } else {
                add_product($value, $_GET['id'], uniq_prdct_in_cart($value, $_GET['id']));
            }
            //end of user_balance
            //echo print_r(infos_product($value));
            //buy_product($value,$_GET['id'],nbr_portion_prdct($value));
            include PATH_VIEW . 'view_store.php';
        }
    }
}
//end of user_connected