Display the quantity field for non-existent products

  • Posts: 124
  • Thank you received: 6
1 year 1 week ago #357302

-- HikaShop version -- : 5.0.0

Hi
Why is the quantity field displayed in the product list view for non-existent products? Product stock is 0. Therefore, the quantity field should not be displayed:



This happens when the user is logged in. Not displayed for guest user:

Attachments:
Last edit: 1 year 1 week ago by levelup.

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

  • Posts: 83007
  • Thank you received: 13399
  • MODERATOR
1 year 1 week ago #357304

Hi,

I don't read arabic but I suppose that the yellow button on your screenshot is the "add to wishlist" button. Since you can add several items of the same product in the wishlist, the quantity input field needs to be displayed if the add to wishlist button is displayed.
A product can be added to the wishlist even without any stock.

The following user(s) said Thank You: levelup

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

  • Posts: 124
  • Thank you received: 6
1 year 1 week ago #357343

Of course, it should be possible to add a product to the wishlist even without any stock. But i think there is no need to display the quantity field.

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

  • Posts: 83007
  • Thank you received: 13399
  • MODERATOR
1 year 1 week ago #357344

Hi,

Well, if you don't want users to be able to add more than 1 item of a product to their wishlist when the product doesn't have any stock left, you would need to do some view overrides via the menu Display>Views.
For the products listing, you can edit the view file add_to_cart_ajax.php
There, add the line:

if(!$add_to_cart) { $this->quantityLayout = 'show_simple'; }
after the line:
if($display_quantity_field && (!$global_on_listing || !$has_required_fields )) {
And you can add the same code after the line:
if(($add_to_cart || $add_to_wishlist) && $display_quantity_field) {
in the file quantity.php which is used for the product details page.

The following user(s) said Thank You: levelup

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

Time to create page: 0.077 seconds
Powered by Kunena Forum