Author Topic: Making Custom field Cart variant required  (Read 2016 times)

johk

  • Jr. Member
  • **
  • Posts: 107
Making Custom field Cart variant required
« 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

KieranMcClung

  • Beginner
  • *
  • Posts: 3
Re: Making Custom field Cart variant required
« Reply #1 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.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8891
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Making Custom field Cart variant required
« Reply #2 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)

Code: [Select]
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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

tradexl

  • Beginner
  • *
  • Posts: 3
    • TradeXL
Re: Making Custom field Cart variant required
« Reply #3 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.?

PolishedGeek

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 263
  • Joomla! Innovation Refined.
    • Polished Geek, LLC - Joomla! extensions, web development & custom integrations
Re: Making Custom field Cart variant required
« Reply #4 on: February 14, 2013, 05:21:01 am »
You can do this with a custom field, customer input text.
~ Deb Cinkus, CEO
Polished Geek, LLC   |    www.PolishedGeek.com

Creators of JoomLister - eBay Lister for Joomla!