cancel
Showing results for 
Search instead for 
Did you mean: 

Unapproved products in cart

0 Kudos

We are using a 6.3 version b2c. When a user adds products to cnd they are moved to unapproved status later on, when the user tries to access the cnd try to checkout, it is throwing a 404 error.

For this I made some changes by removing the unapproved products from the cart data wherever we are accessing the cartdata object. But while placing the order in placeorder method of SummaryCheckoutStepController.java, it is taking me back to the cart page and saying the product is removed and when I try to place order this time, it throws a null pointer.

Which is a better way to handle this scenario? How can I remove the unapproved products from cart when the user comes to the cart page and then after the order can be placed successfully?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

use this at the beginning of the cart method

 if (validateCart(redirectModel))
         {
             return redirectToCartPage();
         }

 protected boolean validateCart(final RedirectAttributes redirectModel)
     {
         //Validate the cart
         List<CartModificationData> modifications = new ArrayList<>();
         try
         {
             modifications = cartFacade.validateCartData();
         }
         catch (final CommerceCartModificationException e)
         {
             LOG.error("Failed to validate cart", e);
         }
         if (!modifications.isEmpty())
         {
             redirectModel.addFlashAttribute("validationData", modifications);
 
             // Invalid cart. Bounce back to the cart page.
             return true;
         }
         return false;
     }




0 Kudos

I will try that now. just a query, don't we have this code already in OOTB. The code looks familiar.

0 Kudos

should be ootb

put the method at the top of the cart

 if (validateCart(redirectModel))
          {
              return redirectToCartPage();
          }
0 Kudos

Now I am getting issues while checking out. During calculation of taxes it says it has more line numbers for taxes than the ones in the order. It throws me an exception.

Answers (0)