Products only available at the Store

  • Posts: 23
  • Thank you received: 1
5 years 2 months ago #303634

-- url of the page with the problem -- : www.genusskanzlei.at/
-- HikaShop version -- : 4.0.2
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.2.12
-- Browser(s) name and version -- : Chrome

Hi

I have once programmed a condition that when we set the quantity to "-2", with the help of a new constant 'IN_STORE,' the front-end will display "Available at the Store" (Erhältlich im Geschäft) instead of "out of stock."

After changing the Theme, this is not working anymore, and I have tried and failed to get it working right following your code source.

For example, when I look at the following category: www.genusskanzlei.at/index.php/genusskan...egory/115-aufstriche
all the products display the standard 'NO_STOCK' --> "Out of Stock" ("Nicht vorrätig")



However, when I view the product page, I do get the 'IN_STORE' message but also the "add to cart"; which in this case shouldn't be displayed since they can only be ordered directly.


I edited the 'com_hikashop/product/quantity.php' and changed:
$stock_class = ($stock != 0) ? "" : " hikashop_product_no_stock";
?>
<span class="hikashop_product_stock_count<?php echo $stock_class; ?>">
<?php
    if(!empty($this->row->product_stock_message))
        echo JText::_($this->row->product_stock_message);
    elseif($stock > 0)
        echo (($stock == 1 && JText::_('X_ITEM_IN_STOCK') != 'X_ITEM_IN_STOCK') ? JText::sprintf('X_ITEM_IN_STOCK', $stock) : JText::sprintf('X_ITEMS_IN_STOCK', $stock));
    elseif(!$in_stock)
        echo JText::_('NO_STOCK');
?>
</span>
<?php

to
$stock_class = ($stock != 0) ? "" : " hikashop_product_no_stock";
?>
<span class="hikashop_product_stock_count<?php echo $stock_class; ?>">
<?php
    if($this->row->product_quantity == -2)
             echo JText::_('IN_STORE');         
    elseif(!empty($this->row->product_stock_message))
        echo JText::_($this->row->product_stock_message);
    elseif($stock > 0)
        echo (($stock == 1 && JText::_('X_ITEM_IN_STOCK') != 'X_ITEM_IN_STOCK') ? JText::sprintf('X_ITEM_IN_STOCK', $stock) : JText::sprintf('X_ITEMS_IN_STOCK', $stock));
        elseif(!$in_stock)
        echo JText::_('NO_STOCK');
?>
</span>
<?php

I want the 'IN_STORE' message to display in the "listing views" and that the "add to cart" options, does not show for this condition. How can I edit the code to achieve these results?



I hope I have made myself understood and you could help me fix this problem, which is misleading the clients.

Thanks a lot in advance!

Attachments:

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 2 months ago #303661

Hi,

If you had it working as view overrides for your previous template, then you could just copy the relevant files from templates/YOUR_OLD_TEMPLATE/html/com_hikashop/product to templates/YOUR_NEw_TEMPLATE/html/com_hikashop/product
and that should be enough.

Now the exact view file to edit and which change to do in that file will depend on how your website is configured, which I don't know.
To make sure that you're editing the correct file, you'll want to first temporarily activate the "display view files" setting of the HikaShop configuration and look at the product page. Once you know which view file is displaying the stock message, you can edit it via the Display>Views menu.
The code modification you proposed in your message should be quite good to change the stock message. However, it won't affect the add to cart button. To change that, you would have to modify that line:

$add_to_cart = !$catalogue_mode && $in_stock && (!$is_free || $display_free_cart) && $product_available;
For example, you could use:
$add_to_cart = !$catalogue_mode && $in_stock && $this->row->product_quantity != -2 && (!$is_free || $display_free_cart) && $product_available;

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

  • Posts: 23
  • Thank you received: 1
5 years 2 months ago #303703

Hi,

thanks for the code suggestion, this part worked-

Now that I remember, I was not showing the shopping cart with the old Theme when I was viewing the category listing.

But the way I see it, this only affects the quantity check, therefore whatever that needs to be changed is in the quantity.php file (com_hikashop/product/quantity.php), which is the only one that calculates if a product is on stock or not.

Any ideas? Whatever I tried didn't change the listing view to 'ON_STORE'.

Thanks in advance!

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 2 months ago #303711

Hi,

Use the "display view files" setting and you'll see which view file is used on the listing instead of quantity, as I explained in my previous message.
It should normally be "add_to_cart_ajax.php"

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

  • Posts: 23
  • Thank you received: 1
5 years 2 months ago #303797

Hi!

Sorry for the troubles:-(. I didn't find the "display view files" before. I edited the file and everything is working now.

Thanks!!

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

Time to create page: 0.084 seconds
Powered by Kunena Forum