0

I want to use a custom quote validation doing the same like the validateMinimumAmount() method, just for some volumetric weight calculations. I already wrote the related helper methods, one of it is called isCheckoutDisabled and returns 1 or 0(in case of to low volume).

By calling this method I am disabling the "Proceed to checkout" button in checkout/cart. The next goal would be, to redirect from the mageplaza onestepcheckout if this is called bypassing the cart (f.e. by clicking "Proceed to checkout" button within the minicart or calling the URL directly)

I am asking myself what would be the best way to achive this goal

  • Writing a plugin for the Index controllers Execute() method
  • Writing a plugin that extends the validateMinimumAmount() method
  • Extending the quote with a custom validation method
  • Creating an extension attribute for quotes

I already tested some stuff without success:

I added a hardcoded redirect to the Index controllers execute() method. This doesn't work cause even if the value is changed, the redirect persists (within the cache)

 $this->_volumeWeightHelper = $this->_objectManager->get(\PackageName\ModuleName\Helper\Disable::class);

    if($this->_volumeWeightHelper->isDisabled() == 1){
        return $this->resultRedirectFactory->create()->setPath('checkout/cart');
    }

So for now I have to rethink the architecture and any hints would be nice!

Cheers, Jan

0

finaly I realised none of the things in my list. I created a custom observer, for the predispatch of the onestepcheckouts index action.

Before I modified the varnish.vcl to return pass on the onestepcheckout route like

  # Bypass shopping cart, checkout and search requests
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch" || req.url ~ "/onestepcheckout") {
    return (pass);
}

Even in this case, the redirect got cached localy so it's elemantary to redirect calling clearHeaders (I did fiddle to long, so hopefully this is helpful for somebody stumbling upon)

 $action = $observer->getEvent()->getControllerAction();
 $response = $action->getResponse();
 $response->clearHeaders()->setNoCacheHeaders();

 if($isDisabled == 1)
    $this->redirect->redirect($response, 'checkout/cart');

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.