Post by sirko » Fri Jan 20, 2012 1:54 am

Hi guys, I need some assistance I want to change button text "Add to cart" on specific product i.e. products with price 0.00 to "Order" while rest of the products are normal
Example: "Add to cart" text become "Order" only for http://www.mysite.com/index.php?route=p ... uct_id=195
Thanks!

Newbie

Posts

Joined
Thu Oct 06, 2011 4:24 pm

Post by OpenCart Addons » Fri Jan 20, 2012 2:52 am

Hey,

In catalog / language / english (or your language) / english.php
Find:

Code: Select all

$_['button_cart']           = 'Add to Cart';
After Add:

Code: Select all

$_['button_order]           = 'Order';
In catalog / controller / product / product.php
Find:

Code: Select all

$this->data['button_cart'] = $this->language->get('button_cart');
Add After:

Code: Select all

$this->data['button_order'] = $this->language->get('button_order');
In catalog / view / theme / <your theme> / template / product / product.tpl
Find:

Code: Select all

&nbsp;<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a></div>
Replace With:

Code: Select all

<?php if ($price > 0) { ?>
&nbsp;<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a></div>
<?php } else { ?>
&nbsp;<a id="button-cart" class="button"><span><?php echo $button_order; ?></span></a></div>
<?php } ?>
Find:

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
Replace With:

Code: Select all

<?php if ($product['price'] > 0) { ?>
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
<?php } else { ?>
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_order; ?></span></a></div>
<?php } ?>
This will make any product with a price of $0.00 show "Order" instead of "Add To Cart".

You will have to perform similar modifications to the category files / modules / etc. in order for this to be universally on your site. This will only modify the product page.


Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by sirko » Fri Jan 20, 2012 4:29 am

Thank you Joel!
Everything went OK except messages from error log saying undefined variable button_order also I couldn't find what and where to change to make this global to my site.
Probably I'll gave up for now until full solution, I appreciate you help!
Thank again.
Todor

Newbie

Posts

Joined
Thu Oct 06, 2011 4:24 pm

Post by GoGo OpenCart » Fri Jan 20, 2012 4:36 am

Take a look at this module:

http://www.opencart.com/index.php?route ... on_id=4139

I can also do a custom modifications to the module, according to your needs ;)

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by jatin_p » Sun Aug 26, 2012 11:01 pm

OpenCart Addons wrote:Hey,

In catalog / language / english (or your language) / english.php
Find:

Code: Select all

$_['button_cart']           = 'Add to Cart';
After Add:

Code: Select all

$_['button_order]           = 'Order';
In catalog / controller / product / product.php
Find:

Code: Select all

$this->data['button_cart'] = $this->language->get('button_cart');
Add After:

Code: Select all

$this->data['button_order'] = $this->language->get('button_order');
In catalog / view / theme / <your theme> / template / product / product.tpl
Find:

Code: Select all

&nbsp;<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a></div>
Replace With:

Code: Select all

<?php if ($price > 0) { ?>
&nbsp;<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a></div>
<?php } else { ?>
&nbsp;<a id="button-cart" class="button"><span><?php echo $button_order; ?></span></a></div>
<?php } ?>
Find:

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
Replace With:

Code: Select all

<?php if ($product['price'] > 0) { ?>
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
<?php } else { ?>
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_order; ?></span></a></div>
<?php } ?>
This will make any product with a price of $0.00 show "Order" instead of "Add To Cart".

You will have to perform similar modifications to the category files / modules / etc. in order for this to be universally on your site. This will only modify the product page.


Joel.


thanks a ton!!!
certainly it helped a lot. but not i'm stuck with a problem,
what i want is:

when someone clicks on "order" button (i.e. when a price is 0), I want to redirect it to an external link.
and when they click on "add to cart" (i.e. when price is > 0), it should add the item to cart as normal. (as it does right now)

your help will be highly appreciated!!!

Newbie

Posts

Joined
Sun Aug 26, 2012 10:53 pm

Post by speziasoft » Mon Dec 14, 2015 3:50 pm

One of the ways to make your store more unique and interesting is to change some of the text strings that are common for all online stores. This is why in this article we will show you how to change the “Add to Cart” text to something different.

How?
Changing the button name is actually quite easy. You just have to change the language string for that phrase and you are good to go. I will show you how to do this step by step. In the following example we will change the “Add to Cart” string for the English language, but this way is applicable for all languages on your store. Lets go!

Access your store’s files.
Navigate to catalog/language/english/default.php.
Find the following string:
1
$_['button_cart'] = 'Add to Cart';
Replace it with:
1
$_['button_cart'] = 'Order This';

That’s it! 8)
In the example above, we are changing the phrase with “Get it!”, but you can change it to whatever you want it to be. By doing this change, you will modify the string globally and it will not matter what template you are using, as long as the button text is not hardcoded in it.

Opencart Expert speziasoft

Newbie

Posts

Joined
Mon Dec 14, 2015 3:42 pm

Post by speziasoft » Mon Dec 14, 2015 3:57 pm

One of the ways to make your store more unique and interesting is to change some of the text strings that are common for all online stores. This is why in this article we will show you how to change the “Add to Cart” text to something different.

How?
Changing the button name is actually quite easy. You just have to change the language string for that phrase and you are good to go. I will show you how to do this step by step. In the following example we will change the “Add to Cart” string for the English language, but this way is applicable for all languages on your store. Lets go!

Access your store’s files.
Navigate to catalog/language/english/default.php.
Find the following string:
1
$_['button_cart'] = 'Add to Cart';
Replace it with:
1
$_['button_cart'] = 'order this!';

That’s it!
In the example above, we are changing the phrase with “Get it!”, but you can change it to whatever you want it to be. By doing this change, you will modify the string globally and it will not matter what template you are using, as long as the button text is not hardcoded in it.

Newbie

Posts

Joined
Mon Dec 14, 2015 3:42 pm
Who is online

Users browsing this forum: No registered users and 42 guests