Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

How to let customer know item added to cart

add to cart

  • You cannot reply to this topic
14 replies to this topic

#1 frankl

  • Community Member
  • 78 posts
  • Real Name:Frank
  • Location:Sydney, Australia

Posted 11 September 2011, 10:17

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!

Edited by frankl, 11 September 2011, 10:18.


#2 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 23 September 2011, 18:21

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.

#3 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 30 September 2011, 15:22

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.

#4 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 04 October 2011, 00:04

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...
Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...

#5 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 04 October 2011, 00:36

I couldn't get the original suggestions to work for me...

Is there more to this that you could provide?
Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...

#6 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 06 October 2011, 16:20

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.

#7 14steve14

  • Community Member
  • 2,176 posts
  • Real Name:Steve
  • Gender:Male

Posted 08 October 2011, 08:03

Maybe its just easier to change

'Display Cart After Adding Product' False

to

True
REMEMBER BACKUP, BACKUP AND BACKUP
I am not a coder. OSC has a steep learning curve, but in general the program does work. If it doesnt work, the chances are it is something you have done.

#8 foxp2

  • Community Sponsor
  • 168 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 08 October 2011, 11:30

View Postforummaker, on 23 September 2011, 18:21, said:

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';
    }

Laurent AKA Fox P two
osCommerce, Code With Passion
My Tools for Agile software development : About Me

#9 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 08 October 2011, 18:09

Quote

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)...
Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...

#10 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 08 October 2011, 18:35

Quote

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>

Quote

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>

Edited by The Munch, 08 October 2011, 18:36.

Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...

#11 foxp2

  • Community Sponsor
  • 168 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 08 October 2011, 21:00

	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 ...
    }

Laurent AKA Fox P two
osCommerce, Code With Passion
My Tools for Agile software development : About Me

#12 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 08 October 2011, 21:20

I keep getting this error:

Fatal error: Call to undefined method shoppingCart::get_product_id_array() in ......../product_info.php on line 353

Quote

<?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 } ?>

Edited by The Munch, 08 October 2011, 21:23.

Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...

#13 foxp2

  • Community Sponsor
  • 168 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 09 October 2011, 03:39

View PostThe Munch, on 08 October 2011, 21:20, said:

I keep getting this error:

Fatal error: Call to undefined method shoppingCart::get_product_id_array() in ......../product_info.php on line 353

-> http://forums.oscommerce.com/topic/379555-how-to-let-customer-know-item-added-to-cart/page__view__findpost__p__1605540
Laurent AKA Fox P two
osCommerce, Code With Passion
My Tools for Agile software development : About Me

#14 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 09 October 2011, 11:35

The function was added to includes/classes/shopping cart:

Quote

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.

Quote

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())) {

Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...

#15 The Munch

  • Community Member
  • 67 posts
  • Real Name:Scott
  • Gender:Male
  • Location:Iowa, USA

Posted 18 October 2011, 22:14

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!!

Edited by The Munch, 18 October 2011, 22:15.

Thank You!!
----------
Using: OSC 2.3.1, Algozone Template, Jcow 5 Pro, CometChat 4 Premium.

Contributions for OSC-2.3.1: QT Pro 4.6.1, Easy Populate EPv2.77a, Admin Notes, Contribution Tracker, Multi-Product Manager, myQBi Quickbooks Sync, Order Editor 5.0.9, Dynamic Sitemap, Tax ID in Order Editor, Separate Pricing Per Customer v4.2.2 ... etc ...

Contributions for OSC-2.2 I've Modified for OSC-2.3.1: Admin Level Account with Categories 2.3.4, File Logging or Email for Failed Admin Login Attempts, Autologon v1.09, Admin Specials by Categories, CCGV 6.0_1, Hide Categories, How Did You Hear About Us, MSRP Listing, Multiple Sales Per Product, osc as info site, OSC Checkout Security Boost v1.1, Points and Rewards Module, Quick Stock Updater, Quick Updates 292, RMA Returns System 2.6, Show Unit Price, Store Mode, Supplier Admin v1.3, Tell A Friend, Required Customer Details v22rc2a, Admin Change Customers Password v3.3, PDF Invoice & PackingSlip 1.6, Quick Price Updates for SPPC v1.5, Country-State Selector v1.5.5 + Limit Countries v2.2, Contact Us Popup Business Card, No Right Click, Delete Customer Account v1.2, Control Login v2.2, Member Type Control v1.1, .... etc...