Cannot add pdt to cart more than once

  • Posts: 272
  • Thank you received: 7
10 years 3 weeks ago #200294

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1

Hi,

A developer I work with recently created a new module position on my shop so I can have the cart and category menu on the right hand side. This new module position was created in my Hikashop override folder: mysite/templates/mytemplate/html/com_hikashop

I tested it and I cannot add a product more than once to the cart. If I try to add the product twice it is not added. I don't think my developer knows why, so i am turning to you for assistance. I would be very grateful for some help/advice. Maybe you know why this is happening and what the solution would be..

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

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
10 years 3 weeks ago #200304

Hi,

The problem comes from the way the customization was done.
The cart module is displayed inside the product page form.
When you have a product in the cart, the quantity of the product in the cart module is passed along when you click on the "add to cart" button and that field has a higher priority than the product quantity field, resulting in the system updating the quantity of the product in the cart with the quantity it already had instead of adding the quantity in the quantity field to the cart.
So what you want is to turn off the "Show quantities in the cart" option of the cart module or to modify the code of the cart module override to not display the quantity field of each product in the cart but just the quantity value.

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

  • Posts: 272
  • Thank you received: 7
10 years 3 weeks ago #200358

Nicolas thank you for the detailed reply.
I did as you said and set "No" for "Show quantities in the cart. However this does not change anything - cart still does not add more than one item. Rather than change the code for the cart, can you suggest a better way to add a new module position for my shop pages that would not cause this problem? For example, if a module position was created in my site template (not in the hikashop override folder), would this solve the issue?

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

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
10 years 3 weeks ago #200376

If the option doesn't change anything, it means that the cart module override in your template doesn't honor the option. So it would require modifying the code of the module cart view file in the template to remove the input. Your developer should be able to do that.

Otherwise, yes it would solve the problem too if you would move the cart module position from outside the product page view.

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

  • Posts: 272
  • Thank you received: 7
10 years 3 weeks ago #200466

Hi Nicolas,
Thanks for the advice.
Is it possible to move the cart module position outside the product page view (so it functions correctly), but for the cart to still visually appear in the same place on the product page (right hand side of product page)?

To better explain, if I create a new module position in my site template (not in the hikashop override folder) and publish the cart to the new position (which visually is still on the right side of the product page), will the cart then work? I can then use a "nonumber.nl" extension to publish the cart module on Hikashop product URLs only.

Hopefully you understand what I am asking :)

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

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
10 years 3 weeks ago #200469

Hi,

Yes, that's possible. It just requires the proper CSS to be added so that you can place the different areas like you need them to appear. The exact CSS will depend on how the module position is created in the template (what HTML it ouputs), what CSS is already in the template, and what other customizations have been done to the product page.
A web designer or a web developer should be able to provide such CSS.

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

  • Posts: 272
  • Thank you received: 7
10 years 3 weeks ago #200552

Thanks you again Nicolas for the advise. That has helped a lot.

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

  • Posts: 272
  • Thank you received: 7
10 years 2 weeks ago #200650

Hi Nicolas,

Do you have any economical developer you can suggest that would be able to create a new module position for me? The guy I used to work with isn't available. I know this is a reasonably easy thing to do, but possibly above my abilities.

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

  • Posts: 26235
  • Thank you received: 4036
  • MODERATOR
10 years 2 weeks ago #200653

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: 272
  • Thank you received: 7
10 years 2 weeks ago #200991

Hi Nicolas,

My developer has said that the cart must be placed in the Hikashop layout, in order to get the module to display correctly on mobiles/ipads etc. So I have no other option than to do this (rather than place it in a site template module position).

Do you think it should be a relativly simple task to get the cart to update correctly by tweaking the "code of the module cart view file in the template to remove the input."?

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

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
10 years 2 weeks ago #201003

Hi,

I don't see why mobile devices display would be a problem. He must have overlooked that he can use CSS media queries to restrict the positioning CSS on the product page based on the width of the device and thus adapt the display so that it looks good for all of the devices.
line25.com/tutorials/create-a-responsive...n-with-media-queries

But yes, it will be easy to remove the quantity input. With the default code, it should just be changing the line:

<input id="hikashop_cart_quantity_<?php echo $row->cart_product_id;?>" type="text" name="item[<?php echo $row->cart_product_id;?>][cart_product_quantity]" class="hikashop_product_quantity_field" value="<?php echo $row->cart_product_quantity; ?>" onchange="var qty_field = document.getElementById('hikashop_cart_quantity_<?php echo $row->cart_product_id;?>'); if (qty_field){<?php echo $input; ?> } document.<?php echo $form; ?>.submit(); return false;" />
to:
<?php echo $row->cart_product_quantity; ?>
in the product/cart view file.

So in short, both should be easy solutions taking a few minutes to implement for an experienced developer.

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

  • Posts: 272
  • Thank you received: 7
10 years 2 weeks ago #201041

Thank you again Nicolas for your detailed help here. I shall try the code change you suggested.

I notice that when the cart is added to the hikashop layout, then the "related products" at the bottom of the page do not show. I believe this is because both modules (the 'cart' and 'related product') is on Display > content module. The new module position that was created on the right of the product page for the cart is also inside the Hikashop component, which seems to disable the 'related product' module on the page.

Is there any fix for this, besides moving the 'related product' module to "bottom1" module position for example (which is not perfect)?

Thanks again

PS : I implemented your code, but as before the cart will only add one of the same product, not 2.
Do you have any other coding suggestions I could try?

Thanks in advance for your help

Last edit: 10 years 2 weeks ago by Jerome. Reason: merging messages

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

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
10 years 2 weeks ago #201086

Hi,

I don't know how the page was customized and that doesn't happen by default so I can't say much.
I would recommend to seek advice with your developer regarding that issue.

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

Time to create page: 0.076 seconds
Powered by Kunena Forum