e1commerce.com
Ask a question
  • New questions
  • With the answers
  • Unanswered
  1. Home
  2. javascript - Tap to copy discount code is not working in cart drawer Shopify

735 votes
0 answers

javascript - Tap to copy discount code is not working in cart drawer Shopify

Solution:

i have solved this problem using java script. here is the code :-

function myFunction() 
      {
        var copyText = document.getElementById("myInput");
        copyText.select();
        copyText.setSelectionRange(0, 99999);
        navigator.clipboard.writeText(copyText.value);
            $(".tooltiptext").show();  
             setTimeout(function() {
                    $('.tooltiptext').fadeOut('fast');
                }, 200);
      }
 .copy_coupon{position:relative;}
                            .tooltiptext{display: none;
                            position: absolute;
                            background: rgb(0 0 0 / 61%);
                            color: rgb(255, 255, 255);
                            top: -25px;
                            padding: 2px 12px;
                            border-radius: 5px}
<div class="coupon_container">
       <div class="left_text">
            <strong>FLAT 50% OFF ON FIRST ORDER</strong>
            <small>*Applicable on single units.</small>
          </div>                     
          <button class="coupon_tab" onclick="myFunction()">
            <span class="copy_coupon" > 
                 <small class="tooltiptext">Copied</small>
                 <small>Tap Here to Copy</small>
                  <strong>FIRST50</strong>
            </span>
          </button>  
</div> 

<input type="text" value="FIRST50" id="myInput"  style="width:auto;" >

Undefined asked
2022-12-22


Source

Didn't find the answer?

Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Similar questions

Find the answer in similar questions on our website.

71 javascript - Tap to copy discount code is not working in cart drawer Shopify
300 Shopify Scripts: Rejected discount is not considered
626 javascript - add class on scroll not working in Shopify enviroment
161 shopify - Shipping discount based on cart weight
442 How to add Discount at cart page in shopify
366 javascript - Cart toast notification - Shopify Hydrogen
726 javascript - Shopify - Facing issue when creating customer using shopify api
627 visual studio code - VSCode not commenting css.liquid lines correctly
174 Shopify Admin REST API Webhook Is Not Calling Another Server URL
755 javascript - Shopify API in node.js/React. How to read and write API in Shopify App?

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.







Latest questions:

830 Triggering Zapier on new Shopify order containing a specific product

902 javascript - Swiper js - How can i change the background color of the selected slide

924 Shopify Webhooks not redirect into Laravel Route

552 How to enable / disable my app that is being managed from theme customization section shopify

337 Shopify List Blog Tags



© 2021

E-mail: infot@e1commerce.com