How To Change The Add To Cart Button Text In WooCommerce

Add to cart is a very generic term that used on many stores around the world. However, at times, you want to change it to something else, “Buy now” for example. In this post, I’m going to show you how to do just that with a simple code in your functions.php theme file.

Using a plugin is much more easier. You can download this WooCommerce Add To Cart button customizer to adjust the text, the look and feel of the buttons on your stores.

The goal

We are going to change the text of your add to cart button to Buy now.

How to change Add to cart to buy now

Let’s open your functions.php file (you can go to Appearance->Editor and select the functions.php file). At the end of that file enter the following code:

add_filter('woocommerce_product_single_add_to_cart_text', 'binary_carpenter_replace_single_text');

function binary_carpenter_replace_single_text()
{
    return 'Buy now';
}

The result

Now, let’s see the result:

How To Change The Add To Cart Button Text In WooCommerce 1

 

How about adding icon and image to the button

You may wonder can you add icon and images to the button (for example the cart icon). The answer is yes, you can but you probably need fontawesome for the icon and upload your image to your host before you can use that. Also, there are a lot more work to be done that just a simple code to add such features. You may need to use a plugin for that.

Conclusion

As you can see, you can change the add to cart text on the button quite easily. However, this method doesn’t offer more flexibility than that. If you want to have icon and image on the button, you probably need something more powerful such as a plugin.

 

How To Set Woocommerce Shipping Rates By Country

The goal

With the introduction of shipping zones, creating shipping rates by country is super easy. We are going to learn how to create flat rates shipping for two different countries in this post.

The setup

For this example, we are going to create flat shipping rate for Vietnam and Germany. The store is located in Vietnam so the flat rate for this country is $5. Shipping to Germany will be higher, $15 in our case.

The implementation

Let’s go to WooCommerce->Settings->Shipping and click on Add shipping zone.

Add a shipping zone for a country

Let’s go ahead and enter zone name and zone regions. In the image above, we created a shipping zone for Germany. Now, let’s go ahead and click on Add shipping method for this zone. We are going to create one flat rate shipping method for each zone.

How To Set Woocommerce Shipping Rates By Country 4

Click on add shipping method, you will get a shipping method like below. Click on the edit button to enter its details:

How To Set Woocommerce Shipping Rates By Country 5

flat rate shipping for country

Click on Save changes and you are done for Germany. Let’s do the same for Vietnam. You’ll get something like this after creating flat shipping for these two countries.

flat rate shipping for two countries Vietnam and Germany

Now you are done. Let’s place test order and see how the shipping based on country works.

Place a test order

Now we have a test order. Let’s go to the cart page, you will see the appropriate shipping rate applied:

shipping rate by country applied

As you can see, the shipping fee is $5, which is exactly what we set when we created the shipping method for Vietnam.

Wait! It doesn’t work for me

If you find the method above doesn’t work for your store, chances are some other plugins or custom code has modified one of the shipping hooks. (`woocommerce_package_rates` for example). In such case, you may need to find the plugin that does that and deactivate it for this method to work.

Conclusion

As you can see, you can easily set flat shipping for each country. You are not limited to shipping based on countries though. If you want a simpler shipping structure, you can set a flat rate for regions like Asia/Africa… However, doing so reduce the level of control over your shipping rates. The choice is yours.