Product variants or product category view problem

  • Posts: 4
  • Thank you received: 1
1 month 2 days ago #370727

-- HikaShop version -- : 6.3.0
-- Joomla version -- : 5.4.3
-- PHP version -- : 8.3.30
-- Browser(s) name and version -- : Firefox 148.0

I’m pretty new to HikaShop.

I import products (Moodle-Courses via Joomdle) and some of these products/courses are pretty much the same with the exception of the dates. I would like to have these courses displayed on one page with checkboxes or radio buttons next to the different dates and one add-to-cart button.

The normal way, I think, would be to have a product and than create variants of it. But these products already exist. And I need the original imported products because they are linked to the courses in Moodle.
My first question is: Is it somehow possible to turn a product into a variant of another product?

I tried another way, created a category for these courses/products and have them displayed on one page in a category view. Now I have the dates (in the product names) on one page, but each one has it’s own add-to-cart button.
My second question: Is it possible to turn these add-to-cart buttons into checkboxes with only one add-to-cart-button beneath it?

It would be nice if somebody had a solution for one of the two problems so I could have the look I’d like.

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

  • Posts: 85428
  • Thank you received: 13965
  • MODERATOR
1 month 2 days ago #370729

Hi,

I have a solution for both:
1. Instead of having variants, you can add these other products in the "options" setting of the main product:
www.hikashop.com/support/documentation/i...ct-form.html#options
Then, you can change the "Product selection method" setting to "checkbox":
www.hikashop.com/support/documentation/5...html#display_product
On the product page of that main product, you'll no have one checkbox for each option product.

2. If you set the "Add to cart on listings" setting to "global", you'll have one quantity input for each product of listings and a global add to cart button at the bottom of the products listings:
www.hikashop.com/support/documentation/5...html#display_product
Now, granted it's an input field, not a checkbox. To have a checkbox would require some code customization.

The following user(s) said Thank You: Gynta

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

  • Posts: 4
  • Thank you received: 1
1 month 2 days ago #370733

nicolas wrote: 1. Instead of having variants, you can add these other products in the "options" setting of the main product:
www.hikashop.com/support/documentation/i...ct-form.html#options
Then, you can change the "Product selection method" setting to "checkbox":
www.hikashop.com/support/documentation/5...html#display_product
On the product page of that main product, you'll no have one checkbox for each option product.


Thank you for your quick answer. To use "options" I'll have to buy a commercial version of HikaShop, right? Does it matter which one?

Last edit: 1 month 2 days ago by Gynta.

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

  • Posts: 85428
  • Thank you received: 13965
  • MODERATOR
1 month 2 days ago #370736

That's correct. Both can do it, so it doesn't matter which one you choose to be able to use this capability.

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

  • Posts: 4
  • Thank you received: 1
1 week 5 days ago #371061

nicolas wrote: Hi,


2. If you set the "Add to cart on listings" setting to "global", you'll have one quantity input for each product of listings and a global add to cart button at the bottom of the products listings:
www.hikashop.com/support/documentation/5...html#display_product
Now, granted it's an input field, not a checkbox. To have a checkbox would require some code customization.


Is there a way to transform this input field into a checkbox? I found the 'product/show_quantity.php' file I have to edit, but what do I have to change to make it work?

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

  • Posts: 85428
  • Thank you received: 13965
  • MODERATOR
1 week 5 days ago #371065

Hello,

You can create a view override of the `show_quantity` template to replace the quantity input with a checkbox when the global add-to-cart mode is used on listings.

Go to System > HikaShop > Display tab and edit it. In the override file, add the following code after the line `$min_quantity = 0;`:

if(!empty($this->global_on_listing)) {
?>
    <div class="hikashop_quantity_checkbox_div">
        <input type="checkbox" id="<?php echo $id; ?>_checkbox" onchange="document.getElementById('<?php echo $id; ?>').value = this.checked ? 1 : 0;" />
        <input id="<?php echo $id; ?>" type="hidden" value="0" class="hikashop_product_quantity_field" name="<?php echo $name; ?>"<?php echo $formAttr; ?> />
    </div>
<?php
    return;
}

This renders a simple checkbox that sets the hidden quantity field to 1 when checked and 0 when unchecked. The global add-to-cart button on the listing will then add only the checked products to the cart. On the product page, the normal quantity display will still be used.

The following user(s) said Thank You: Gynta

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

  • Posts: 4
  • Thank you received: 1
1 week 5 days ago #371072

It worked! Thank You thank you thank you Danke schön Muchas Gracias!

The following user(s) said Thank You: nicolas

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

Time to create page: 0.044 seconds
Powered by Kunena Forum