Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

add info to sessions


travisb

Recommended Posts

$variable = whatever;
tep_session_register('variable');

Obviously, replace variable with the actual variable name in both places and set it equal to something other than whatever.

 

Hth,

Matt

Link to comment
Share on other sites

Ok, that works, but not like I had hoped. What I want to do is add another field that the cart keeps track of for EACH item in the cart. Right now the session keeps track of product_id, qty, attributes, and price. I would like to add one more.

 

This code is from application_top where you add a product. I know I need to do something here but I do not know what.

 // customer adds a product from the products page
     case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                               $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
}

Link to comment
Share on other sites

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id'], $HTTP_POST_VARS['your_new_field']);

Replace your_new_field with the actual name given to the hidden or input field in product_info.php. Also, modify the add_cart function in includes/classes/shopping_cart.php to accept the new parameter (in between attributes and notify). You will also have to modify TABLE_CUSTOMERS_BASKET to include a column for the variable that you are passing (this is where the cart is stored, not in the session table). Various other changes may be needed to update/display this value as well.

 

Note: there might be various situations where you would want to do this differently, but it is hard to discuss them without knowing what you want to do more precisely.

 

Hth,

Matt

Link to comment
Share on other sites

I have not tried it yet and will have to wait until tomorrow. However, here is exactly what I want to do.

Go to: http://www.bruehlus.com/index.php/cPath/141_72 (this is the only category with pricing info so far)

In the first box click on the + button next any of the items with pictures.

In the second box choose any of the fabric groups by clicking the +

Then select a color.

All the text boxes to the right should be filled in and you can click the "add to cart" button.

 

On the shopping cart page you will see something like:

Big Arm 1 seater

- Upholstery 2454

but you do not get the color number which might look like 2454-15.

 

We have 500 products and 250 fabric options which means 125,000 combinations and I do not want to enter or maintain that many. Luckily, the fabrics have price groups so we only have about 20 different prices per item (only 10,000 combos).

 

The fabric group prices are what is listed in the attribute table and I made a couple more table to handle the fabric groups and colors within those groups. The cart keeps track of the group price option automatically, which is great. However, I need to know which color was selected within that group. This is why I wanted to add another field that the cart keeps track of.

 

If you can think of an easier or better solution to this please let me know. Thanks for your help.

Link to comment
Share on other sites

travisb, care to share the how? Your store is exactly the functionality I needed. I've been fighting trying to figure out how best to handle multiple options for a group (in my case its wood mouldings, which have price variables based on lumber type and size, so not nearly as many combinations as what you deal with, but enough to make things untidy/confusing).

 

I'd appreciate any know how you can impart!!!

 

TA!!

Link to comment
Share on other sites

travisb, care to share the how?  Your store is exactly the functionality I needed.  I've been fighting trying to figure out how best to handle multiple options for a group (in my case its wood mouldings, which have price variables based on lumber type and size, so not nearly as many combinations as what you deal with, but enough to make things untidy/confusing).

 

I'd appreciate any know how you can impart!!!

 

TA!!

First I created a new product option called upholstery. Then I added all the upholstery groups as option values. For each product I add the option values for each group which have their own prices and vary by product. But this does not alllow me to select a color within that group, so I created a couple more tables. First I created a table called upholstery_grades with id, grade, material, and manufacturer. This contains 20 groups. Next I created upholstery_colors table with id, grade, and color. This contains 250 rows.

 

Now to the programming. In the first box I show the products listed in that category. To do that I made a new file and made sure to get all the important includes from the header and footer. Then I made an sql query to pull all the products from that category. When you select a product, the price, model, and id number are put in the form using javascript and then the options show in the second box. Again I made another file and used a query to get the options for that product. Select a group and the group price and group number are copied to the form using javascript again. Then I call another query to select the colors available for that group. This is not based on the product at all, just the fabric group. Select a color and the color value is copied to the form and you are ready to add to cart.

 

Now I need to apply those changes suggested above so I can collect the color value with the fabric group.

 

If you would like to see the code that I am using, just let me know and I can post it.

