Author Topic: Add to Cart Linking  (Read 6011 times)

sortlarz

  • Beginner
  • *
  • Posts: 1
  • A beginner
Add to Cart Linking
« 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

Code: [Select]
/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  ???

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Add to Cart Linking
« Reply #1 on: July 18, 2017, 23:54:04 pm »
product id must be an array:  virtuemart_product_id[]=6

Code: [Select]
/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=6&virtuemart_category_id=8&quantity=1

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10466
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add to Cart Linking
« Reply #2 on: August 03, 2017, 06:30:59 am »
the quantity also, you can even add more than one product at once.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

loppan

  • Jr. Member
  • **
  • Posts: 158
    • CRASHDÏET Official Website
Re: Add to Cart Linking
« Reply #3 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?

Optic

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Add to Cart Linking
« Reply #4 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:
Code: [Select]
/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=177&virtuemart_custom_id=39[]-1.0&quantity=1Where 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!

sirius

  • Jr. Member
  • **
  • Posts: 176
    • OCTeam
  • VirtueMart Version: 3.8.6
Re: Add to Cart Linking
« Reply #5 on: July 06, 2021, 15:14:16 pm »
Hi,
the get request for custom field is more like this for example:
Code: [Select]
&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
J3.10.11 | PHP 7.4.33 + APC + memcached + Opcode
VM Prod : 3.8.6 | VM Test : 4.0.7.10732

Optic

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Add to Cart Linking
« Reply #6 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

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10637
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: Add to Cart Linking
« Reply #7 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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Optic

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Add to Cart Linking
« Reply #8 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:
Code: [Select]
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:
Code: [Select]
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