News:

Support the VirtueMart project and become a member

Main Menu

Questions about my multi-languages shop

Started by VB74, September 11, 2024, 10:48:42 AM

Previous topic - Next topic

hazael


VB74


VB74

#17
Hi hazael,

I have 2 more questions:

1/ How do you make your parent product non-addable to the cart? On my site the parent product can be added to the cart and therefore purchased. This doesn't make sense because it doesn't correspond to anything.

2/ Concerning the reviews and ratings of my parent product and my 6 children's products. Do you know how I could merge them into a single entity?

Thanks in advance for your help.

hazael

#18
You can always block the [add to cart] button in the initial phase to make it inactive.
If you don't know how to code - just paste this code before the end of the </body> tag.

<script>
document.addEventListener("DOMContentLoaded", () => {
  const addToCartButton = document.querySelector('.addtocart-button');
  const allRadioButtons = document.querySelectorAll('.cvselection');
  addToCartButton.disabled = true;
  allRadioButtons.forEach(radioButton => {
    radioButton.addEventListener('change', () => {
      if (radioButton.value !== 'VM_CUSTOM_NOT_SELECTED') {
        addToCartButton.disabled = false;
      }
    });
  });
});
</script>

There are also many other solutions - you can always create a different template for the parent product with a hidden or inactive button.

You can also use stock levels for all child products - the parent product in this case should have the value 0 - then you will also not be able to add it to the cart. Set the child products to some absurdly high number, for example 999999, and you can sleep soundly. ;-)

VB74

Thanks for your reply!

I copied the code you indicated before the end of the </body> tag. It's not bad but it doesn't work in the case where you put a child product in the wishlist, then from the wishlist you click on that child product, you'll then see that the "Add to cart" button will be inactive while the format and language are selected.

As for the method with the parent's stock at 0, I've tried it, but the "Add to cart" button is still there. I suppose this is logical, since in the VirtueMart configuration I've selected "Products Out of Stock are orderable, no special action". The problem is that none of the other options are suitable.

The only solution I can see would be to select "Displays 'Notify Me' instead of 'Add To Cart' button" and use CSS to not display the "Notify Me" button.

hazael

#20
Why do you need a "wish list"? after all, it is no different from "add to cart" at all. With such a small number of products, a wish list is completely pointless. If you ran a social networking site and had a large number of users and thousands of products to follow, something like this would make sense. On your website, these are just unnecessary fireworks....

As I wrote above, for the default.php file in your template, you can make a copy of the renamed file and remove unnecessary functions such as "wish list" in this file. You can also remove the "add to cart" button from displaying. this new file will also be the name of the template in the product settings, that you can assign to parent products.

This file should be located here:
templates/you-template-name/html/com_virtuemart/productdetails/default.php

VB74

Thanks for your advice, I disabled the Wishlist system.

In fact, the problem is not related to the wishlist. The "Add to cart" button is inactive if you go directly to the child product page without going through the parent.

So if a user goes through Google to get to one of my child product pages, the "Add to cart" button will be disabled. It could be very strange for the user. You can try: https://casa-bandera.com/shop-italian-cookbooks/ebook-qs1-english-epub
Do you have a solution to this problem please?

Thanks for your solution, but I don't like manipulating files and I don't know much about code.

hazael

#22
Ok, I made a slight modification - change the code and check if it works
PS. delete file: components/com_virtuemart/assets/js/jquery.noconflict.js  - this file is nonsense and causes errors. you can also remove it in the jch-optimize component

<script>
document.addEventListener("DOMContentLoaded", () => {
  const addToCartButton = document.querySelector('.addtocart-button');
  const allRadioButtons = document.querySelectorAll('.cvselection');
  const selectedRadioButton = document.querySelector('.cvselection:checked');
  if (selectedRadioButton && selectedRadioButton.value === 'VM_CUSTOM_NOT_SELECTED') {
    addToCartButton.disabled = true;
  } else {
    addToCartButton.disabled = false;
  }
  allRadioButtons.forEach(radioButton => {
    radioButton.addEventListener('change', () => {
      if (radioButton.value === 'VM_CUSTOM_NOT_SELECTED') {
        addToCartButton.disabled = true;
      } else {
        addToCartButton.disabled = false;
      }
    });
  });
});
</script>

VB74

It works, many thanks hazael!  8)

Concerning my second question, would you have a solution too? :)

2/ Concerning the reviews and ratings of my parent product and my 6 children's products. Do you know how I could merge them into a single entity?



hazael

I believe that a rating system created and managed by the platform owner adds little to no value and is among the least trustworthy. It's easy to manipulate the reviews or even write them yourself. If someone leaves a negative review, it can be effortlessly removed, leaving only positive feedback. In my view, this makes the rating system in VirtueMart one of the least valuable features in the component, and not worth using.

As we all know, even reviews on Google can be fraudulent—you can simply buy positive feedback. However, there are other alternatives that not only provide credibility but also drive traffic to your website, such as Trustpilot.