What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi all, I added a CartPreCheck plugin to check for the availability of a product that I get by reque
Hi all,
I added a CartPreCheck plugin to check for the availability of a product that I get by requesting the stock of the product from a NAVConnect. I managed to get an error message when the check for availability fails. But the product is still added to the cart. I debugged through AvailabilityCartConnector/Business/Cart/CheckCartAvailability.php which determines isSellable but it is unclear to me where the product is actually excluded from being added to the cart. Maybe someone can help me where this takes place?
Comments
-
Hi David! Are you talking about
\Spryker\Zed\CartExtension\Dependency\Plugin\CartPreCheckPluginInterface
this plugin stack?0 -
Yes exactly
0 -
Specification says:
Should return CartPreCheckResponseTransfer where error messages set and flag that check failed.
0 -
Have you set
->setIsSuccess(false)
?0 -
Yes I’m checking the condition for the product being available, if it isn’t available I set success to false and add the message. It looks something like this:
$cartPreCheckResponseTransfer->setIsSuccess(false); $errorMessage = (new MessageTransfer()) ->setValue(static::CART_PRE_CHECK_NAVCONNECT_NOT_AVAILABLE_TRANSLATION_KEY) ->setParameters(['%sku%' => $itemTransfer->getSku()]); $cartPreCheckResponseTransfer->addMessage($errorMessage);
0 -
The message appears when the condition is met but the element still appears in the cart and im unsure where the decision is made if it is added to the cart or not
0 -
vendor/spryker/spryker/Bundles/Cart/src/Spryker/Zed/Cart/Business/Model/Operation.php:206
0 -
Check this. Maybe it will help
0 -
With this particular plugin stack I had the experience that plugins included later can override the negative response of the previous plugin. Please check this is not happening in you case
0 -
Thanks for the advice, I’ll give both of those suggestions a try and get back to you 👍
0 -
Hi, you have maybe to implement the
TerminationAwareCartPreCheckPluginInterface
and implements the methodpublic function terminateOnFailure()
with return true.0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 75 Spryker News
- 924 Developer Corner
- 783 Spryker Development
- 88 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 25 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random