You need to show the cart itself in the popup everytime product is added to c...

Contribution Date
Technology
Contribution Project
Contribution Details

You need to show the cart itself in the popup everytime product is added to cart?

+++ b/modules/dc_ajax_add_cart_popup/src/EventSubscriber/AjaxAddToCartPopupSubscriber.php @@ -0,0 +1,98 @@ + $view_builder = $this->entityTypeManager->getViewBuilder('commerce_product_variation'); + $product_variation = $view_builder->view($this->purchasedEntity, 'dc_ajax_add_to_cart_popup'); + $content = [ + '#theme' => 'dc_ajax_add_cart_popup', + '#product_variation' => $product_variation, + '#product_variation_entity' => $this->purchasedEntity, + '#cart_url' => Url::fromRoute('commerce_cart.page')->toString(), + ]; + $title = ''; + $options = ['width' => '700']; + $response->addCommand(new OpenModalDialogCommand($title, $content, $options)); + $event->setResponse($response);

You can take the idea from here.

You have to pass the cart block markup in the $content. You can check the existing module code. You will find the code to programmatically render the block. You have glue them together.

Contribution Author
Files count
0
Patches count
0