hide the option to change the amount in a cart for a certain categorie

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312008

-- HikaShop version -- : 4.2.2
-- Joomla version -- : 3.9.12
-- PHP version -- : 7.3

Hi,
We have a situation where we use option products that are automatically loaded when a customer buys a product.
When the customer buys 2 products, the optional product is also increased to 2.
This is all working fine.

The issue arrises when the customer is changing the amount of the option product to a lower value then the product. This is not allowed.
I can understand it's difficult to enforce that so we are exploring the options to have a little work-around to make it more difficult for the customer to change this value.

Would it be possible to make changes to the cart and wishlist view so the fields to change the amount are hidden/disabled for all products from a certain parent categorie? This because all the option products are in 1 parent categorie.

Thanks for any tips on this !

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
4 years 6 months ago #312017

Hi,

If you activate the "group options with product" setting in the Hikashop configuration then the customer cannot change the quantity of options as they automatically use the quantity of the main product in the cart.

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312029

Hi, that would have been a great solution but now it looks like the main product is really expensive.
Unfortunately this is not the way to go for this client.

Is there a way to keep the optional product visible while using this option so the customer can see the individual prices?

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

  • Posts: 12953
  • Thank you received: 1778
4 years 6 months ago #312030

Hello,

I think that would require some customization of Hikashop files of the product view via Hikashop->Display->Views.

Can you give us more information about what you exactly want through some screenshots ? Thank you.

Kind regards,
Mohamed Thelji.

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312053

Hello Mohamed,

I hope this explains it well enough :

Attachments:

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
4 years 6 months ago #312055

Hi,

What you could do is edit the file "show_block_cart" via the menu Display>Views and after the line:

foreach($cart->products as $i => $product) {
you could add:
if(empty($product->cart_product_option_parent_id)) {
 $this->options['status'] = true;
} else {
 $this->options['status'] = false;
}

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312088

Hi,

Thanks for this Nicolas.

What I can see now is that on the checkout the field of the product is not editable, this should beon the option product.
And if we get this switched, is this also applicable to the cart view?

Thank you very much for helping with this creative solution :)

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
4 years 6 months ago #312101

Hi,

I'm not sure what you mean by "the cart view". Are you talking about the HikaShop cart module ? Or the HikaShop cart manager ?
Or something else ?
In any case, a similar modification will be possible, but what modification to do where depends on what you're talking about, so I can't say anything precise.

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312110

Hi,

Sorry for not being clear the first time.

With the cart view I mean what visitors see when they click on "cart" in our menu.
index.php?option=com_hikashop&view=cart&layout=show

With the checkout they use this :
index.php?option=com_hikashop&view=checkout&layout=show

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

  • Posts: 12953
  • Thank you received: 1778
4 years 6 months ago #312123

Hello,

With the cart view I mean what visitors see when they click on "cart" in our menu.
index.php?option=com_hikashop&view=cart&layout=show


To edit that page displaying, you'll just have to edit the "Show" file of the "Cart" view of your front-end template via "Hikashop->Display->Views".

With the checkout they use this :
index.php?option=com_hikashop&view=checkout&layout=show


And for that page displaying, you'll have to edit the "show_block_cart" file of the "checkout" view of your front-end template via "Hikashop->Display->Views".

Kind regards,
Mohamed Thelji.

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312255

Hi Mohamed,

Thanks for the extra explanation.
I understood the different view files part.
To me the problem is figuring out where to put the code in the right place to disable editing the amount field for the options product in those views.
The code Nicolas gave disables the amount for the main product and of the optional product(or my demo site is not OK).
I tried to switch the values but no luck for me;)

A bit of extra info just to get the best explanation for future readers maybe..

- main product has an optional product
- optional product is created with 1 charateristic and a price

The amount of products ordered of the main product should always be the same as the optional product.
Unfortunately we cannot use the group option because this makes the product look expansive (short explanation).

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
4 years 6 months ago #312263

Hi,

Well, the code is quite similar but the variable names are different. After the line:

foreach($this->cart->products as $k => $product) {
you could add:
if(empty($product->cart_product_option_parent_id)) {
 $this->manage = true;
} else {
 $this->manage = false;
}

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312265

Hi,

Thanks for this code.

To be clear, we started in the "show_block_cart" file so first I went to that file.
In this file the string "foreach($this->cart->products as $k => $product) {" cannot be found.
I could only find this in the "show" view file so tried to put the code there.
Unfortunately this looks like it does not change anything in the frontend.
Did I apply it not as intended?

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
4 years 6 months ago #312266

Hi,

It's indeed in cart / show.php that you need to do that change.
I don't see why it wouldn't change anything unless you're not editing that view file for your frontend template.

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312418

Hi,

To rule out old modifications I installed a new and clean demo site to test this code.
Unfortunately I see no change happening in the front after putting the code in the frontend view "cart > show" at around line 129.

It must be me or we are not on the same page about this (we are all human after all :) )

If you want to take a quick peak I can give an account, no problem.
Maybe better than making this a very long thread (if you want)?

Thanks anyway for helping.

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
4 years 6 months ago #312428

Hi,

Please understand that custom development is outside regular user support.
We do ask for backend access to check settings and fix bugs as part of the user support, but we're not supposed to help you with custom development.
Providing you pieces of code here is already a big stretch.
If you want us to work on that for you, I'm afraid we would have to bill you a small extra.
If interested, you can use our contact form with a link to this thread and a backend access and we can do that.

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

  • Posts: 290
  • Thank you received: 22
4 years 6 months ago #312433

Hi,
I understand that and don't want to stretch more than this.

Will have a good look to figure this one out and contact if nescesarry for a bit of custom work.
I will also update when I have the cause / solution for others to find.

Thanks so far !

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

Time to create page: 0.103 seconds
Powered by Kunena Forum