javascript - Disable element in php if/else -
what trying disable/hide button if condition satisfied
below code woocommerce website.
php
foreach( wc()->cart->get_cart() $cart_item_key => $values ) { $_product = $values['data']; if( get_the_id() == $_product->id ) { //*disable button*// }} html
<button class="test">...</button>
try this
$btn='<button class="test" '.(get_the_id() == $_product->id ? "disabled" : "").">...</button>"; echo $btn;
Comments
Post a Comment