ariogenki Posted August 24, 2006 Posted August 24, 2006 >_< Okay. Three days of no avail I have finally concluded I need help. I am building a gift registry. Anyways.... here is the code that adds it to the cart. case 'add_product_user': include('registry/display/cart/add.php'); $amount2 = count($cart_num); $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$amount2); tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Now. Two things happens here. Inside Add.php it adds it to my gift registry correctly, and inside add.php is an array that I created call cart_num to make sure it counts it so it can add the correct quantity to the cart. $Amount2 is the amount that should be added to the shopping cart. It doesnt even matter if the array isnt being populated correctly it should still represent 1 in $cart_num if I were to count it. But the fact is that the array is being populated correctly as it adds the correct number of ppl to my table for the registry. But when it trys to add the quantity to my cart, upon redirect my shopping cart is completly empty and if there were items already in the cart before, they are now gone. Can someone help me? :( Quote
guntersammet Posted August 26, 2006 Posted August 26, 2006 Not 100% sure what you try to do. somehow it appears to me that you want to sum up the $cart_num array but you use count which returns you the number of elements in the array. BTW, did you have a look at my gift registry contribution (http://www.oscommerce.com/community/contributions,1226/category,all/search,registry)? HTH Gunter >_< Okay. Three days of no avail I have finally concluded I need help. I am building a gift registry. Anyways.... here is the code that adds it to the cart. case 'add_product_user': include('registry/display/cart/add.php'); $amount2 = count($cart_num); $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$amount2); tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Now. Two things happens here. Inside Add.php it adds it to my gift registry correctly, and inside add.php is an array that I created call cart_num to make sure it counts it so it can add the correct quantity to the cart. $Amount2 is the amount that should be added to the shopping cart. It doesnt even matter if the array isnt being populated correctly it should still represent 1 in $cart_num if I were to count it. But the fact is that the array is being populated correctly as it adds the correct number of ppl to my table for the registry. But when it trys to add the quantity to my cart, upon redirect my shopping cart is completly empty and if there were items already in the cart before, they are now gone. Can someone help me? :( Quote
guntersammet Posted August 26, 2006 Posted August 26, 2006 After reading it again, you it seems like you want to use count. Are you making sure that you are in the correct scope for $cart_num? If not, $cart_num might not be available where you try to use it. HTH Gunter Quote
boxtel Posted August 26, 2006 Posted August 26, 2006 >_< Okay. Three days of no avail I have finally concluded I need help. I am building a gift registry. Anyways.... here is the code that adds it to the cart. case 'add_product_user': include('registry/display/cart/add.php'); $amount2 = count($cart_num); $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$amount2); tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Now. Two things happens here. Inside Add.php it adds it to my gift registry correctly, and inside add.php is an array that I created call cart_num to make sure it counts it so it can add the correct quantity to the cart. $Amount2 is the amount that should be added to the shopping cart. It doesnt even matter if the array isnt being populated correctly it should still represent 1 in $cart_num if I were to count it. But the fact is that the array is being populated correctly as it adds the correct number of ppl to my table for the registry. But when it trys to add the quantity to my cart, upon redirect my shopping cart is completly empty and if there were items already in the cart before, they are now gone. Can someone help me? :( well, to my shame I have to say that I have no idea what a gift registry is. Some variation to a wish list ? in any event, what does $cart_num stand for and why is it an array? Quote Treasurer MFC
ariogenki Posted August 28, 2006 Author Posted August 28, 2006 Fixed it With The following The Array contains who is getting the gift. So I count it jsut to get the amount/quantity for the cart. The gift registry is like a wish list, except its made to send the product to multiple ppl with gift messages, seperate delivery dates etc. case 'add_product_registry' : $v = calval(); if (isset($HTTP_GET_VARS['products_id'])) { // if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) { // tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])); // } else { $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$v); // } } echo add_to_shipping_list(); tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.