News:

Looking for documentation? Take a look on our wiki

Main Menu

Add product to cart via homemade link?

Started by Sunburst WebConsult, December 07, 2011, 09:05:48 AM

Previous topic - Next topic

siggio76

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

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

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

Quote from: Andyfoo 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

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

seanlang1

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

#20
Quote from: idlepress on November 15, 2012, 21:00:47 PM
Quote from: Andyfoo 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

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

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

Quote from: solwininfotech on April 26, 2012, 08:09:36 AM
Quote from: vrans99 on April 25, 2012, 13:08:51 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

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

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 :

<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 :

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