VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: johk on October 20, 2012, 12:43:17 PM

Title: Making Custom field Cart variant required
Post by: johk on October 20, 2012, 12:43:17 PM
Hi,

Say I have a t-shirt that comes in different sizes. I can setup the sizes and different prizes for them using the Custom Field Cart Variant. Is it possible to make it a required field ie the user has to choose a size from the dropdown.
I realise this can be done with cart control but for this shop it is not required.

Any suggestion most appreciated.

Johk
Title: Re: Making Custom field Cart variant required
Post by: KieranMcClung on February 11, 2013, 13:33:59 PM
This is also a problem I am facing.

Currently the site I'm creating allows for colour selection, although this doesn't affect the price of the product. So it's currently set up with a cart attribute drop down list of colours. Someone can add the item to the basket regardless of selecting a colour, and this isn't ideal.

To the OP, did you find a solution? Or to anyone else is there a solution out there?

I'm quite new to VM so I might be misunderstanding terminlogy and the use of certain attributes, and such, so apologies if I'm misunderstanding things.

Thank you.
Title: Re: Making Custom field Cart variant required
Post by: GJC Web Design on February 11, 2013, 14:56:08 PM
Haven't tried this but the code for the Add to cart is in

components/com_virtuemart/helpers/shopfunctionsf.php ~ line 98

I would copy this code into a components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php template overide (i.e. call it directly)

if($this->product->orderable){
vmJsApi::jPrice();
$html = '<input type="submit" name="addtocart" class="addtocart-button" value="'.JText::_('COM_VIRTUEMART_CART_ADD_TO') .'" title="'.JText::_('COM_VIRTUEMART_CART_ADD_TO') .'" />';
} else {
$html = '<input name="addtocart" class="addtocart-button-disabled" value="'.JText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT') .'" title="'.JText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT') .'" />';
}


and try detecting your attribute with jquery etc to manipulate the add to cart.. maybe hide the <span class="addtocart-button"> span if dropdown not selected
Title: Re: Making Custom field Cart variant required
Post by: tradexl on February 13, 2013, 09:59:51 AM
i just want to know that how to put written text box on item details page? and if client complete that text box than how to get that text box value.?
Title: Re: Making Custom field Cart variant required
Post by: PolishedGeek on February 14, 2013, 05:21:01 AM
You can do this with a custom field, customer input text.