In add to cart function can be placed discount, discounts are made via xxx-hashid. i figure out that problem is when user want cheat and type random xxx-123456 my system crash.
hashid is from Ivan Akimov.
is possible to achiev, when hashID (userID) doesnt exist function return code isnt valid but without crash ?
public function getIdByHash($hashid) {
$response = ['valid' => false];
if ($hashid){
$response['valid'] = true;
$hashid = explode("PMX-",$hashid)[1];
$hashids = new Hashids("",6);
return $hashids->decode($hashid)[0];
}
if ($hashid){
$response ['valid'] = false;
return $hashids = "PMX-"."dGRLrb";
}
}
Aucun commentaire:
Enregistrer un commentaire