Hidden Variant Causing Issues

  • Posts: 800
  • Thank you received: 10
  • Hikashop Business
1 week 3 days ago #322507

I'm in a bit of a pickle and I'm not sure how to fix it.

Say I have a Small, Medium and Large item.

If the Small is SOLD OUT, when the customer goes to the page, they see the SOLD OUT message without clicking on "Small". This is deceiving as it appears that all of that product is sold out. Please see the URL added in this post.

So what I usually do is create a default variant and add it as the first one, then use CSS to hide it to get rid of the issue stated above. See example attach.

If the user goes to the page and click "Add to Cart" without selecting a size, the DEFAULT variant is added to the cart.

How can I avoid getting the DEFAULT/(Hidden) variant added to the cart?

Thanks!

Attachments:

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

  • Posts: 70194
  • Thank you received: 10508
  • MODERATOR
1 week 3 days ago #322542

Hi,

What you could do is to edit the file product / show.php via the menu display>Views and add a bit of code at the beginning to hide the add to cart button when the page is loaded:

<script>
window.hikashop.ready( function(){
	document.querySelector('#hikashop_product_quantity_main .hikacart').style.display = 'none';
});
</script>

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

  • Posts: 800
  • Thank you received: 10
  • Hikashop Business
1 week 2 days ago #322559

Hi nicolas,

So the code works perfectly for products that have variants but it does not work for products that do not have variants.

If you look at products in the "Preowned" section you will notice that the "Add to Cart" button is not showing because there is only one of each so I didn't have to use variants.

So maybe the code should be;
If there is variant hide the "Add to Cart" button until a selection is made, if no variant then don't hide it.

I will send the URL privately so you can see what I mean.

Thanks!

Last edit: 1 week 2 days ago by MyWorld.

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

  • Posts: 70194
  • Thank you received: 10508
  • MODERATOR
1 week 1 day ago #322561

Hi,

Then you just need an additional check around that code:

<?php if(!empty($this->element->variants))  { ?>
<script>
window.hikashop.ready( function(){
	document.querySelector('#hikashop_product_quantity_main .hikacart').style.display = 'none';
});
</script>
<?php } ?>

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

  • Posts: 800
  • Thank you received: 10
  • Hikashop Business
4 days 20 hours ago #322722

Hi nicolas,

The website owner was saying that when the button is not visible customers may think that the product is out of stock. So she was asking if:

1) It's possible to disable the "add to cart" button and only enable it after they click on a size. Similar to what is done here:
www.roots.com/ca/en/cabin-slim-cuff-swea...emsourse=productlist

OR

2) Keep the button enabled/visible but display a message if they click on "add to cart" without selecting a size. Similar to what is done here:
www.gapcanada.ca/browse/product.do?pid=5...3_1#pdp-page-content

Thanks!

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

  • Posts: 70194
  • Thank you received: 10508
  • MODERATOR
4 days 9 hours ago #322733

Hi,

Both are possible with some more complex custom coding.
If you want us to work on this for you, you can use our contact form to request a quote:
www.hikashop.com/support/contact-us.html

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

  • Posts: 800
  • Thank you received: 10
  • Hikashop Business
4 days 1 hour ago #322768

Well I'm not sure what the cost will be..but I'm assuming it's not going to be cheap.

I think the option to have customers select a variant in order to add an item to the cart should be part of Hikashop software without having to pay extra to have it added as it's not a unique customization, this should have been a default feature from the start - other ecommerce softwares has it as part of their software, and not an added feature, eg: j2store.net/demo/index.php/shop/simple

I also had to purchase other extensions in order to improve Hikashop's functionality so having to pay for other extensions, pay for hikashop software, pay for a feature that I think should already be part of the software, sadly for me, I cannot afford at this time.

Thanks!

Last edit: 4 days 1 hour ago by MyWorld.

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

  • Posts: 70194
  • Thank you received: 10508
  • MODERATOR
3 days 9 hours ago #322784

Hi,

the option to have customers select a variant in order to add an item to the cart should be part of Hikashop software without having to pay extra"

That is already the case by default.
By default, the default variant is preselected. And thus, it is impossible to add a product to the cart without having a variant selected.
You changed the way it works to make it look like a variant isn't preselected and thus created that problem with the add to cart button being visible even though it's not a working one.
So having us fix that issue, which is specific to your website has to be an extra.
Now if instead you want us to add the capability to not have a variant preselected, we actually added that capability with the latest version with the "Characteristics dynamic display" setting. However, this works only when the product has more than 1 characteristic. And that's why I proposed another solution to do what you want here:
www.hikashop.com/forum/feature-request/9...-variant.html#322632
This would be possible without any coding (just a bit of CSS).

So basically there is one choice:
- you follow my advice and you're done with a bit of CSS and product / variant configuration
- you do it your way and it requires a bit of javascript coding
- you stay with the default system available and wait for us to implement some improvement to the system in the future

I'm not here to try to get more money from you. I'm proposing solutions that you can have directly on your website, without having to wait for us to improve HikaShop in the future. I actually gave you some simple code propositions but it seems you want something more complex to code. At that point it requires proper development, and thus money for the time spent.

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

  • Posts: 800
  • Thank you received: 10
  • Hikashop Business
2 days 18 hours ago #322815

I definately was not implying that you were trying to get more money from me - I'm sorry if that's how it came across. I was just saying that I had no money at the moment for this. I thought this feature should have been something that is already part of the software. If you say it is, and I missed it - I apologize.

Thanks!

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

  • Posts: 70194
  • Thank you received: 10508
  • MODERATOR
9 hours 37 minutes ago #322824

Hi,

No worries. But you didn't came back to me on this other thread where I provided a solution which should suit your needs:
www.hikashop.com/forum/feature-request/9...-variant.html#322632
Did you try it out ?

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

  • Posts: 800
  • Thank you received: 10
  • Hikashop Business
37 minutes ago #322844

I will take a look and try it out. Thanks :)

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

Time to create page: 0.067 seconds
Powered by Kunena Forum