Author Topic: "Generic Child Variant" - Prevent adding Parent to Shopping cart  (Read 29731 times)

patrik60

  • Guest
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #15 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.

dsrpmedia

  • Jr. Member
  • **
  • Posts: 328
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #16 on: April 13, 2012, 06:44:59 am »
Quote
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.

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

  • Jr. Member
  • **
  • Posts: 328
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #17 on: April 13, 2012, 06:48:04 am »
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

  • Full Member
  • ***
  • Posts: 672
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #18 on: April 13, 2012, 17:16:21 pm »
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

  • Guest
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #19 on: April 17, 2012, 18:46:54 pm »
@ 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

  • Beginner
  • *
  • Posts: 6
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #20 on: April 21, 2012, 16:06:43 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

  • Jr. Member
  • **
  • Posts: 77
  • VirtueMart Version: latest
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #21 on: May 04, 2012, 15:34:35 pm »
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

  • Jr. Member
  • **
  • Posts: 328
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #22 on: May 04, 2012, 21:14:25 pm »
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

  • Beginner
  • *
  • Posts: 3
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #23 on: May 22, 2012, 13:17:04 pm »
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

  • Jr. Member
  • **
  • Posts: 132
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #24 on: June 17, 2012, 05:06:51 am »
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

  • Jr. Member
  • **
  • Posts: 132
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #25 on: June 17, 2012, 05:28:14 am »
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

  • Beginner
  • *
  • Posts: 47
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #26 on: June 17, 2012, 17:14:48 pm »
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

  • Jr. Member
  • **
  • Posts: 328
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #27 on: June 17, 2012, 21:22:52 pm »
Quote
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.

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

  • Jr. Member
  • **
  • Posts: 328
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #28 on: June 17, 2012, 22:01:31 pm »
I made a small adjustment to the hack
Code: [Select]
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

  • Virtuemart 2 is quite bugfree now
  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2657
  • Virtuemart 2 is quite bugfree now
    • Virtuemart Ukraine division
Re: "Generic Child Variant" - Prevent adding Parent to Shopping cart
« Reply #29 on: June 29, 2012, 07:24:05 am »
I made a small adjustment to the hack
Code: [Select]
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!
Virtuemart 2 is quite bugfree now. You can support Community by voting for Project on the JED
http://extensions.joomla.org/extensions/e-commerce/shopping-cart/129/review
Join us in
https://www.facebook.com/virtuemart
https://twitter.com/virtuemart