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

Remove add to cart button for some products

Started by ukfish1, July 12, 2012, 15:11:44 PM

Previous topic - Next topic

ukfish1

Hi

Is it possible to remove the "add to cart" button for some products only? One of the products we sell cannot be bought directly online. Clients need to call us or email us before we take the order manually.

One possible way round is to set the stock level for this item to zero and then in the general config to select "Displays 'Notify Me' instead of 'Add To Cart' button" against the action to take when an item is out of stock. Is it then possible to remove the "notify me" functionality and button completely (as we are not using stock levels anyway).

cheers

Paul

ivus

#1

Hi ukfish1,

You sure can. There are however a few steps you need to take to make it all work.

Firstly you need to setup a new CUSTOM FIELD with the following options

       
  • Custom Field Type :  Integer
  • Title : PhoneOrderOnly
  • Published : Yes
  • Parent : 0
  • Cart Attribute : NO
  • Description : NULL
  • Default : NULL
  • Tooltip : NULL
  • Layout position : NULL
  • Admin only : NO
  • Is a list? : NO
  • Hidden : YES
Save it and then take note of it's ID (/administrator/index.php?option=com_virtuemart&view=custom&task=edit&virtuemart_custom_id[]=26)

Then in your product detail page find the add to cart block and insert this code:




            $testphoneorder = array();
            foreach ($this->product->customfieldsSorted['normal'] as $phoneorder) :
                $testphoneorder[] = $phoneorder->virtuemart_custom_id;
            endforeach;
           
            if ( ! in_array( 26, $testphoneorder) ) : // <-- insert your ID in place of the 26
           
            // Add To Cart Button
            if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {
               echo $this->loadTemplate('addtocart');
            };
            // Add To Cart Button END
           
            else :


                echo JText::_('COM_VIRTUEMART_CART_NOTIFY');


            endif;



See how you go with that.