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

Template over-ride to Disable add to cart for a category

Started by phil147, September 25, 2017, 12:24:26 PM

Previous topic - Next topic

phil147

Using VM 3.2.4

I have an over-ride that was put in my product display php file. The over-ride makes add to cart buttton in category view dis-appear and in product detail page it makes add to cart button disabled and grey back-ground. It used for a medicine product category that displays a button to a form thats to be completed first etc...

I have another product category that we're no longer allowed sell online, so I need to remove add to cart option from category view and disable in product detail view and grey the button.

Anyone know how to do this? Have attached product display file (changed to txt format from php)

snippet of code from file below...where it check the category id '218' which is the medicine category

<?php //GJC
   if(in_array('218',$this->product->categories)){
      $product_name = $this->product->product_name;
   ?>
   <script type="text/javascript">

         jQuery(document).ready(function($) {
            $('.addtocart-button').prop('disabled', true);
            $('.addtocart-button').addClass('disabled');
            $('#ff_elem20').val('<?php echo $product_name; ?>');
            $('a.declaration').on('click', function () {
               $('.decform').hide();
               $('.gjc_overlay').show();
               $('.decform').show();
               //$("html, body").css("overflow", "hidden");
            });
            $('.close-content').on('click', function () {

               $('.decform, .gjc_overlay').hide();
               //$("html, body").css("overflow", "visible");
            });
         });

</script>


GJC Web Design

make the 218 an array of the filtered cats

then use array_intersect
http://php.net/manual/en/function.array-intersect.php

if(count(array_intersect($array2,  $array))) {
   ...
}


GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

phil147

not sure i understand...would it be a matter of adding similar code to one file (product display) or would it be more complicated ?

GJC Web Design

$array2 = array(218,219);

if(count(array_intersect($array2,  $this->product->categories))) {
   ...
}

untested
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation