How to change the 'Buy Now' button text to 'Preorder Now' but not on all products?

Solved

How to change the 'Buy Now' button text to 'Preorder Now' but not on all products?

jitesh1
Tourist
9 0 9

How to change the 'Buy Now' button text to 'Preorder Now' but not on all products . I want the button text 'Preorder Now' only on some products?

Accepted Solutions (2)
devcoders
Shopify Partner
227 40 55

This is an accepted solution.

Hi @jitesh1 

- Go to Online Store -> Theme -> Edit code.
- Find the file layout/theme.liquid and paste the code below at the bottom of the file.

 

{% if product.handle == 'farm-fresh-himalayan-dark-baron-apples5kg' %}
  <style>
    .shopify-payment-button__button {
      position: relative;
      overflow: hidden;
      text-align: center;
      line-height:40px;
      color: transparent;
      border: none;
      padding: 10px 20px;
      font-size: 16px; 
      }
      .shopify-payment-button__button::after {
      content: 'Preorder Now'; 
      color: #ffffff; 
      font-size: 16px; 
      position: absolute;
      top: 43%;
      left: 50%;
      transform: translate(-50%, -50%);
      white-space: nowrap; 
      }
  </style>
{% endif %}


 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!

View solution in original post

devcoders
Shopify Partner
227 40 55

This is an accepted solution.

Hi @jitesh1 

If this doesn’t work, please inform me at email devcodersp

 

 

{% if product.metafields.global.button_text == 'preorder' %}
<style>
.shopify-payment-button__button {
position: relative;
overflow: hidden;
text-align: center;
line-height:40px;
color: transparent;
border: none;
padding: 10px 20px;
font-size: 16px;
}
.shopify-payment-button__button::after {
content: 'Preorder Now';
color: #ffffff;
font-size: 16px;
position: absolute;
top: 43%;
left: 50%;
transform: translate(-50%, -50%);
white-space: nowrap;
}
</style>
{% endif %}

 

 

 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!

View solution in original post

Replies 14 (14)

devcoders
Shopify Partner
227 40 55

Hi @jitesh1 
If you share your store URL and password with me, I will check and provide you with the solution.

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!
jitesh1
Tourist
9 0 9

Hello sir thanks for replying
store url - https://thehimalayanfarm.in/

devcoders
Shopify Partner
227 40 55

Hi @jitesh1 

- Go to Online Store -> Theme -> Edit code.
- Find the file assets/base.css and paste the code below at the bottom of the file.

 

.shopify-payment-button__button {
position: relative;
overflow: hidden;
text-align: center;
line-height:40px;
color: transparent;
border: none;
padding: 10px 20px;
font-size: 16px; 
}
.shopify-payment-button__button::after {
content: 'Preorder Now'; 
color: #ffffff; 
font-size: 16px; 
position: absolute;
top: 43%;
left: 50%;
transform: translate(-50%, -50%);
white-space: nowrap; 
}

 

devcoders_0-1722713098942.png

 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!
jitesh1
Tourist
9 0 9

but it will be change for all the products. i want to apply it for specific products only

devcoders
Shopify Partner
227 40 55

Hi @jitesh1 

Okay, please let me know which product you want to change the text for. Share the link to that product with me.

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!
devcoders
Shopify Partner
227 40 55

This is an accepted solution.

Hi @jitesh1 

- Go to Online Store -> Theme -> Edit code.
- Find the file layout/theme.liquid and paste the code below at the bottom of the file.

 

{% if product.handle == 'farm-fresh-himalayan-dark-baron-apples5kg' %}
  <style>
    .shopify-payment-button__button {
      position: relative;
      overflow: hidden;
      text-align: center;
      line-height:40px;
      color: transparent;
      border: none;
      padding: 10px 20px;
      font-size: 16px; 
      }
      .shopify-payment-button__button::after {
      content: 'Preorder Now'; 
      color: #ffffff; 
      font-size: 16px; 
      position: absolute;
      top: 43%;
      left: 50%;
      transform: translate(-50%, -50%);
      white-space: nowrap; 
      }
  </style>
{% endif %}


 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!
jitesh1
Tourist
9 0 9

Thank you, sir. It works. But do I have to manually add `product handle` again and again if I want to have more products in my store to preorder? Can't it be done with a GUI where we can select 'preorder' true or false, like in a metafield or something?

devcoders
Shopify Partner
227 40 55

Hi @jitesh1 
Yes, I can do this dynamically using metafields.

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!
jitesh1
Tourist
9 0 9

Can you please tell me how can i do that

devcoders
Shopify Partner
227 40 55

This is an accepted solution.

Hi @jitesh1 

If this doesn’t work, please inform me at email devcodersp

 

 

{% if product.metafields.global.button_text == 'preorder' %}
<style>
.shopify-payment-button__button {
position: relative;
overflow: hidden;
text-align: center;
line-height:40px;
color: transparent;
border: none;
padding: 10px 20px;
font-size: 16px;
}
.shopify-payment-button__button::after {
content: 'Preorder Now';
color: #ffffff;
font-size: 16px;
position: absolute;
top: 43%;
left: 50%;
transform: translate(-50%, -50%);
white-space: nowrap;
}
</style>
{% endif %}

 

 

 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!
jitesh1
Tourist
9 0 9

it works

thanks for the help

devcoders
Shopify Partner
227 40 55

Hi @jitesh1 

 

Great to hear that the issue has been resolved! If my assistance was helpful, please consider liking and accepting the solution. Feel free to reach out if you have any further questions.

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com.
If my assistance was helpful, please consider liking and accepting the solution. Thank you!

JayAdra
Shopify Partner
124 14 30

Just keep in mind, though the above solution with CSS might work, it's quite hacky, and doesn't give you much flexibility.

 

A cleaner solution would be to use similar liquid code in your theme file/s to render different text on the page, rather than overriding this with CSS.

 

And an even simpler/more flexible solution would be to use an app (especially if you're looking to offer actual preorders, and not just change the label of the button).