Author Topic: No add to cart showing on browse  (Read 40731 times)

mav

  • Beginner
  • *
  • Posts: 2
Re: No add to cart showing on browse
« Reply #45 on: November 28, 2012, 13:20:44 pm »
Dear Virtuemart users.

We also encountered the problem with Virtuemart 1.1.5 not displaying add to cart button on products with attributes.
Solved the problem by editing /administrator/components/com_virtuemart/html/shop.browse.php
change
Code: [Select]
        // Add-to-Cart Button
        if (USE_AS_CATALOGUE != '1' && $product_price != ""
            && !stristr( $product_price, $VM_LANG->_('PHPSHOP_PRODUCT_CALL') )
            && !ps_product::product_has_attributes( $db_browse->f('product_id'), true )
            && $tpl->get_cfg( 'showAddtocartButtonOnProductList' ) ) {

to

Code: [Select]
        // Add-to-Cart Button
        if (USE_AS_CATALOGUE != '1' && $product_price != ""
            && !stristr( $product_price, $VM_LANG->_('PHPSHOP_PRODUCT_CALL') )
            /*&& !ps_product::product_has_attributes( $db_browse->f('product_id'), true )*/
            && $tpl->get_cfg( 'showAddtocartButtonOnProductList' ) ) {

also change the following code later in the same file:
Code: [Select]
$products[$i]['form_addtocart'] = $tpl->fetch( 'browse/includes/addtocart_form.tpl.php' );

to:
Code: [Select]
            /*$products[$i]['form_addtocart'] = $tpl->fetch( 'browse/includes/addtocart_form.tpl.php' );*/

            $tpl->set( 'product_parent_id', $product_parent_id );
            $tpl->set( 'product_price', $product_price );
            $tpl->set( 'category_id', $category_id );
            $tpl->set( 'manufacturer_id', $manufacturer_id );
            $products[$i]['form_addtocart'] = $tpl->fetch( 'product_details/includes/addtocart_form.tpl.php' );

Also notice adding $product_parent_id  variable, because when you don't do so, PHP will pop up an error:
Code: [Select]
Notice: Undefined variable: product_parent_id in /components/com_virtuemart/themes/vmtheme155/templates/product_details/includes/addtocart_form.tpl.php on line 10

Hope this helps!