Hey Everyone,

I've done some googling around with respect to finding out how to change the text inside the "Add to Cart" button to "Buy Now".

I noticed that there's a module for drupal 6 and 7 but I couldn't find anything yet for Drupal 8. Are there any modules like this for drupal 8? And if not, how would I make this change?

I also wouldn't mind changing the color of the button.

Thanks.

-S. Bailey

Comments

VM’s picture

color of button or image utilized for the button = CSS

there aren't any modules for D8 that alter text as of yet, but I believe you can still change via settings.php (scroll to bottom).

sdotbailey’s picture

Thanks.

Any idea where I might find the correct settings.php file?

VM’s picture

what do you mean correct?

settings.php (there is only one) is located in your sites/default folder

sdotbailey’s picture

I seemed to have more than one. Regardless, I looked in the file you suggested and there's nothing at the bottom that contains the text "Add to Cart" that would indicate to me that I could modify this here.

I figure there has to be a file somewhere, the Drupal file structure that tells the computer to write the words "Add to Cart".

I just cant seem to figure what file it is or where it is.

VM’s picture

you should only ever have one settings.php file If you have more than one, I'd be digging into why.

You won't find already existing text there. you would need to override the text string there. There are examples in the commented text. Because the text you are wanting to change is hyperlinked, you will likely need to dig through the commerce files to determine what exactly is contained in the t() .

https://www.google.com/search?q=drupal+change+add+to+cart+text&oq=drupal...

the results above indicate the question has been asked several times in the past. Have you worked through those results?

sdotbailey’s picture

Yes many of them.

I also just came across this article however I don't know where to find the file that contains the "Add to cart" string.

I found a file uc_product.views.inc which included t('Add to cart') but I am uncertain if this would be the string to override.

Also correct me if wrong but none of those are for drupal 8. Even the article I have attached here is for seven and therefore the code at the bottom of the settings.php file is different.

When I right click on the button and choose inspect element, the "value=Add to Cart" I can change this in the browser. But where can I find the HTML file so I can just phycially change it?

VM’s picture

It's not in an HTML file. Drupal doesn't use HTML files. I don't guide anyone in their pursuits to hack core/contrib files. That's a recipe for disaster.

If you can't figure out how to test and change via settings.php, I suggest involving yourself in the stringoverrides issue queue or the string overrides avanced issue queue to aid in bringing a D8 version to fruition. I'd recommend string overrides advanced to those that are challenged by locating text strings in files.

edit:
Another option is to multilingual options. before modules such as stringoverrides, one would create a site specific translation. Though you aren't changing the actual language it still allowed the changing of text via an English to English translation. Note, I haven't tried to do this in D8. The locale.module is not included in D8 which is what was used D7 and previous. locale.module has been replaced with specific translation modules.

sdotbailey’s picture

What is the equivalent code of

# $conf['locale_custom_strings_en'][''] = array(
#   'forum'      => 'Discussion board',
#   '@count min' => '@count minutes',
# );
 

from drupal 7 in drupal 8? Do you know?

Think I may have found. It's not as close to the bottom of the file as I expected. Also, it was in "comments" which I was't looking at, at first. Thank you for your help.

Final Edit:
Also, for anyone else out there who is using Drupal 8 and looking to do this, the exact code snippet you are looking for is...

$settings['locale_custom_strings_en'][''] = array(
   'forum'      => 'Discussion board',
   '@count min' => '@count minutes',
   'Add to cart' => 'Buy Now',
 );