News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Custom implementation of switching products in browse view

Started by Kuubs, February 07, 2024, 10:48:19 AM

Previous topic - Next topic

Kuubs

I have some issues with the changing of the products via custom fields in the category view (browse view).

So i want to implement my own solution to change the product selected in the browse view, and thus changing the add to cart link (so the user can directly put the product into its cart in the category view).

I tried to change the hidden input fields:

<input type="hidden" name="virtuemart_product_id[]" value="237">
<input type="hidden" name="pname" value="Product name">
<input type="hidden" name="pid" value="237">

But when I change these values, it does not actually does the adding to cart correctly.

So what do I need to change exactly to make this work?

Kuubs

The problem i Have is that I use generic child variant, in the browse view, i cannot pick a color to update the addtocart button. So it keeps on disabled settnig Choose a variant.

But with my own implementation i can manually change all the necessary things to make it work. But I'm not sure how this needs to be done. I also tried looping through all the child variants and render the sublayout addtocart for every child but that also won't work. the popup that it's in the cart is not displayed correctly like for example other pages and it does not actually add the product into the cart :(

Kuubs

I have made this work.

You have to render the addtocartbar so the amount gets rendered. And then you only have to change the hidden fields described above!

Milbo

Quote from: Kuubs on February 08, 2024, 12:59:15 PM
The problem i Have is that I use generic child variant, in the browse view, i cannot pick a color to update the addtocart button. So it keeps on disabled settnig Choose a variant.
You can configure them so, that you sell the parent too. You can use it with and without empty option. Without empty option, your cart variant is selected.

Quote from: Kuubs on February 08, 2024, 12:59:15 PM
But with my own implementation i can manually change all the necessary things to make it work. But I'm not sure how this needs to be done. I also tried looping through all the child variants and render the sublayout addtocart for every child but that also won't work. the popup that it's in the cart is not displayed correctly like for example other pages and it does not actually add the product into the cart :(

For me this sounds like a bug due your template or misunderstanding. You can use the generic child in the browse view and change the selected variant there with ajax. So I wonder what you try todo.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/