I have a few if conditions in the following PHP.
I can't enable the Javascript section which needs to hide the class when the cart "quantity" is more than the balance.
jimport( 'joomla.user.helper' );
$user = JFactory::getUser();
$groups = $user->get('groups');
if(in_array(15, $groups)) {
$carts= VirtueMartCart::getCart();
foreach($carts->cartProductsData as $cartItem)
{
if($cartItem['virtuemart_product_id'] == $product->virtuemart_product_id){
echo "<br /> ".$cartItem['quantity']." already added to cart";
}
if($cartItem['quantity'] == $max_balance) <?php { ?>
<script type="text/javascript">
$('.addtocart-button').attr('disabled', 'disabled');
</script>
<?php } ?>
} }
I don't know how to close the first php instance. It refuses.
if($cartItem['quantity'] == $max_balance) <?php { ?>You're already inside PHP tags but you've opened them again. You cannot open php tags inside php.<?php } ?>, then some curly braces after (outside of the PHP-block since you just closed it) and then yet another?>.<?phpfromif($cartItem['quantity'] == $max_balance) <?php { ?>and remove?>from</script> <?php } ?><scriptand open it again right after the js-block.