Buy me a coffee

Replace Add to Cart with Custom Button

Suppose you have these products, you need to change the Add to Cart to Custom Button with a custom URL.

Replace Add To Cart With Custom Button 04 Min

#1. First, you need to find the URLs of the 4 products.
In my example, we will have:

  • /shop/p/diamond/cut/curb/chain/gold/24inch/12mm
  • /shop/p/diamond-cut-curb-chain-silver-necklace-24inch-12nn-stainless-steel
  • /shop/p/diamond-cut-curb-chain-gold-bracelet-12mm-9inch
  • /shop/p/diamond-cut-curb-chain-silver-bracelet-12mm-9inch

#2. Use this code to Code Injection – Footer.

Replace Text/URL with your desired text/URL.

<a href="https://google.com" class="product-01 custom-button">Learn More</a>
<a href="https://amazon.com" class="product-02 custom-button">Learn More</a>
<a href="https://instagram.com" class="product-03 custom-button">Learn More</a>
<a href="https://ebay.com" class="product-04 custom-button">Learn More</a>

Replace Add To Cart With Custom Button 01 Min

#3. Use this code to Code Injection – Footer, under #2 code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  jQuery(document).ready(function($){
     $('.product-01').insertAfter('.grid-item-link[href="/shop/p/diamond/cut/curb/chain/gold/24inch/12mm"]');
    $('.product-02').insertAfter('.grid-item-link[href="/shop/p/diamond-cut-curb-chain-silver-necklace-24inch-12nn-stainless-steel"]');
      $('.product-03').insertAfter('.grid-item-link[href="/shop/p/diamond-cut-curb-chain-gold-bracelet-12mm-9inch"]');
      $('.product-04').insertAfter('.grid-item-link[href="/shop/p/diamond-cut-curb-chain-silver-bracelet-12mm-9inch"]');
})
</script>

Replace Add To Cart With Custom Button 02 Min

You will have this

Replace Add To Cart With Custom Button 05 Min

#3. Use this code to Custom CSS box

a.custom-button {
  display: none;
}
section.plp-grid-add-to-cart {
    display: none !important;
}
div.grid-item a.custom-button {
    text-align: center;
    background-color: var(--primaryButtonBackgroundColor);
    border: 2px solid #fff;
    padding-top: 15px;
    padding-bottom: 15px;
    margin-top: 10px;
    display: inline-block !important
}

Replace Add To Cart With Custom Button 03 Min

Replace Add To Cart With Custom Button 03 Min

You will have

Replace Add To Cart With Custom Button 06 Min