News:

Looking for documentation? Take a look on our wiki

Main Menu

"Generic Child Variant" - Prevent adding Parent to Shopping cart

Started by mulcamd, March 27, 2012, 19:43:35 PM

Previous topic - Next topic

patrik60

As far as I know there is no sort option. Children are sorted in the order they were created.

dsrpmedia

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!

dsrpmedia

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

Bruce Morgan

I agree.  It is another basic usability feature that should not be ignored.  I could live without it but is sure makes life easier.

patrik60

@ 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?

doell-computer

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.  :(

jux

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

dsrpmedia

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

Childitem

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.

spyderwebdesign

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?

spyderwebdesign

#25
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
}

Parsimonious

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.

dsrpmedia

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.

dsrpmedia

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

Maxim Pishnyak

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!
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