Page 1 of 1

Child Product handling on VM3.0.10

PostPosted: Fri Nov 06, 2015 7:19 pm
by admin
Hello friends, we would like to share a fix for child product stock handling on VM3.

Our configuration:

Custom field: Generic child variant (cart input yes / cart attribute yes, position addtocart)
Products:

Parent product: has price 100 + has a category + has NO STOCK + has custom field "Generic Child Variant Associated"
for this parent, we created two child products:

Product 200 In Stock: Stock 100pcs, has price, no category selected
Product 300 Out of stock: Stock 0pcs, has price set, no category selected

VM config:
- display "notify me for products out of stock"

When you land at Parent product, the "notify me" is correctly displayed, when you select the product "In Stock" the add to cart is properly displayed

BUT

when you select product "Out of stock" you still see the add-to-cart on default VM template.


FIX (this is done on pre-release vm3.0.12 but previous versions are most probably affected the same way):

\components\com_virtuemart\sublayouts\customfield.php

find this (here on line 305 to 315:
Code: Select all

if($customfield->parentOrderable==0){
                  if($product->virtuemart_product_id==$customfield->virtuemart_product_id){
                     $product->orderable = false;
                  } else {
                     $product->product_in_stock = $parentStock;
                  }

               } else {


               }



and replace with this:
Code: Select all
               if($customfield->parentOrderable==0){
                  
                  if($product->virtuemart_product_id==$customfield->virtuemart_product_id){
                     $product->orderable = false;
                  }
               } else {
                     $product->product_in_stock = $parentStock;
                     
               
                     
               }



Image

expected result after the fix:
- parent product: Notify me link
- In Stock product: Add to cart displayed
- Out of Stock product: Notify me link

best regards, stan