Adding product to cart but reflects after page reload/refresh

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281070

Hi there,

I have used add to cart html link to add products.

<a class="hikashop_html_add_to_cart_link" href="http://www.csiwallpanels.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&qty=1&cid=85&Itemid=206&data[item][prodid_fincode]=<?php echo $this->element->product_code;?>-WOO001" onclick="try{ new Ajax('http://www.csiwallpanels.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&qty=1&cid=85&Itemid=206&data[item][prodid_fincode]=WOO001',  { method: 'get' }).request(); }catch(err){ new Request({url:'http://www.csiwallpanels.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&qty=1&cid=85&Itemid=206&data[item][prodid_fincode]=WOO001', method: 'get'}).send(); } return false;">Add to cart</a>
Code is working fine but I cant see product immediately in the cart, requires a page reload.
Do, I need to do any other settings to be configured.

Please help.
Thank you

Last edit: 7 years 6 months ago by nicolas.

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

  • Posts: 83780
  • Thank you received: 13568
  • MODERATOR
7 years 6 months ago #281074

Hi,

You would have to fire an event like that:

resp = Oby.evalJSON(xhr.responseText);
window.Oby.fireAjax('cart.updated', {id: resp.ret, el: this, product_id: 85, type: 'cart', resp: resp});
and use o.xRequest instead of new Ajax or new Request.
I would recommend however to look into using the addToCart function of media/com_hikashop/js/hikashop.js

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281183

Hi Nicolas,

Thanks for your response.
I have added hikashop content module on one of the product page.
It is loading but, when I adding product to cart it adds same product again and again even if a different product is clicked.

www.csiwallpanels.com/store/product/five...-panel-system-fis000
Module is at bottom.

Can you please check and help me why this is happening.
Thank you.

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281199

Hi Nicolas,
I need that urgently.
Please help me out me or tell some suggestion to display products like that.
I have around 500 products to show like that.

I have also tried add to cart html link, but after adding a product it redirects to checkout. i tried to prevent redirect with try new Ajax function with u had suggested in one of the thread.But in that .send() function doesn't exists i guess in Hikashop 3. In earlier version, it was working with legacy turning on.

i don't want a refresh on adding product and want show notification of product has been added to cart.

Thanks

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281200

Hi Nicolas,

Waiting to hear from you.

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

  • Posts: 26232
  • Thank you received: 4035
  • MODERATOR
7 years 6 months ago #281185

Hello,

Which module at the bottom ?!
All I can see is a module at the top where you need to click on the "cart" icon to show the cart content.
And it's refreshing fine !

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281227

]Hi, Jerome thanks for ur response,

See at the bottom of the page : www.csiwallpanels.com/store/product/five...-panel-system-fis000
I have attached the screenshot. The main product is added properly, but when you click on add to cart on products which are displayed below the main product is added to cart.

Thanks

Attachments:

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281236

hi Nicolas,

did you understand my problem?

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281241

hi
Any Solution??

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281247

hello,
anyone there to help me out?

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

  • Posts: 83780
  • Thank you received: 13568
  • MODERATOR
7 years 6 months ago #281232

Hi,

Ok, that is more clear.
So the issue is that if you click on an add to cart button in that listing module, it's the main product which is added to the cart module.

I think I see what is the issue.
Try to update the file components/com_hikashop/views/product/tmpl/add_to_cart_ajax.php with the file in the archive enclosed. That should hopefully help.

File Attachment:

File Name: add_to_cart_ajax.zip
File Size:2 KB

Attachments:
Last edit: 7 years 6 months ago by nicolas.

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281330

Hi Nicolas,

Thank you, but your code doesn't seem to be working out for me. Now not even base product is added when i click on different product.
it keeps on loading ajax spinner, see the screenshot attached.
And I have managed to solve it.
Can you tell me how can I load products from the database according to product category in the view file?

Someting like this $products=$productClass->getByCategory("Categoryname");

Thank you.

Attachments:

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281353

Hi,

I have written the SQL Quey in the view file. And it's working fine.
Will that okay? I mean writing SQL in view files.

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

  • Posts: 83780
  • Thank you received: 13568
  • MODERATOR
7 years 6 months ago #281358

Hi,

Yeah, that's not a problem. So if the correction I proposed didn't help, that means that there is something else missing. We would need a backend and FTP access to a website copy where we can see the issue in order to debug and provide a proper fix.
But if you're happy with what you have now, we can close that and we'll leave that be until someone else report a similar issue.

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

  • Posts: 24
  • Thank you received: 0
7 years 6 months ago #281380

Hi Nicolas,
I found that this attr data-addto-div="hikashop_product_form" is cause for adding same product again and again.

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

  • Posts: 83780
  • Thank you received: 13568
  • MODERATOR
7 years 6 months ago #281409

Hi,

Yes I know. If you look at the changes in the add_to_cart_ajax.php file I had proposed compared to the default one of HikaShop, it was meant to set the data-addto-div attribute properly.

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

Time to create page: 0.055 seconds
Powered by Kunena Forum