frankl Posted September 11, 2011 Posted September 11, 2011 If you have 'Display Cart After Adding Product' set to False in Configuration -> My Store, products are added 'silently', and the customer may not realise it has been added to the cart. You can add messages such as 'Product has been Added to Cart!', or even add a message in MessageStack, by utilising the following snippet of code... <?php //add item to cart if (tep_session_is_registered('new_products_id_in_cart')) { ...insert your logic here... } if (tep_session_is_registered('new_products_id_in_cart')) { tep_session_unregister('new_products_id_in_cart'); } ?> You could, for instance, insert in the product info page (just after the call for column left, using MS2.x as an example), like this... <?php if (tep_session_is_registered('new_products_id_in_cart')) { echo '<tr> <td class="messageStackSuccess">Product Added To Cart</td> </tr>'; } if (tep_session_is_registered('new_products_id_in_cart')) { tep_session_unregister('new_products_id_in_cart'); } ?> You can even have fun with jQuery and fade the message in when the new page loads to make it even more noticeable! osCommerce user since 2003!
forummaker Posted September 23, 2011 Posted September 23, 2011 I'm not sure if this is exactly what I'm looking for (it may be).. but I have a quick question regarding this post. If a customer adds an item to their cart... then shops around a bit... then returns to view the item again... will this code inform them that that item is currently in their shopping cart. Can I do this with this code? If so.. I think what would be best is if instead of the "Add to Cart" button that is currently there... It will say..."This items is currently in your cart... to add another to your cart click here"... or something along those lines. I noticed that my customers will return to view the item they just added to their cart... and add another because the item does not indicate it is currently in their cart. I think this is very important.. and not sure why this hasn't been addressed before. Thanks for any help:) That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
forummaker Posted September 30, 2011 Posted September 30, 2011 Any suggestions on my last post? Thanks:) That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
Guest Posted October 4, 2011 Posted October 4, 2011 I haven't tried this yet, but I would love to see a solution as Ken has proposed, because I would love to have some indication like that as well...
Guest Posted October 4, 2011 Posted October 4, 2011 I couldn't get the original suggestions to work for me... Is there more to this that you could provide?
forummaker Posted October 6, 2011 Posted October 6, 2011 Still stumped why there isn't more interest in this..... Or maybe it just the two of us... hmmmm That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
♥14steve14 Posted October 8, 2011 Posted October 8, 2011 Maybe its just easier to change 'Display Cart After Adding Product' False to True REMEMBER BACKUP, BACKUP AND BACKUP
foxp2 Posted October 8, 2011 Posted October 8, 2011 I'm not sure if this is exactly what I'm looking for (it may be).. but I have a quick question regarding this post. If a customer adds an item to their cart... then shops around a bit... then returns to view the item again... will this code inform them that that item is currently in their shopping cart. Can I do this with this code? If so.. I think what would be best is if instead of the "Add to Cart" button that is currently there... It will say..."This items is currently in your cart... to add another to your cart click here"... or something along those lines. I noticed that my customers will return to view the item they just added to their cart... and add another because the item does not indicate it is currently in their cart. I think this is very important.. and not sure why this hasn't been addressed before. Thanks for any help:) add in catalog\includes\classes\shopping_cart.php : function get_product_id_array() { $product_id_array = array(); if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_array[] = tep_get_prid($products_id); } } return $product_id_array; } and in catalog\product_info.php (after line 51) if(in_array($product_info['products_id'], $cart->get_product_id_array())) { echo 'this product is in your shopping cart'; }
Guest Posted October 8, 2011 Posted October 8, 2011 and in catalog\product_info.php (after line 51) if(in_array($product_info['products_id'], $cart->get_product_id_array())) { echo 'this product is in your shopping cart'; } In catalog/product_info.php, what would this follow or preceed? My site is pretty heavily modified... And is this in osC v2.3.1 or 2.3 or which? (just so I know which one to reference)...
Guest Posted October 8, 2011 Posted October 8, 2011 STOCK OSC v2.3.1: L49: if ($product_check['total'] < 1) { L50: ?> L51: L52: <div class="contentContainer"> L53: L54: <div class="contentText"> L55: <?php echo TEXT_PRODUCT_NOT_FOUND; ?> L56: </div> L57: L58: <div style="float: right;"> L59: <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?> L60: </div> L61: </div> STOCK OSC 2.2: L49: if ($product_check['total'] < 1) { L50: ?> L51: <tr> L52: <td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td> L53: </tr> L54: <tr> L55: <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> L56: </tr>
foxp2 Posted October 8, 2011 Posted October 8, 2011 if(in_array($product_info['products_id'], $cart->get_product_id_array())) { echo 'this product is in your shopping cart'; } after the product query : $product_info_query = tep_db_query("select .... $product_info = tep_db_fetch_array($product_info_query); or anywhere you want with : if(in_array((int)$HTTP_GET_VARS['products_id'], $cart->get_product_id_array())) { your code ... }
Guest Posted October 8, 2011 Posted October 8, 2011 I keep getting this error: Fatal error: Call to undefined method shoppingCart::get_product_id_array() in ......../product_info.php on line 353 <?php if(in_array((int)$HTTP_GET_VARS['products_id'], $cart->get_product_id_array())) { echo 'this product is in your shopping cart'; } else { ?> <div class="buttonAction"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) .tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, '', 6); ?></div> <?php } ?>
foxp2 Posted October 9, 2011 Posted October 9, 2011 I keep getting this error: Fatal error: Call to undefined method shoppingCart::get_product_id_array() in ......../product_info.php on line 353 -> http://www.oscommerce.com/forums/topic/379555-how-to-let-customer-know-item-added-to-cart/page__view__findpost__p__1605540
Guest Posted October 9, 2011 Posted October 9, 2011 The function was added to includes/classes/shopping cart: function get_product_id_array() { $product_id_array = array(); if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_array[] = tep_get_prid($products_id); } } return $product_id_array; } ... in the product_info...: It doesn't matter which variation of IF is used. It gets the same result with the undefined method. if(in_array((int)$HTTP_GET_VARS['products_id'], $cart->get_product_id_array())) { --OR-- if(in_array($product_info['products_id'], $cart->get_product_id_array())) {
Guest Posted October 18, 2011 Posted October 18, 2011 Just thought I'd report on my moronic error... The part added to catalog\includes\classes\shopping_cart.php was added to the very end of the page, before the ?> - but it SHOULD have been added before the last } ?> ... which ends the encasement for the whole class. It works wonderfully, and I've put it in a statement on product_info.php so that it replaces the Add To Cart button if that product is in the cart, and it really helps a lot! Thank you so much for this Laurent!!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.