0

if a customer tries to add to cart any product then he redirects to login/signup page. He login then -> redirect to after adding its product into cart to checkout.

I have used Loginpost after plugin there I got the referer which I need to convert it to URL and then change its one param (form_key) and redirect to the destination URL.

$redirectUrl = $this->_redirect->getRedirectUrl();
$referer = $this->_request->getParam('referer');
if($referer){
    $updated_form_key = $this->_formKey->getFormKey();
    $redirectUrl  = base64_decode($referer);            
    // here i get
    // $redirectUrl 'www.example.com/checkout/cart/add/uenc/aHR0cDovL3d3dy5zdG0ybG9jYWwuY29tL3ByaWNpbmc%2C/product/101065/form_key/h3QPYavelKlbrkni/'
    // Need to update
    // $redirectUrl 'www.example.com/checkout/cart/add/uenc/aHR0cDovL3d3dy5zdG0ybG9jYWwuY29tL3ByaWNpbmc%2C/product/101065/form_key/$updated_form_key/'
    // Get from key params from $redirectUrl
    // Update it with $updated_form_key
    // Create the url with updated_form_key
    // updated $redirectUrl 
}
if($redirectUrl){
    $this->_responseFactory->create()->setRedirect($redirectUrl)->sendResponse();
    die();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.