News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

wrong setup or bugs ?

Started by ntougouchi, April 18, 2012, 00:43:50 AM

Previous topic - Next topic

ntougouchi

Hi,

I'm using VM2.0.4 on Joomla 2.5.4.

I want to setup VM for my products, but it dosen't work as I hoped.

I want to sell handbags (and more) with different "coatings".
I've created a parent product, named "Handbag", with description, dimension, price, 2 general categories...
I've created a custom field "coating", type "general children variant"
I've setup the parent "Handbag" with this new custom field.
I've created 3 children for my 3 "coatings", with stock, photos, and 1 special category.
I've created a category "coating", to allow shoppers to see all products with the same "coating" (collection).

I don't want to sell the parent product, but only children.
I wan't to manage stock for each children.

In five words, I wan't to do this :
http://linkfelho.online.fr/joomla+virtuemart/index.php?page=shop.product_details&flypage=shop.garden_flypage&product_id=2&category_id=3&manufacturer_id=0&option=com_virtuemart&Itemid=26


First question :
- Is it the good process to do what I want to do ?
I've tested "plugin custom fields", but the result was wrong..
There is no real documentation, and Google show only tutorials to VM1..

Second question :
- Why is the button "add to cart" available and "up and running" with the parent product ?
In VM1, tutorial explains the "add to cart" button shows an "alert box" to shopper for choosing variant, and don't add product in the cart...
In VM2, the parent product is added in the cart ...


Third question :
- Why does the parent product appear twice on the top of the dropdown field (with my children variants) ? it shouldn't appear. For information,
my parent product is linked to 2 categories. I suppose that's why it appears 2 times, but it shouldn't appear once !!
In VM1,  the first item of dropdown was "Please select...".
In VM2.. there is not this "necessary" first item.


So, Either I don't setup my shop correctly, Either there are bugs...

Regards

ntougouchi

So, I didn't know if an answer would came one day.. And it was urgent.
I consider it is a bug and not a wrong setup..

I apply some hacks found in this Forum.. with adaptations for my process..
For me, in VM2.0.4 :
- /administrator/components/com_virtuemart/models/customfields.php LINE 762, there is
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']);
}

I replaced by:

foreach($uncatChildren as $k => $child){
if(!empty($child['product_parent_id'])) { //  Ignore parent product in this dropdown
$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']);
}
}
//  Add a "title" on dropbox, without value :
if (sizeof($options) > 0) {
array_unshift($options, array('value'=>null,'text'=>"->"));
}




- /components/com_virtuemart/controllers/cart.php LINE 119, there is :

$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');

I add AFTER:

// Unable to put in the cart a parent product
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 = "Please Choose the coating for the product";
$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();   
    }
}