The current default template is rather poor. I propose adding two new items to this.
A checkout link and a quantity added to the cart.

I've created a patch to add both of these basic functions. The checkout url is pretty simple. The quantity ensures that it won't say '1 items'.

Comments

DerekCresswell created an issue. See original summary.

subhojit777’s picture

Status: Active » Needs work

Thank you. I have added some suggestions:

  1. +++ b/modules/dc_ajax_add_cart_popup/src/EventSubscriber/AjaxAddToCartPopupSubscriber.php
    @@ -31,6 +31,20 @@ class AjaxAddToCartPopupSubscriber implements EventSubscriberInterface {
    +   * @var float
    

    Use @var float|null

  2. +++ b/modules/dc_ajax_add_cart_popup/src/EventSubscriber/AjaxAddToCartPopupSubscriber.php
    @@ -68,6 +82,10 @@ class AjaxAddToCartPopupSubscriber implements EventSubscriberInterface {
    +      '#checkout_url' => Url::fromRoute('commerce_checkout.form',
    

    Update this, so that #checkout_url is added only if cart property is not null.

  3. +++ b/modules/dc_ajax_add_cart_popup/src/EventSubscriber/AjaxAddToCartPopupSubscriber.php
    @@ -68,6 +82,10 @@ class AjaxAddToCartPopupSubscriber implements EventSubscriberInterface {
    +      '#quantity_added' => $this->quantity,
    

    `#quantity_added` should be added only if `quantity` property is not null.

  4. +++ b/modules/dc_ajax_add_cart_popup/templates/dc-ajax-add-cart-popup.html.twig
    @@ -15,18 +15,30 @@
    +      {{ quantity_added }} {{ ' items added to your cart'|t }}
    

    Use {% trans %}{{ quantity_added }} items added to your cart{% endtrans %} for better translation support

subhojit777’s picture

+++ b/modules/dc_ajax_add_cart_popup/src/EventSubscriber/AjaxAddToCartPopupSubscriber.php
@@ -31,6 +31,20 @@ class AjaxAddToCartPopupSubscriber implements EventSubscriberInterface {
+   * @var \Drupal\commerce_order\Entity\OrderInterface

Use @var \Drupal\commerce_order\Entity\OrderInterface|null

derekcresswell’s picture

Status: Needs work » Needs review
StatusFileSize
new3.57 KB

Here you are

derekcresswell’s picture

Apologies, I must not be choosing the right test version.