marksling posted on 2008-10-08 08:49:08 #
Hi Olaf,
I use the db_cart_example_btn_only.php but when i insert a new row i don't get the message $msg[11] = "Added the product to your cart."; from the db_cart_class.php. The row is inserted in the database but i dont get the message.
I have this in the db_cart_example_btn_only.php: <p style="color:#FF0000;margin:10px 0;"><?php echo $myCart->error; ?></p> With this i should get the message right?
Even when using your db_cart class without modifications it doesn't show message 11.
Any idea how to solve this?
Thank you
The most popular forum posts:
Comments / discussions
Olaf posted on 2008-10-08 10:54:05 #
Hi, do you get other messages?
marksling posted on 2008-10-08 11:06:46 #
Thank you for your reply,
I'm getting other messages, only 11 doesn't work.
i haven't changed anything on how to get those messages. It's just how you programmed it.
Olaf posted on 2008-10-08 11:30:35 #
I see the option is only in the "stock" example enabled.
add this code to your product index page:
if (!empty($_GET['get_msg'])) $myCart->messages($_GET['get_msg']);
Don't forget this class is an early beta version, I work with this script in many applications but I don't have the time to release a new version.
marksling posted on 2008-10-08 12:13:20 #
hm....i've pasted the code in my code. It still doesn't show message 11.
I looked in the original db_cart_stock_example.php and tested it but it doesn't work there either.
Maybe a php configuration?
Olaf posted on 2008-10-08 12:40:15 #
no, I think the code is on the wrong place, please post your code (only the upper PHP part)
marksling posted on 2008-10-08 12:45:30 #
ok, here is the code before the <html> starts
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/ext_user_profile.php");
$update_profile = new Users_profile(false); // need to be false otherwise the redirect to this page will not work
$update_profile->get_profile_data();
$get_profile = $update_profile->get_profile_data();
$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page
$page_protect->get_user_info();
$hello_name = ($page_protect->user_full_name != "") ? $page_protect->user_full_name : $page_protect->user;
$id = $page_protect->id;
if (isset($_GET['action']) && $_GET['action'] == "log_out") {
$page_protect->log_out(); // the method to log off
}
require($_SERVER['DOCUMENT_ROOT']."/classes/db_cart/db_cart_class.php");
$vvhoofdgroep = @$_GET['vvhoofdgroep'];
$vvsubgroep = @$_GET['vvsubgroep'];
$q = @$_GET['q'];
$q_info['vvhoofdgroep'] = $vvhoofdgroep;
$q_info['vvsubgroep'] = $vvsubgroep;
$q_info['q'] = $q;
$query_info = $vvhoofdgroep;
// end get product data
$cust_conn = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $cust_conn);
$cust_sql = "SELECT id, email FROM users WHERE id = '$id'";
$cust_result = mysql_query($cust_sql) or die(mysql_error());
$cust = mysql_fetch_object($cust_result);
$_SESSION['custom_num'] = $cust->id;
$_SESSION['email'] = $cust->email;
mysql_free_result($cust_result);
// end het customer data
// create a new cart object
$myCart = new db_cart($_SESSION['custom_num']);
$myCart->show_ordered_rows();
$num_rows = $myCart->get_number_of_records();
// handle checkout link
if (isset($_GET['action']) && $_GET['action'] == "checkout") {
if ($num_rows > 0) {
header("Location: ".CHECKOUT); // change the file name if you need
} else {
$myCart->error = "U heeft niets geselecteerd!";
}
}
if (!empty($_GET['get_msg'])) $myCart->messages($_GET['get_msg']);
Olaf posted on 2008-10-08 12:50:05 #
I think this is the wrong page :)
the code I send to you is for the page "db_cart_example_btn_only.php"
look there is some redirect, if you use the default files it should work
marksling posted on 2008-10-08 13:03:38 #
Thank you very very much! It worked. Only the echo was missing
if (!empty($_GET['get_msg'])) $myCart->messages($_GET['get_msg']);
should be
if (!empty($_GET['get_msg'])) echo $myCart->messages($_GET['get_msg']);
right? Btw, what do you mean with redirect? This is btw your db_cart_examples_btn_only.php with a few modifications.
Olaf posted on 2008-10-08 13:24:39 #
after a product is added the browser redirect to the continue script, after the order rows is processed the visitor is redirected to the prev. page
marksling posted on 2008-10-08 13:34:28 #
o, like that. yes, i know that. Thank you for your support!
Olaf posted on 2008-10-08 13:37:49 #