Closed (duplicate)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Cart
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Aug 2017 at 12:38 UTC
Updated:
1 Sep 2017 at 13:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sorabh.v6Patch uploaded.
Comment #3
joshmillerNeeds dependency injection.
Comment #4
sorabh.v6Comment #5
heddnI'd like to see the position of the drupal_set_message move before,
$this->cartManager->addOrderItem($cart, $order_item, $form_state->get(['settings', 'combine']));. This way I can alter the messages that are set in an event subscriber. And then we don't even need the message alter at all. Just retrieve the messages and alter them as you see fit in an event subscriber.As an example of what you can do with that simple movement: here's https://gist.github.com/heddn/74386a203797894a84c67901cf4951d0
Comment #6
sorabh.v6Replaced $purchased_entity with $order_item, because developer can extract purchased_entity from $order_item but what if he needs order_item too.
Also, moduleHandler was already injected into some parent class. So, just used that here in the updated patch. Please review.
Comment #7
drugan commentedWorks as expected.
Comment #8
heddnAt the very least, can we move the dsm before the addtocart call so the option exists to do this either way?
Comment #9
drugan commentedComment #10
sorabh.v6@heddn Moved dsm before addToCart and created event for add to cart message. Please review the attached patch and interdiff file.
Comment #11
sorabh.v6Comment #12
heddn@drugan thanks for the link to #2834416: Move the add to cart message to an event subscriber to allow it to be replaced/removed. I think should be closed duplicate.