What's new

PHP PAHELP LNG

iamjefjef23

Elite
Joined
May 20, 2016
Posts
4,583
Reaction
2,980
if('<?= $available > 0 ?>' == 1){
start_loader()
$.ajax({
url:base_url+"classes/Master.php?f=save_to_cart",
method:'POST',
data:{product_id: '<?= isset($id) ? $id : "" ?>',quantity:1},
dataType:'json',
error:err=>{
console.error(err)
alert_toast("An error occured","error")
end_loader();
},
success:function(resp){
if(resp.status =='success'){
update_cart_count(resp.cart_count);
alert_toast("Product has been added to cart.",'success')
}else if(!!resp.msg){
alert_toast(resp.msg,'error')

}else{
alert_toast("An error occured","error")
}
end_loader();
}
})
}

anong idadag ko mga idol para pag 0 yung $available is mag aalert sya na "No Stock Available"
 

L-Prime

Elite
di mo po ba siya pwedeng gawan nalang ng condition directly sa php code like:
PHP:
<?php
$available = 1;

if($available <= 0){
?>
// Javascript code here ganon
    
<?php } else { ?>
// ibang condition dito
?>
 
Top