Jump to content

How to use the ShoppingCartValidateProductUpdate hook


yomyyo

Recommended Posts

I am trying to validate custom fields for my item, but whether or not the custom field is valid, I will be thrown an error. If it's an invalid field it'll say  "Please correct the following errors before continuing: This email address is already in use." However if the user gives a valid field, it will just give "Please correct the following errors before continuing:" without anything after.

I have the hook set up as so

function checkUser($vars){
    $postData = array(
        'data' => array(
            'email' => $vars['customfield'][6],
        )
    );
    
    $ch = curl_init();

    if($ch == false){
        throw new Exception('failed to init');
    }

    curl_setopt_array($ch, array(
        CURLOPT_URL => myUrlGoesHere,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HEADER => 0,
        CURLOPT_POSTFIELDS => http_build_query($postData),
    ));
    
    //Save the result from the request
    $output = curl_exec($ch);
    $res = json_decode($output);

    curl_close($ch);
    console_log($res);
    if($res){
        $message = "This email address is already in use.";
        return $message;
    }
}

Is there a value I need to return using this hook.

Thank you!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated