News:

Support the VirtueMart project and become a member

Main Menu

Virtuemart Dropdown Custom Field - Static Text Default

Started by brentonking, November 20, 2012, 08:43:24 AM

Previous topic - Next topic

brentonking

Apologies if this has been asked and answered, I couldn't find it.

I want to have the words "Please Select" as the default option for all of my Drop Down Custom Fields. I need it to be static and DOESN'T act as a value. If the customer doesn't change to a value/option then they can't proceed with "Add to Cart".

Obviously adding the value "Please Select" as an option in each custom field isn't going to work. I just need it as the set default globally for custom field drop downs.

Probably best to also have a fail message popup reminding them to select an option.

Using VM 2.0.10 currently (I assume this hasn't been added yet for 2.0.14 anyway)
J 2.5.8

Please help!

brentonking


Marcus Hjortsberg

I don't even know how to make a dropdown in virtuemart at all...
I would like this as well...

Thanx!



Maxim Pishnyak

You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

alvinwang21

#6
We want to set up the default value of dropdown box is select size. If customer click "add on" or "buy now" button, we can pop up a form said "please select the size of product". So, we don't have any chance that customer may accidently click on the wrong product size and get wrong product.  :)#

EDIT BY MODERATOR: This is not the issue raised by the OP

Maxim Pishnyak

You could use parent(product)-child(sizes) relation.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

balai


You can create the drop-down using the cart variant custom field and set the values you like but you should create on your own the validation rule and alert.


alvinwang21


balai

Hi

here is the explanation for the cf:
http://www.ostraining.com/blog/joomla/custom-field-virtuemart/

As type select "cart variant"
As for the validation rule you should find a lot of stuff if you google it.

I think that you should get the selected value and if its the value of the default option "select something" to alert a message

"select something" should be set as option too, to your products

tuki

Check this tutorial http://awebsupport.com/vm2-set-up-child-product-with-stock-control
And the demo site: http://awebsupport.com/virtuemart-child-product-with-stock-control/productdetails/5
Did you mean this?

Some other useful information: We made +1 custom child called "Please Choose" ,and made a little modification in the default addtocart layour (not show add to cart button for this child product), and this works fine.

MikeUK

To bring this back on track after alvinwang21 almost derailed the thread..........  (@alvinwang21, see your first post. Changing the issue of a thread does not help. So make sure you understand the issue before posting)

I noticed this issue with the drop down (where there is no default 'please select' in the drop down list). I think I've got a fix. It needs more testing though.

To clarify, this fix changes the parent product name in the drop down to "-Please Select-".

This  works only if the custom field in the parent product has the 'Display parent as option' checked, and should only be used if the 'Parent orderable' option is unchecked.

In file administrator\components\com_virtuemart\models\customfields.php, change this:
foreach ($uncatChildren as $child) {
$options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id'],FALSE), 'text' => $child['product_name']);


to this:

foreach ($uncatChildren as $child) {
// -- Dropdown modification start (MikeUK)
if ($child['product_name'] != $product->product_name) {
$adapted_text = $child['product_name'];
}
else {
$adapted_text = "-Please Select-";
}
$options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id'],FALSE), 'text' => $adapted_text);
// -- Dropdown modification end
}
Get answers faster:
    [li]
Search forum. You might find answer[/li]
[li]Use existing threads. Keep Q + A consolidated[/li]
[li]Troubleshooting? See http://forum.virtuemart.net/index.php?topic=60033.0[/li]
[li]For admin user manual - http://virtuemart.net/documentation/User_Manual/index.html[/li]
[li]For coding (developer manual) - http://virtuemart.net/documentation/Developer_Manual/index.html[/li][/list]

I can build your online shop, setup or customize Virtuemart or help your existing shop maximize its potential. Email / PM for info

Nocturnaloner

Developers, thank you for this wonderful free software.  That said, this is basic functionality that is still broken, even after all this time.  If I have 2 child items, and the parent is not orderable, I can't add the first selected child to the cart.  I actually have to chose the second child item, then select the first again for it to be enabled to be added to the cart.  This is a bug that needs to be fixed.

Darkheart

#14
Yes, this is very annoying...

MikeUK - thanks fo your mod - it works! I have changed 
$adapted_text = "-Please Select-";
to
$adapted_text = JText::_ ('COM_VIRTUEMART_LIST_EMPTY_OPTION');
This is better for multilingual sites.