Link to comment
Share on other sites

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id'], $HTTP_POST_VARS['your_new_field']);

Replace your_new_field with the actual name given to the hidden or input field in product_info.php.  Also, modify the add_cart function in includes/classes/shopping_cart.php to accept the new parameter (in between attributes and notify).  You will also have to modify TABLE_CUSTOMERS_BASKET to include a column for the variable that you are passing (this is where the cart is stored, not in the session table).  Various other changes may be needed to update/display this value as well.

 

Note:  there might be various situations where you would want to do this differently, but it is hard to discuss them without knowing what you want to do more precisely.

 

Hth,

Matt

Matt, I believe this will work, but first I need to get the session thing worked out. When I add an item to cart my session table shows this:

cart|O:12:"shoppingcart":5:{s:8:"contents";a:1:{s:7:"125{2}8";a:2:{s:3:"qty";i:1;s:10:"attributes";a:1:{i:2;s:1:"8";}}}s:5:"total";d:1580;s:6:"weight";d:0;s:6:"cartID";s:5:"72993";s:12:"content_type";b:0;}language|s:7:"english";languages_id|s:1:"1";currency|s:3:"USD";navigation|O:17:"navigationhistory":2:{s:4:"path";a:6:{i:0;a:4:{s:4:"page";s:9:"index.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:6:"141_72";}s:4:"post";a:0:{}}i:1;a:4:{s:4:"page";s:19:"products_inline.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:6:"141_72";}s:4:"post";a:0:{}}i:2;a:4:{s:4:"page";s:28:"upholstery_grades_inline.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:3:"pid";s:3:"125";}s:4:"post";a:0:{}}i:3;a:4:{s:4:"page";s:21:"show_group_inline.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:2:{s:5:"grade";s:2:"44";s:7:"article";s:4:"4430";}s:4:"post";a:0:{}}i:4;a:4:{s:4:"page";s:16:"product_info.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:6:"action";s:11:"add_product";}s:4:"post";a:10:{s:3:"pro";s:16:"Big Arm 1 seater";s:3:"mod";s:5:"35401";s:3:"uph";s:7:"4430-35";s:3:"spr";s:7:"1380.00";s:3:"upr";s:7:"+200.00";s:3:"tot";s:4:"1580";s:1:"x";s:2:"26";s:1:"y";s:2:"13";s:11:"products_id";s:3:"125";s:2:"id";a:1:{i:2;s:1:"8";}}}i:5;a:4:{s:4:"page";s:17:"shopping_cart.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:0:{}s:4:"post";a:0:{}}}s:8:"snapshot";a:0:{}}

4430-35 is my color selection, so that part works. However, when I click on any link, my session info changes and the color info is no longer there.

