PHP Scripts Development » PHP Classes Support Forum » Db_cart class Support forum

[sticky]

Using DB cart without a customer ID

(15 posts)

Great offers not only for geeks!


  1. In many webshops the customer has to login/register after the product selection is done. With the db_cart class it's possible to handle shopping carts with and without a customer ID.
    Important
    If you don't want to use a customer ID you need to leave the property in the constructor empty (or use a zero):

    $object = new db_cart();

    or if you don't know if a customer is logged in use the code like:

    if (empty($customer)) $customer = 0;
    $object = new db_cart($cutomer);
    Posted 6 months ago #
  2. User has not uploaded an avatar

    xkarlos
    Member

    Thank you for this post,
    this was think I didnt know !!!!

    Posted 6 months ago #
  3. User has not uploaded an avatar

    xkarlos
    Member

    I am sorry but I still do not know how to do it:

    If I use $object = new db_cart();
    how can I get the customer id number ?

    thank you

    Posted 6 months ago #
  4. Quote from: xkarlos
    "I am sorry but I still do not know how to do it:
    If I use $object = new db_cart();
    how can I get the customer id number ?
    thank you"

    in this case the default value "0" (zero) is used...

    Posted 6 months ago #
  5. User has not uploaded an avatar

    xkarlos
    Member

    I try to describe my problem in detail,
    becouse it doesnot work me.

    I have two pages : 1 - site with products and shown the total value of the shopping cart, 2 - page with the shopping cart.

    When I add in page 1 things to the cart, the total value shows good,
    bud in the 2nd page is nothing in the basket.

    In page 1 I have: $myCart = new db_cart(0);
    In page 2 I have: $myCheckout = new db_cart(0);

    But it still doesnot work.

    In your example files you have there :

    $_SESSION['custom_num'] = $cust->cust_no;
    $_SESSION['email'] = $cust->email;

    (I dont have it there, is that required ?)

    Shall i have in all pages the same db cart object ?

    many thanks for your help here

    Posted 6 months ago #
  6. Hi,

    the two session variables are an example if you have some other customer database.

    please post the PHP code from your second page.

    Posted 6 months ago #
  7. Hi, I removed your code since it doesn't show something new :)

    check the sessions, place this code on the top of both pages

    print_r($_SESSION)

    and compare the result (the order id) and check also the database records

    Posted 6 months ago #
  8. User has not uploaded an avatar

    xkarlos
    Member

    page 1: Array ( [order_id] => 69 )
    page 2: Array ( [order_id] => 69 )

    Its same, but I dont know what could it be ?

    do you have any idea ?

    PS: When I use db_cart(0) - is it possible to do shopping by more than one customers in the same time ?

    Posted 6 months ago #
  9. The "Customer id" (zero) is only used for a check, the important thing is the "Order Id", while there are more than one "unknown" customers on your site the "Order id" is used to separate the order rows.

    I think there is something wrong with the sessions, do you have the test application on some public web server?

    Posted 6 months ago #
  10. User has not uploaded an avatar

    xkarlos
    Member

    I found out tha during the shopping I have no record in table db_cart_orders.
    Only in db_cart_rows. I think this could be the problem.
    Becouse there are SQL querys WHERE .... and the result of COUNT * for these querys is 0.

    In this moment I dont have it on public server :(

    Posted 6 months ago #

RSS feed for this topic

Reply »

You must log in to post.