I'm trying to find the correct function or filter to edit the text of the buttons "View Cart" and "Checkout" in the Cart Widget of Woocommerce.
My website url : http://modularwave.com/ (just so you know i'm using Brutal, great theme from zigzagpress).
Thanks in advance for you help,
F.
You can use str_ireplace() to change the text of the button, the following function will allow you to change the text of a Woocommerce button:
//The filters.. both are required.
add_filter('gettext', 'change_checkout_btn');
add_filter('ngettext', 'change_checkout_btn');
//function
function change_checkout_btn($checkout_btn){
$checkout_btn= str_ireplace('Checkout', 'Your New Text', $checkout_btn);
return $checkout_btn;
}
To easily translate plugins use this plugin:
https://wordpress.org/plugins/loco-translate/
It lets you select a plugin.
Note, only plugins with .mo/.po files can be translated.
I hope this will help you!
Good luck.
Related
I have very beginner level understanding of wordpress, woocommerce and elementor. I am still learning a lot of things. I believe that the best way to learn is to imitate. So, I go through various themes and try to imitate their behaviour and appearance using Elementor. But, this particular theme caught my eye. The Add to cart button appears when someone hovers over the product image instead of always being there. Can you guys please help me figure this out or atleast point me in the right direction?
This is how it should look when someone hovers over the images
This is how it looks when the mouse pointer is away
More info
<?php if($available) {?>
Buy now
<?php } ?>
This code solves my problem as expected.
WooCommerce documentation reference
Solution: Add code in your theme's function.php file.
add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );
function my_extra_button_on_product_page() {
global $product;
echo 'Add to cart';
}
Solution: Install Custom WooCommerce Add to Cart plugin
Custom WooCommerce Add to Cart Plugin
Solution: You can use hooks with shortcodes:
custom add to cart button
Or create overrides for WooCommerce files in your own template
Could someone point me in the right direction to accomplish a small task?
Basically I need to create a small plugin that adds a button (html code - a link) on the add new page/post in admin.
I've researched a bit but I didn't find what hook to use. Thank you
I was trying to add a button somewhere on the post new page in admin that once clicked would trigger some ajax.
Here's what I've come up with in case someone else needs this:
add_action( 'media_buttons', function($editor_id){
echo 'Click me';
});
I am customizing the Wordpress login page and I want to add a text to the bottom of the page. I've already found tutorials that teach you how to add a text above login form but I want to add text to the "footer". How do I do that?
I want to add the text here
Thank you in advance for you answer.
Lenka
I'm refering to the docs: https://codex.wordpress.org/Customizing_the_Login_Form
You can use an action hook for the action login_footer to customize the login footer.
add_action( 'login_footer', 'your_custom_footer' );
function your_custom_footer() {
// Add your content here
echo "<p>I'm a little side note.</p>"
}
I have a customized admin where I have changed posts to "articles" and I changed this text throughout the rest of the site by adding some code to functions.php but can't find a way to alter it in the dashboard widget that, the main default one that is titled "Right Now." I'd like it to say "X Articles" instead of "Posts" here. Anyone know? I'd like to change "X Categories" to a custom taxonomy and eliminate the listings for tags and pages from this space as well.
Any help is greatly appreciated.
Looking at the core, I see the string is hardcoded. Two ways to change it: jQuery or the filter get_text.
You'll want to load it only in that specific page, so use:
add_action( 'load-index.php', 'callback' );
function callback()
{
// add_filter( 'get_text', etc...
# OR
// add_action( 'admin_footer', print jQuery...
}
Here's another example of usage.
I want to create a wordpress plugin where it adds additional controls underneath the WYSIWYG editor when adding pages/posts. But I don't know what keywords I'm supposed to google for to find relevant tutorials on how to do it.
Can someone provide me with resources?
It's called add_meta_box() - call it within a hooked admin_init function like so;
function my_custom_meta_box()
{
add_meta_box(
'my_meta_box_id',
'My Meta Box Title',
'my_meta_box_callback',
'post', // either post, page or link,
'normal', // position of the meta box,
'high' // position priority
);
}
add_action('admin_init', 'my_custom_meta_box');
function my_meta_box_callback()
{
echo 'This is the content of my meta box!';
}
Do you want the filter reference for hooks to add to the editor? Plugin API/Filter Reference « WordPress Codex There are lots of plugins that add controls to the editor: WordPress › WordPress Plugins - TinyMCE
I've written a good tutorial on adding WordPress Meta Boxes additionally check out my WPalchemy Meta Box PHP Class which will help you create meta boxes with ease.