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>
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))) {
...
}
not sure i understand...would it be a matter of adding similar code to one file (product display) or would it be more complicated ?
$array2 = array(218,219);
if(count(array_intersect($array2, $this->product->categories))) {
...
}
untested