VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: sortlarz on July 18, 2017, 23:47:03 PM

Title: Add to Cart Linking
Post by: sortlarz on July 18, 2017, 23:47:03 PM
Hello !

I am currently using v3.2.2 on Joomla 3.7.3.

I am using VM only for check out as i've got a different way of displaying products. I need to use a custom add to cart link.

I found and used this

/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id=6&virtuemart_category_id=8&quantity=1

This one , links me to the cart but it wont really add my product.

Please help  ???
Title: Re: Add to Cart Linking
Post by: K&K media production on July 18, 2017, 23:54:04 PM
product id must be an array:  virtuemart_product_id[]=6

/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=6&virtuemart_category_id=8&quantity=1
Title: Re: Add to Cart Linking
Post by: Milbo on August 03, 2017, 06:30:59 AM
the quantity also, you can even add more than one product at once.
Title: Re: Add to Cart Linking
Post by: loppan on August 03, 2017, 08:46:20 AM
What is the "syntax" for adding more than one products in the same URL? Also, does this work with child products?
Title: Re: Add to Cart Linking
Post by: Optic on July 06, 2021, 14:39:28 PM
Hey

Maybe someone could please give me advise how I can add some custom fields with predefined values in the URL?
The URL, provided here looks really good and it works, but my article has custom fields, which must be filled as well.
Please tell me how to change the URL, so it will accept custom fields with values

I tried the following:
/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=177&virtuemart_custom_id=39[]-1.0&quantity=1
Where the custom_id=39 is the used custom field and the -1.0 should be the value of this field.
But it isn't working

THX in advance!
Title: Re: Add to Cart Linking
Post by: sirius on July 06, 2021, 15:14:16 PM
Hi,
the get request for custom field is more like this for example:
&customProductData[2265][6]=7514&customProductData[2265][25]=7515&quantity[]=1&virtuemart_product_id[]=2265

[2265] => product ID
[6] => the ID of the custom option in the #__virtuemart_customs table
7514 => the ID of the customfield stored for this product id in #__virtuemart_product_customfields table

But so the custom field must exist first

Hope it help a little bit
Title: Re: Add to Cart Linking
Post by: Optic on July 09, 2021, 16:44:58 PM
Hey

Sorry for the late reply!
Your suggestion works almost brilliant, after a couple of tests

One last question:
How to add multiple products in that style? - Do I have to call one url after the other, or is there a way to combine them in one URL?

THX a lot in advance
Title: Re: Add to Cart Linking
Post by: GJC Web Design on July 09, 2021, 18:46:41 PM
index.php&optionvirtuemart&view=cart&task=add&quantity[]=5&virtuemart_product_id[]=22&quantity[]=2&virtuemart_product_id[]=55
Title: Re: Add to Cart Linking
Post by: Optic on July 10, 2021, 11:46:21 AM
Hey
THX - but this I tried and is not working
When I add an article with this url, it works:
index.php?option=com_virtuemart&view=cart&task=add&customProductData[175][44][119]=14.00&customProductData[175][45][118]=8&customProductData[175][43][117]=1&quantity[]=1&virtuemart_product_id[]=175

But when I combine (same article, with different custom product data), it just adds the last article, but not both:
index.php?option=com_virtuemart&view=cart&task=add&customProductData[175][44][119]=14.00&customProductData[175][45][118]=8&customProductData[175][43][117]=1.00&quantity[]=1&virtuemart_product_id[]=175&customProductData[175][44][119]=14.00&customProductData[175][45][118]=8&customProductData[175][43][117]=4.00&quantity[]=1&virtuemart_product_id[]=175

THX