VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: OliviaH on March 18, 2016, 16:37:25 PM

Title: Add button to add product sample onto website.
Post by: OliviaH on March 18, 2016, 16:37:25 PM
Joomla! 3.4.8
Virtuemart 3.0.12
Website: http://www.flooringsales.co.uk/ (http://www.flooringsales.co.uk/)


We have recently changed to a new website, unfortunately the old one is gone and the code seems to be nowhere.

Basically we used to have a button underneath the 'add to cart' button that added a free sample product to the cart, with the product name as an attribute.

We had a uncategorised 'Free Sample' product with sku: FREESAMPLE, so we could control the amount of samples ordered through the shipping method, based of the sku.

I don't really know how or where to code the button into adding this product to the cart, with the sender product as some sort of attribute, so they/we know what product they want a sample of.

Making a sample product for each product is what I want to avoid as we have thousands of products.


Cheers
Dan
Title: Re: Add button to add product sample onto website.
Post by: Studio 42 on March 20, 2016, 15:00:52 PM
Hi Dan,
I think this need a custom development, because you need to use a template change and a plugin, to get the product and add the name in the product.
Title: Re: Add button to add product sample onto website.
Post by: OliviaH on March 21, 2016, 10:03:26 AM
Well I am looking to do a template override. I just don't know how to add a product to the cart via javascript.
If no one can help I'll keep looking. CUstom development is sadly not an option.
Title: Re: Add button to add product sample onto website.
Post by: Studio 42 on March 21, 2016, 11:52:51 AM
If you don't want use plugin, then you need to declare 2 options.
One is "standard" and one is "free sample" and set the option price to same price as main price but negative
FOr eg if your product price is 10 set option to -10
Title: Re: Add button to add product sample onto website.
Post by: OliviaH on March 30, 2016, 13:51:45 PM
But if the SKU is that of the product, my shipping method wont work, to ensure only a maximum of 6 samples are allowed on any one order.
Title: Re: Add button to add product sample onto website.
Post by: Studio 42 on March 30, 2016, 18:08:09 PM
For the price, you need then to add a new standard paiment or shipment when all is free.
To add a limit, this need some coding(using a plugin), it's not possible else or of course on hacking Virtuemart.
Title: Re: Add button to add product sample onto website.
Post by: OliviaH on March 31, 2016, 10:12:35 AM
I am currently using a plugin to do complex shipping methods. But I can't do it based on price as they may have samples and products in the cart.
Title: Re: Add button to add product sample onto website.
Post by: OliviaH on March 31, 2016, 12:24:27 PM
Well I have worked out how to add a button that adds a set product to the cart.
I created a sublayout that was another 'Add To Cart' button but it adds a set product_id rather than fetching the current one from the page.

<input type="hidden" name="virtuemart_product_id[]" value="3496"/>

I have a custom field on the 'Free Sample' which is currently blank.

Is there a way to change the value of that custom field in the cart with the button?