Author Topic: Add product to cart via homemade link?  (Read 27171 times)

siggio76

  • Beginner
  • *
  • Posts: 2
Re: Add product to cart via homemade link?
« Reply #15 on: August 24, 2012, 20:41:17 PM »
Hi to everybody and special thanks to solwinfotech for the form. It works fine and the product is added to the cart.

Do you know how to set a custom field value via this form? I tried to analyze original vm add-to-cart form and i get something like this:
<input class="vmcustom-textinput" type="text" name="customPlugin[19][textinput][comment]" size="64" value="">

I've tried to put the same field into my form but it simply doesn't work... As you can see this is a simple text input field where the customer should write his name. It should be easy to set but the cart function just ignore it.

Thanks in advance!

Andyfoo

  • Beginner
  • *
  • Posts: 12
Re: Add product to cart via homemade link?
« Reply #16 on: November 01, 2012, 17:28:09 PM »
This is a great code. Thanks for posting it.

I'd like to have the 'Add to Cart' button open a lightbox rather than go to the cart page in full. Any suggestions how I could tweak the code to do this?

Thanks,
-Andy

idlepress

  • Beginner
  • *
  • Posts: 17
Re: Add product to cart via homemade link?
« Reply #17 on: November 15, 2012, 20:09:05 PM »
I was directed to this thread, which solved my problem with the first 2 posts.

I have another question similar to these.

How can I incorporate a quantity selector and use a homemade "Buy now" link to add 1, 5, 20, 2043943, etc... items to the cart? (not those specific numbers, any quantity)

idlepress

  • Beginner
  • *
  • Posts: 17
Re: Add product to cart via homemade link?
« Reply #18 on: November 15, 2012, 21:00:47 PM »
This is a great code. Thanks for posting it.

I'd like to have the 'Add to Cart' button open a lightbox rather than go to the cart page in full. Any suggestions how I could tweak the code to do this?

Thanks,
-Andy

I also would like to echo this, as I find this to be more user friendly

seanlang1

  • Beginner
  • *
  • Posts: 7
Re: Add product to cart via homemade link?
« Reply #19 on: December 03, 2012, 13:14:06 PM »
Hi, i found this post very helpful, however, i also need a text link to remove a product from the cart. Does anyone know if this is possible?

Thanks,
Sean

vinmax

  • Beginner
  • *
  • Posts: 17
  • website design - web developer - laravel - joomla
    • responsive html mobile template - http://maxartkiller.in
Re: Add product to cart via homemade link?
« Reply #20 on: December 26, 2012, 13:01:54 PM »
This is a great code. Thanks for posting it.

I'd like to have the 'Add to Cart' button open a lightbox rather than go to the cart page in full. Any suggestions how I could tweak the code to do this?

Thanks,
-Andy

I also would like to echo this, as I find this to be more user friendly


Yes this is possible by using facebox jquery in your code. You need make little hack in core code. Make a caal of the cart url on click event of "Add to Cart" button.

IN product detail page you can make the change like this.

$document->addScriptDeclaration("
    jQuery(document).ready(function($) {
        $('addtocart-button').click( function(){
            $.facebox({
                iframe: 'index.php?option=com_virtuemart&view=cart',
                rev: 'iframe|550|550'
            });
            return false ;
        });
   
    });
");

Try this code
http://shoeg.in, http://maxartkiller.in

WebStuff

  • Jr. Member
  • **
  • Posts: 192
  • Time Is Precious, Waste It Wisely
Re: Add product to cart via homemade link?
« Reply #21 on: January 23, 2013, 13:26:49 PM »
This may be of interest for people wanting to add with dropdowns and text input fields.
http://forum.virtuemart.net/index.php?topic=110001.msg368586#msg368586

vchierici

  • Beginner
  • *
  • Posts: 4
Re: Add product to cart via homemade link?
« Reply #22 on: September 11, 2013, 12:28:37 PM »
Thank you for that super quick reply, solwininfotech.

Forgive my lack of knowledge. How can I send hidden variables through URL?

I appreciate your help.


I am using vm 2.0.2 and joomla 1.7

I had created one article and in that i put some information in Hidden variables.

I put the below code in "Edit HTML Source"

<form method="post"><span class="addtocart-button"> <input class="addtocart-button" title="Add to Cart" type="submit" name="addtocart" value="Add to Cart" /> </span><input type="hidden" name="quantity[]" value="1" /> <input class="pname" type="hidden" value="Hand Shovel" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /><input type="hidden" name="task" value="add" /><input type="hidden" name="virtuemart_product_id[]" value="1" /> <input type="hidden" name="virtuemart_manufacturer_id" value="1" /> <input type="hidden" name="virtuemart_category_id[]" value="1" /></form>


This is work for me ...

Try and check

AMAZING. MANY MANY Thanks

kona333

  • Beginner
  • *
  • Posts: 17
Re: Add product to cart via homemade link?
« Reply #23 on: October 21, 2013, 02:30:13 AM »
If you want a custom field to also get added, then add this:

<input type="hidden" name="customPrice[0][27]" value="784" />

You'll need to look at the source to see the custom field name (I used one I had in the example) and change the value to each of your fields.

loppan

  • Jr. Member
  • **
  • Posts: 167
    • Diet Records
Re: Add product to cart via homemade link?
« Reply #24 on: January 20, 2016, 00:32:20 AM »
It's super cool to be able to add products this way! I'm using it for offering gift wrapping and shipping insurance on the checkout-page... Really nice but I wonder how I properly can echo the price of this product? Let's say I'm adding this code to default_pricelist.php :

Code: [Select]
<a href="index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=1799&virtuemart_category_id[]=136&quantity[]=1">
Would you like to add gift wrapping to your order?
</A>

I want to add the price after the string of text, like this :

Code: [Select]
Would you like to add gift wrapping to your order? Fee: <?php echo "the base price of product ID 1799 here" ?>
I hope you understand what I mean hehe. I'm using so many currencies and sell internationally so just putting the price as raw html wouldn't be so elegant...

Truly grateful if anyone with more php-knowledge than me wanted to help out, hopefully other newbies can be helped as well :)

Thanks!

Best wishes

Peter