Home > Enterprise >  add an image right after the total in the checkout page @shopify
add an image right after the total in the checkout page @shopify

Time:09-28

I want to add an image right after the total price at the checkout page, look at the example: enter image description here

I tried to add the img directly in the checkout.liquid in this section: enter image description here

but that displays my image at the very bottom of the whole order-summary__section

update: I tried the suggested answer, but it didnt work enter image description here

CodePudding user response:

If you have access to the Checkout.liquid you can add this in with a javascript function just target .order-summary__section--total-lines and insert your image after that element.

You can't add it in as liquid because as you've seen the whole order summary content area is contained in the {{ content_for_order_summary }} tag

      (() => {
      
        'use strict';
            
          const selectors = {
            targetTotalLines : '.order-summary__section--total-lines',
          };

          const injectImage = function() {
            let htmlContentToInject = `<img src="https://cdn.shopify.com/s/files/1/0177/9856/666/files/ICON.png?v=1663076456" />`;
            document.querySelector(selectors.targetTotalLines).insertAdjacentHTML('afterend', htmlContentToInject);
          };

          document.addEventListener('DOMContentLoaded', (e) => {
            injectImage();
          });
      
      })()
    </script> ```


  [1]: https://i.stack.imgur.com/1qcNA.png
  • Related