cart|O:12:"shoppingcart":5:{s:8:"contents";a:1:{s:7:"125{2}8";a:2:{s:3:"qty";i:1;s:10:"attributes";a:1:{i:2;s:1:"8";}}}s:5:"total";d:1580;s:6:"weight";d:0;s:6:"cartID";s:5:"72993";s:12:"content_type";b:0;}language|s:7:"english";languages_id|s:1:"1";currency|s:3:"USD";navigation|O:17:"navigationhistory":2:{s:4:"path";a:1:{i:0;a:4:{s:4:"page";s:9:"index.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:3:"141";}s:4:"post";a:0:{}}}s:8:"snapshot";a:0:{}}

Link to comment
Share on other sites

If you would like to see the code that I am using, just let me know and I can post it.

 

Please?? Travis, that would be greatly appreciated! Thanks!!

 

 

 

BTW, Your shop solution is brilliant! Very nice look to the site, too!

Link to comment
Share on other sites

Ok, here are some links to see the code for the layout of my site:

main page - http://www.bruehlus.com/index.php.txt

products box - http://www.bruehlus.com/products_inline.php.txt

fabric groups - http://www.bruehlus.com/upholstery_grades_inline.php.txt

colors - http://www.bruehlus.com/show_group_inline.php.txt

javascript for filling the forms - http://www.bruehlus.com/includes/general.js.txt

 

and here is the html I use in my category descriptions to get the correct products showing in the box. I have to hardcode the cPath in each description, so if I change my categories in the database later, I may have to change it here as well.

 

<iframe src="/products_inline.php/cPath/141_72" width="285" frameborder="1" height="290" scrolling="auto" name="categories_frame"></iframe>

 

That should be most of the files that I had to change for this, but if you think that something might be missing, let me know.

Link to comment
Share on other sites

I am still having troulbe with the sessions. I can get the fabric color in the session when the products are added.

Here the is when the product is added with color 4432-32

cart|O:12:"shoppingcart":5:{s:8:"contents";a:1:{s:7:"125{2}9";a:2:{s:3:"qty";i:1;s:10:"attributes";a:1:{i:2;s:1:"9";}}}s:5:"total";d:1580;s:6:"weight";d:0;s:6:"cartID";s:5:"71934";s:12:"content_type";b:0;}language|s:7:"english";languages_id|s:1:"1";currency|s:3:"USD";navigation|O:17:"navigationhistory":2:{s:4:"path";a:6:{i:0;a:4:{s:4:"page";s:9:"index.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:6:"141_72";}s:4:"post";a:0:{}}i:1;a:4:{s:4:"page";s:19:"products_inline.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:6:"141_72";}s:4:"post";a:0:{}}i:2;a:4:{s:4:"page";s:28:"upholstery_grades_inline.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:3:"pid";s:3:"125";}s:4:"post";a:0:{}}i:3;a:4:{s:4:"page";s:21:"show_group_inline.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:2:{s:5:"grade";s:2:"44";s:7:"article";s:4:"4432";}s:4:"post";a:0:{}}i:4;a:4:{s:4:"page";s:16:"product_info.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:6:"action";s:11:"add_product";}s:4:"post";a:10:{s:3:"pro";s:16:"Big Arm 1 seater";s:3:"mod";s:5:"35401";s:3:"uph";s:7:"4432-32";s:3:"spr";s:7:"1380.00";s:3:"upr";s:7:"+200.00";s:3:"tot";s:4:"1580";s:1:"x";s:2:"53";s:1:"y";s:1:"8";s:11:"products_id";s:3:"125";s:2:"id";a:1:{i:2;s:1:"9";}}}i:5;a:4:{s:4:"page";s:17:"shopping_cart.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:0:{}s:4:"post";a:0:{}}}s:8:"snapshot";a:0:{}}

But when I click to a new page the color number is lost. The original product attribute is kept, but only by referencing its id number from the product attribute table.

cart|O:12:"shoppingcart":5:{s:8:"contents";a:1:{s:7:"125{2}9";a:2:{s:3:"qty";i:1;s:10:"attributes";a:1:{i:2;s:1:"9";}}}s:5:"total";d:1580;s:6:"weight";d:0;s:6:"cartID";s:5:"71934";s:12:"content_type";b:0;}language|s:7:"english";languages_id|s:1:"1";currency|s:3:"USD";navigation|O:17:"navigationhistory":2:{s:4:"path";a:1:{i:0;a:4:{s:4:"page";s:9:"index.php";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:3:"141";}s:4:"post";a:0:{}}}s:8:"snapshot";a:0:{}}

 

I need to be able to keep track of the color number. Does anyone have any guesses on how to do this?

Link to comment
Share on other sites

  • 2 weeks later...

Have you considered installing one of the text attribute contributions and modifying it to carry the info that you need? AFAIK, it would be as simple as modifying the javascript to change the text field. Then when someone clicks the submit (Add to Cart) button, the contribution would do the rest of what you need.

 

Hth,

Matt

Link to comment
Share on other sites

I am working on something similar. I am trying to create a pick list and need to track attribute quantities through the entire process.

 

I have been able to track the information in the shopping cart and I created a new field in customers_basket_attributes and have been able to write the data to that table after they start to checkout but how does it move from this table to the orders_products_attributes table when an order is confirmed?

 

Thanks.

while (!succeed) {try()};

 

GMT -6:00

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...