Skip to main content

"Added to cart" notification next to "Add to Cart"

More
11 years 1 month ago #212020 by Tim Moore
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3

There are three options after the user click "Add to Cart" button:
  1. Stay on page
  2. Redirect
  3. Popup notification
But none of them fits.
How can I append "Added to Cart" notification next to the "Add to Cart" after the user click this button? And even better with the counter of added goods

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #212030 by nicolas
You can change the code:
Code:
$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ return hikashopModifyQuantity(\'' . $this->row->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }';
to:
Code:
$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ document.getElementById(\'hikashop_product_quantity_main\').innerHTML+=field.value+\' products added to the cart\';return hikashopModifyQuantity(\'' . $this->row->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }';
in the file "show_default" of the view "product" via the menu Display>Views.
The following user(s) said Thank You: Tim Moore

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #212105 by Tim Moore
Thank you! It works. But if I want to add more positions of that product, I get several messages like:
"1 products added to the cart1 products added to the cart2 products added to the cart" (see attached file)
Is there a way to show only the total of added items. Like "Added to Cart: 5 items" ?

And If the customer comes back to this page again later, how to make him informed that the product is already in the cart?

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago - 11 years 1 month ago #212106 by Tim Moore
And another question: After adding to Cart, to change the color of the Add to Cart Button and the inner text to "Added to Cart".
Clicking this button again links to the Cart Page
Last edit: 11 years 1 month ago by Tim Moore.

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago - 11 years 1 month ago #212116 by Mohamed Thelji
Hello,

And If the customer comes back to this page again later, how to make him informed that the product is already in the cart?

Customers are generally informed of what they have added to their cart by displaying a cart module listing every products added to their cart or only displaying the amount of product on their cart.

Is there a way to show only the total of added items. Like "Added to Cart: 5 items" ?

Doing it will be more complex, but to fix the code that Nicolas gave you, a solution can be to, edit the file "show_default" file of the "Product" view of your front-end template, and add after these lines :
Code:
<div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main"> <?php //LAYOUT quantity $this->row = & $this->element; $this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ return hikashopModifyQuantity(\'' . $this->row->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }'; $this->setLayout('quantity'); echo $this->loadTemplate(); ?> </div>
this :
Code:
<span id ="nb_product_added" class="nb_product_added"> </span>

And change the code that Nicolas gave you by :
Code:
$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ document.getElementById(\'nb_product_added\').innerHTML=field.value+\' products added to the cart\';return hikashopModifyQuantity(\'' . $this->row->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }';
Last edit: 11 years 1 month ago by Mohamed Thelji.
The following user(s) said Thank You: Tim Moore

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #212194 by Tim Moore
Thank you! but this way it only shows you the LAST amount of added items, not the Total, if you wish to add more a bit later

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #212203 by nicolas
It's more complex but still possible.
You first load the cart, sum the quantity of each product in it, and then sum it with the quantity asked by the customer.

Please understand that we're already way outside user support here and that this falls under code customization.
If you need a developer to help you with such customization, you can use our commercial jobs forum or contact our partners:
www.hikashop.com/home/our-partners.html
We also have documentation for developers who wish to customize themselves :
www.hikashop.com/support/documentation/1...ize-the-display.html
www.hikashop.com/support/documentation/6...r-documentation.html

Please Log in or Create an account to join the conversation.

More
11 years 3 weeks ago - 11 years 3 weeks ago #213791 by Tim Moore
1) After adding to Cart, how to change the color of the Add to Cart Button and the inner text to "Added to Cart".
Clicking this button again would link to the Cart Page

2) and the same principle for product page and category listing ?


3) Whilst trying to get "Added to cart" notification next to "Add to Cart" in the category listing I attempted to use this code in cart.php
Code:
if(empty($this->ajax)) // $this->ajax = 'return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0,\'cart\','.$module_id.')'; $this->ajax = 'document.getElementById(\'nb_product_added_'.$this->row->product_id.'\').innerHTML=\'Added to Cart\'; return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0,\'cart\','.$module_id.')';

And added a line
Code:
<span id ="nb_product_added_<?php echo $this->row->product_id ?>" class="nb_product_added"></span>
to the file listing_img_title.php just after the
Code:
<?php if($this->params->get('add_to_cart') || $this->params->get('add_to_wishlist')){ $this->setLayout('add_to_cart_listing'); echo $this->loadTemplate(); }?>
.
But the notice is not being rendered. What am I doing wrong?
Last edit: 11 years 3 weeks ago by Tim Moore.

Please Log in or Create an account to join the conversation.

More
11 years 3 weeks ago #213812 by nicolas
Hi,

1. You want to edit the file add_to_cart_listing file like you did for point 3 to customize the javascript of the add to cart button in order to perform these tasks when the customer click on the button.

2. The add_to_cart_listing will only be for the listing of products. For the product page, you want to edit the show_default view file instead and you'll also have a $this->ajax there that you can customize.

3. I don't see the span on your website when I look at the HTML of the page. So that means that either you're not using the "image and title" block layout for your listing, or that you've edited the view file for another template.
The following user(s) said Thank You: Tim Moore

Please Log in or Create an account to join the conversation.

More
11 years 3 weeks ago #213943 by Tim Moore
thank you!

3. I don't see the span on your website when I look at the HTML of the page. So that means that either you're not using the "image and title" block layout for your listing, or that you've edited the view file for another template.

I've used a bit different approach, without that span

Please Log in or Create an account to join the conversation.

Time to create page: 0.245 seconds
Powered by Kunena Forum