Skip to content
Advertisement

How to hide a link using php and css

I am trying to apply some css in my php for a test to see how to hide a button in my php file. It’s not happening at the moment and I am not sure why it is not removing the button.

HTML:

JavaScript

PHP

JavaScript

UPDATE

The above code is a test code to try and fix the main code below:

JavaScript

Advertisement

Answer

In your verify_all_products_in_cart function, you have several isues:

in_array needs 2 parameters, you’re only sending one

JavaScript

this is doing an assignment = not a check == / ===

JavaScript

$all_products is overused being set in 3 places

$shopping_cart_button is a poorly named and unessicary variable with a lot of duplicated code


You could re-write this function to something like the below which should work for your needs (assuming wc_get_products returns an array of ids, if not it may take a bit of modifying):

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement