When making a parent and children with "Generic Child Variant" I get a very nice dropdown list with the parent and the children listed. THIS IS FINE!
BUT because often the parent is the template for the variants of the children, the parent, at least in some cases, should not be addable to the shopping cart.
This because all the variations, the children, have the specific properties.
For example T-shirts. T-shirts have size and color.
To show all the variants with "Generic Child Variant" works perfectly. The parent being the pattern and the children the different entities.
But if a shopper, by accident puts the parent in the shopping cart, the shop owner can not know which size and color to ship.
How can be prevent that the parent is put in the shopping cart.
If not possible in version 2.0.2 / 2.0.3, could an option be added to parents like "addable to shoping cart"or "valid cart value" or ... (what's in a name).
Please give me advise how to handle.
I have the same problem. My semi optimal solution so far is to add these lines after line 703 in
administrator\components\com_virtuemart\models\customfields.php
----------------------------------------------------------------------
if (sizeof($options) > 1) {
$options[0]['text'] = "Choose";
}
----------------------------------------------------------------------
And then add the following lines after line 119 in
components\com_virtuemart\controllers\cart.php
----------------------------------------------------------------------
if (sizeof($virtuemart_product_ids)>0) {
$jobDb = JFactory::getDbo();
$sqlStmt = 'SELECT count(*) FROM #__virtuemart_products p, #__virtuemart_product_customfields f, #__virtuemart_customs c
WHERE p.product_parent_id=0 and p.virtuemart_product_id='.$virtuemart_product_ids[0].' and
p.virtuemart_product_id=f.virtuemart_product_id and c.field_type=\'A\' and c.virtuemart_custom_id=f.virtuemart_custom_id';
$jobDb->setQuery($sqlStmt);
$jobResult = $jobDb->loadResult();
if ((int)$jobResult >= 1) {
jExit();
}
}
One word: GREAT!
One small suggestion: when trying to add the parent to the shopping cart, give a error message that the user has to choose!
Insert these lines in cart.php instead:
-----------------------------------------------------
if (sizeof($virtuemart_product_ids)>0) {
$jobDb = JFactory::getDbo();
$sqlStmt = 'SELECT c.custom_title FROM #__virtuemart_products p, #__virtuemart_product_customfields f, #__virtuemart_customs c
WHERE p.product_parent_id=0 and p.virtuemart_product_id='.$virtuemart_product_ids[0].' and
p.virtuemart_product_id=f.virtuemart_product_id and c.field_type=\'A\' and c.virtuemart_custom_id=f.virtuemart_custom_id';
$jobDb->setQuery($sqlStmt);
$jobResult = $jobDb->loadResult();
if ($jobResult != null) {
$errorMsg = "You must choose " . $jobResult;
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
echo json_encode($this->json);
jExit();
}
}
-----------------------------------------------------
Can someone from the virtuemart team please respond on this topic? Why can't we have such a basic feature without editing the source code? Or am I missing something fundamental here?
This is a very good solution. Thank you. Would it be possible to have an option like "please choose" instead of the parents name at the top of the list?
Yes you can by inserting these lines after line 703 in administrator\components\com_virtuemart\models\customfields.php
if (sizeof($options) > 1) {
$options[0]['text'] = "Please choose";
}
Another semi optimal solution is to follow Milbo's advice here: http://forum.virtuemart.net/index.php?topic=98648.0
That way your users will have the first variant if they forget to choose and click the "add to cart"-button.
I have found another bug in VM2 regarding variants. The combo box is not visible when using IE9 and the default VM2 template. It works in firefox and chrome though.
Thank you for your answer. But it doesn't help. I still don't see the "Please choose", just the parents name on top of the dropdown. May be this is why I'm testing with version 2.0.3H? This version seems to have some bugs.
EDIT: updated to 2.0.3 I, still no effect. First part in cart.php works fine! Is it correct to insert it just before the line beginning with
"if ($is_list>0) {"
EDIT2: I have found it: Need to go to line 766 after
foreach($uncatChildren as $k => $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']) ,'text' =>$child['product_name']);
Oh sorry, I forgot to mention, I am using 2.0.2 which according to "Virtuemart 2 - Live update" is the latest stable version. Nevertheless, it seems so unstable that I will have to go back to 1.1.9.
I see that you write that you have a good dropdown list when using "Generic Child Variant"
If i make this, i get a list , but it expands and closes when i click on the list.
Only way to choose from the list is when i hold my mouse button on the list, and move the mouse cursor a little bit....
Someone that can help me out??
http://cmalo.nl/testsite2/index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=37&virtuemart_product_id=58 (http://cmalo.nl/testsite2/index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=37&virtuemart_product_id=58)
I am facing another problem and i am looking for a solution.
I am using VM 2.0.2 and Joomla 2.5.4
I had create a Generic Child Variant, associated with the parent item, and one child item. My problem is that the dropdown list contains the parent item more than once time and one child item. The result of the dropdown is the parent 3 times and the child one.
Any suggestions how to resolve the problem?
Thomas
@cmalo...I clicked on your link because I am having the same problem you describe.
How did you fix it?
I see you guys are using 2.0.2 not 2.0.4. Have you tried updating? I need to implement a similar solution.
It's all in the upgrade apparently.
After upgrading to 2.0.4 it looks like the customfield for child product variants has a drop down that stay dropped down.
The issue @cmalo was having.
I tried upgrading to 2.0.4 and this version was worst than 2.0.2
Any suggenstions on 2.0.2?
Quote from: olesman on April 12, 2012, 15:27:09 PM
@cmalo...I clicked on your link because I am having the same problem you describe.
How did you fix it?
Updating to 2.0.4 fixed it
_______________________________
My next problem is that i dont know how to sort child items
As far as I know there is no sort option. Children are sorted in the order they were created.
Quotebecause often the parent is the template for the variants of the children, the parent, at least in some cases, should not be addable to the shopping cart.
This because all the variations, the children, have the specific properties.
I`ve been fighting with this for weeks - another thing that was super easy in vm 1.1 which apparently cannot be done in vm2 - at least without hacking the core (and re-hacking & re-hacking the core with every update)
I don `t know if the dev team even bothers to read these forums, but it was soooo much better when the parents were not added to the children dropdowns & all you had to do to make it so that the parent could not be added to the cart was simply not give it a price.
can`t we have something that easy with this new 'improved' system? PLEASE!
Quote from: patbe60 on April 12, 2012, 18:20:09 PM
As far as I know there is no sort option. Children are sorted in the order they were created.
how can they possibly expect you to create your products in the correct order you want them displayed?
say you have 1500 products in your shop & each has several children - if you get a new child option & want this product displayed near the top you have to delete every other product & re-add them in order?
that`s insane
I agree. It is another basic usability feature that should not be ignored. I could live without it but is sure makes life easier.
@ Orfirel
I'm on VM 2.0.6 now. Your hack works still fine. BUT: There'a a new option in configuration, " Display modal popup upon 'Add to cart' ".
When enabled the hack works fine, when disabled it doesn't work, also Parent will be added to the cart. Is there any solution?
Quote from: thomaska on April 12, 2012, 13:00:55 PM
I had create a Generic Child Variant, associated with the parent item, and one child item. My problem is that the dropdown list contains the parent item more than once time and one child item. The result of the dropdown is the parent 3 times and the child one.
Same here!
It seems if you use a product (with childs) in more than one category then the parent item appears multiple. :(
ok I think I have spot a bug here , because I m not the only to get this error, and I have test and install on 3 differents computer with fresh download joomla 2.5.4 + vm 2.0.6 and the issue is still here:
*BUG find with the parent product /child
when you set up the stock of the parent product to =6
When the stock of the child product is coming to = 0 it takes automatically the stock of the parent (=6)
Moreover the parent product can be ordered which is not ok. (there should be a warning popup asking to choose a size or color first - meaining choosing a child product from the parent product)
I could set up the stock of the parent produt to = 0 but there will be a problem on the page of the parent product it will show= product out of stock or notify me which is measleading the customer that will think the product is not available.
Could you please let me know on how to fix this issue?
My e-commerce is stuck from opening because of this.
Im using VM 2.0.6 and joomla 2.5.4
I`ve been begging for a fix for this for months
I`m still using VM 1.1 for all my ecommerce sites because VM2.0 just doesn `t work as well as the original
Virtuemart 2.0.6
When I insert the code below in cart.php just after the line with:
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
The error message isn't generated when the parent item is added. Is this the right place to insert this code?
-----------------------------------------------------
if (sizeof($virtuemart_product_ids)>0) {
$jobDb = JFactory::getDbo();
$sqlStmt = 'SELECT c.custom_title FROM #__virtuemart_products p, #__virtuemart_product_customfields f, #__virtuemart_customs c
WHERE p.product_parent_id=0 and p.virtuemart_product_id='.$virtuemart_product_ids[0].' and
p.virtuemart_product_id=f.virtuemart_product_id and c.field_type=\'A\' and c.virtuemart_custom_id=f.virtuemart_custom_id';
$jobDb->setQuery($sqlStmt);
$jobResult = $jobDb->loadResult();
if ($jobResult != null) {
$errorMsg = "You must choose " . $jobResult;
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
echo json_encode($this->json);
jExit();
}
}
-----------------------------------------------------
Update:
The error message pop ups only if the option 'Display modal popup upon 'Add to cart'' in [Components, Virtuemart, Configuration, Checkout] is checked. If this option is not checked, the error message will not appear and the parent can be added to the shopping cart.
I am using VM 2.0.6 and I am having trouble
in customfields.php line 703 is
if ($is_list>0) {
on line 704 I paste
if ($is_list>0) {
if (sizeof($options) > 1) {
$options[0]['text'] = "Please choose a size";
}
When I look at my page http://www.likdancewear.com/component/virtuemart/ellieshoes/3-or-less/016-mila-g-blkg-adult-glitter-flat-with-bow-detail.html?Itemid=0
I still see the parent item listed as the first item in the drop down. I want to see "Please choose a size".
I have the stock on my parents set to 0 so you can't order them. Only my children have stock.
Can anyone please help with the correct code for VM 2.0.6?
HOLY CRAP!!! - I think I found it with my fundamental php skills.
This appears to work, but I need to test ordering a product to see what happens.
in administrator\components\com_virtuemart\models\customfields.php
around line 763
foreach($uncatChildren as $k => $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']) ,'text' =>$child['product_name']);
change to
foreach($uncatChildren as $k => $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']) ,'text' =>$child['product_name']);
$options[0]['text'] = "Please choose a size";
}
-----------------------------------------------
or just add
$options[0]['text'] = "Please choose a size";
on the line before the
}
Thanks that seems to work, although I'd prefer that "notify me" wasn't there as it could make some people believe the whole product is out of stock and deter them from trying to choose a size or colour. But it's still much better than what we had.
Just a note - If you're using a newer test version it has moved in the code down to around 1038 (well in 2.0.7f it has). They've changed the spacing a bit so using the find function doesn't easily work.
QuoteHOLY CRAP!!! - I think I found it with my fundamental php skills.
This appears to work, but I need to test ordering a product to see what happens.
Yeah! - that`s very good work.
I also wish that the Parent Price and the 'notify me' or 'add to cart' would not appear on the parent page (used to be so easy - just set parent price to '0.00'), but this is by far the closest that I have seen anyone come to making the new VM work as well as the old.
This should be incorporated into the core of the next release.
I made a small adjustment to the hack
foreach($uncatChildren as $k => $child){
$childprice = getChildPrice($child['virtuemart_product_id']); // get the price for child products
$childprice = number_format($childprice->product_price, 2, '.', '');
$options[] = array( 'value' =>
JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id='.$virtuemart_category_id.'&virtuemart_product_id='.$child['virtuemart_product_id']) ,'text' =>$child['product_name']." [$".$childprice."]");
$options[0]['text'] = "Please choose a size";
}
this allows to show the child product price in the dropdown
Quote from: dsrpmedia on June 17, 2012, 22:01:31 PM
I made a small adjustment to the hack
foreach($uncatChildren as $k => $child){
$childprice = getChildPrice($child['virtuemart_product_id']); // get the price for child products
$childprice = number_format($childprice->product_price, 2, '.', '');
$options[] = array( 'value' =>
JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id='.$virtuemart_category_id.'&virtuemart_product_id='.$child['virtuemart_product_id']) ,'text' =>$child['product_name']." [$".$childprice."]");
$options[0]['text'] = "Please choose a size";
}
this allows to show the child product price in the dropdown
Pardon me, but I can't solve your puzzle. I saw
Fatal error: Call to undefined function getChildPrice() in ..........administrator\components\com_virtuemart\models\customfields.php on line 763
and can't find getChildPrice neither in 2.0.6, nor in 2.0.7 files at all
Can you share developed by you function "getChildPrice"?
Thanx in advance!
this hack is for 2.0.6 - you can see it in action here http://vm20b.fyica.com/virtuemart/gardentools/test-detail - the thing I haven`t figured out is how to not display a price for the parent.
I`m on the road today, when I get back to the office I`ll upload my customfields.php file
Hi, does anyone know the Virtuemart 2.0.8e equivalent of this?
Quote from: ben1390 on August 21, 2012, 14:09:12 PM
Hi, does anyone know the Virtuemart 2.0.8e equivalent of this?
I think i solved this using http://forum.virtuemart.net/index.php?topic=100330.msg346003#msg346003 and displaying parent in customfield and categorizing only parent. But images of child 1 are the same of parent.
I found this to work.
foreach ($uncatChildren as $k => $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']), 'text' => $child['product_name']);
}
array_unshift($options,"Please chooose an option"); // this pushes the option to the top of the list.
However, I am still looking for a way to now require that something get picked.
In 2.0.14 you can not longer add the parent, however the first item in the drop down box is your first child so it appears to the customer that they can't order the first child variant. The first item in the drop down box should say something similar to Select Your Variant.
i'm using 2.0.14 and adding the parent is always possible, wether i check "parent orderable" or not! :( :-[ :'(
Same problem here after updating to 2.0.14 :-\
Hi Orfirel,
do you have a working example of this? Or has there been any updates from the Virtuemart Dev team on this?
I have followed the thread and I am unable to get this working. My demo / dev site with parent child products and attributes is here:
http://integrousdemo.co.uk/ccs/shop/painting/paint/k2-paint-detail
so VOLUME, YEAR and GENERAL COLOR need to be mandatory and I should not be able to add to cart if VOLUME has not been selected
Thanks in advise
Kind regards
Alan
Quote from: Orfirel on March 30, 2012, 09:32:55 AM
Insert these lines in cart.php instead:
-----------------------------------------------------
if (sizeof($virtuemart_product_ids)>0) {
$jobDb = JFactory::getDbo();
$sqlStmt = 'SELECT c.custom_title FROM #__virtuemart_products p, #__virtuemart_product_customfields f, #__virtuemart_customs c
WHERE p.product_parent_id=0 and p.virtuemart_product_id='.$virtuemart_product_ids[0].' and
p.virtuemart_product_id=f.virtuemart_product_id and c.field_type=\'A\' and c.virtuemart_custom_id=f.virtuemart_custom_id';
$jobDb->setQuery($sqlStmt);
$jobResult = $jobDb->loadResult();
if ($jobResult != null) {
$errorMsg = "You must choose " . $jobResult;
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
echo json_encode($this->json);
jExit();
}
}
-----------------------------------------------------
Can someone from the virtuemart team please respond on this topic? Why can't we have such a basic feature without editing the source code? Or am I missing something fundamental here?
Alan, you use K2, ask them.
Quote from: spyderwebdesign on November 19, 2012, 01:06:08 AM
In 2.0.14 you can not longer add the parent, however the first item in the drop down box is your first child so it appears to the customer that they can't order the first child variant. The first item in the drop down box should say something similar to Select Your Variant.
Then you must check also the option "display parent as option" but configurate it as not orderable. This will be enhanced vm2.2. Exactly with a empty value "select your variant" we work on this.
2.2? It would be great to have it in 2.1 :'(
2.2 will be the first stable release of 2.1 series. Atm will be released vm2.0.16
:-\ Thought that 2.1 was going to be stable enough for production.
@DaggaTora
For that reason the 2.0.16 was released, the next release will be 2.2
@bytelord
;D I have a mess in the head with so many versions.
Now I see the Light!
Hi all,
All of you are doing great work here and thanks for all your help.
After reading this post I'm totally confused though :-\
In summary; is there a way to make a custom field (cart variant) as "required" that the customer MUST make the choice and to display "please choose" or similar as a first option in 2.0.18a version?
Thanks in advance.
Quote from: syntalk on March 08, 2013, 10:42:42 AM
Hi all,
All of you are doing great work here and thanks for all your help.
After reading this post I'm totally confused though :-\
In summary; is there a way to make a custom field (cart variant) as "required" that the customer MUST make the choice and to display "please choose" or similar as a first option in 2.0.18a version?
Thanks in advance.
I am looking for this solution too. To prevent customers from accidentally choosing the wrong drop-down value.
I had it working in a previous version, but in one of the new updates the hack stopped working.
I wound up just creating a child named 'please select' with no price, and set it so that it was the first child in the dropdown, not very elegant but it works
If that works that's great! does not work in Joomla! 2.5.6 VM 2.0.20b
What version are you using dsrpmedia. If you set a child named 'please select' with no price- it still lets you add that to cart ???
Any update on how to get round this issue?
Using Joomla! 2.5.6 VM 2.0.20b
hmmm I`m using joomla 2.5.9, VM 20.20b
the product 'please select' is not orderable - I don `t think I did anything to the code see
http://spectrum.rejuvasolutions.co/wellness/immunity/nasal-sinus-pray-detail
Thanks dsrpmedia. It does work. :)
I had template override.
can someone clarify the final solution on this issue?
Quote from: spyderwebdesign on November 19, 2012, 01:06:08 AM
In 2.0.14 you can not longer add the parent, however the first item in the drop down box is your first child so it appears to the customer that they can't order the first child variant. The first item in the drop down box should say something similar to Select Your Variant.
This one worked for me but I changed it so if it is selected after another selection is made it doesn't boot me out to the home page.
array_unshift($options, array('value' => '#', 'text' => 'Please select an option'));
There seems to be a lot of confusion - for many reasons. One reason is that some people are using a "Parent/Child" situation and creating resolutions. Those of us who "cannot" use that method are still using an independent product with "Custom Fields" due to the way the clients' products need to be tracked with the SKU "and" inventory.
Hence, there is no method for mandating a customer select something. At least, there has been nothing posted that actually works in the latest J2.5.17 and VM2.0.26d
I've tried many of the solutions, even some hacks. But nothing works - at least nothing I've tried to follow.
I don't want and cannot have my products a child of something. Each product needs to be independent.
And the "hacks" that I've read will be overwritten with any updates - they are not written as overrides. Those that had it working in previous versions, I'm sure, have found that the solutions no longer work...from what I've come across.
Here it is, January 2014, and this simple issue of making a selection "required" eludes VM2.0.26d
Let me ask the developers. What will it take to have the following issues resolved:
selection required to "any" list of custom fields
strikethrough "easily" assigned to the original price
tax per total in cart by US city (AlvaTax is NOT an option)
"Select a shipping method" AND "Select a payment method" hidden when there is ONLY 1 option offered
Will it take money? Time? Expertise?
Those same 4 issues have been now 2 years that I've watched the forums with no resolve.
I don't know how to word this message without it sounding like a complaint. But I truly am asking, what "will" it take for these resolves? Is it because they are only issues in the US?
Hello,
I know I am adding to an old topic but I cant find anything recent that comes close.
I have the same problem where in the dropdown I want "Please select" or something similar as the first option. Instead I see the description for the parent, and when I click, that is then added to the cart which I really don't want. Only child products should be ok to add to the cart.
Can anyone help with this please. I'm a Joomla and VM novice and I have spent hours trying to fix this. I'm using the Multi Variant Custom Field type.
VM 3.0.8
Joomla 3.4.1
David
All of the above problems are solved.
When you use the multivivariant just select for your parent in the matrix for one selection "none", done. Download the fullpackage and install the sampeldata
Hello,
I have uploaded the sample data into a staging environment so I can check product setup.
I am still having a problem though with Parent and child setup. When I view categories or do a search the search results show both parent and child - that isnt what I would expect to happen. I have checked the sample data and been through the configuration and matched the setup of the multi-variant custom field exactly but I still see the parent and the child products.
I would appreciate any help I have been trying to fix this for weeks.
Thanks
David
Hello,
I've found a workaround for this purely by chance.
I noticed that when I upload products with a parent and child relationship from a csv file I get exactly what I needed, so I deleted the incorrect products then just replaced them from a csv file.
No idea why this works given all other things are the same (all setup such as custom fields),but that's how I will be setting them up in future.
David
Quote from: Milbo on June 04, 2015, 09:30:41 AM
All of the above problems are solved.
When you use the multivivariant just select for your parent in the matrix for one selection "none", done. Download the fullpackage and install the sampeldata
Not quite Milbo - if you already have custom fields setup of a different type to multivariant, e.g. string and assigned values to products then there is still no out-of-the-box solution for this without changing the custom field setup, which is not a viable option if the site is already mostly built.
I don't understand why when all that is needed is a simple Required checkbox for checkout, which is configured in the Custom Field edit.
What am I missing here?
Bumpring this. Is there any news on the issue, new existing solution or upcoming?
Thank you!
I recenty used the services of my template developer to implement a custom solution that makes a cart string custom field 'required'.
See it in action here https://www.trendco.co.uk/shop/rae (https://www.trendco.co.uk/shop/rae)
This https://shop.st42.fr/en/products/shortcodes.htm implement mandatory fields without any hacks or template changes.
See http://pro.st42.fr/en/shortcodes/test-product-no4-in-engb.html for eg.
"Rating: 5 based on 1 rating" - This must be good ;)
Could actually be the solution, plus some extras, thank you!
EDIT: It actually solved my problem. But mine was not about variants (OP), only about custom field options.
Normally you would add a custom field type 'Generic child variant' to the parent product. Afterwards you can select the option 'Parent orderable' Yes/No in the 'Product Edit' view > 'Custom Fields' tab.