Change text button “add to cart” able to translation - php

I put in functions.php this code to change the label of the “add to cart” button of Woocommerce. Here is the code:
add_filter( 'woocommerce_product_add_to_cart_text', 'nlwc_custom_button_text' );
function nlwc_custom_button_text() {
return __('Aggiungi ');
}
Is this solution able to be translated with Poedit(for example)?
I tried to insert this:
e_(‘Aggiungi’, ‘theme’);
instead of __('Aggiungi '), but WordPress returned me the text separated from the button.
How can I do to be able to translate the button add to cart in my theme?
I know that if don't modify it, Woocommerce translates the term "add to cart".
Thanks a lot to everyone who answers :)
Carlo

you can use _e function to translite local texts _e('yout text', your theme)

Related

Want to change Checkout button text in woocommerce

continue to shipping button text and continue to payment button text
in website woocommerce checkout is there any solution for this pls help me
SH1
Sh2
My website
Cosmeticsonlinehubb.pk
I have tried all plugins but still got not solution for this.
you can change by adding this code to your theme's functions.php
function my_custom_checkout_button_text() {
return 'My Custom Text';
}
add_filter( 'woocommerce_order_button_text', 'my_custom_checkout_button_text' );
You have to change the value which obviously is the My Custom Text to whatever you want.
Friendly, George

WordPress delete checkout button from cart widget

I want to delete the checkout button from the cart widget so that a user has to view their cart first and can only checkout from the cart page.
I am sure I have to delete some code somewhere but not sure where.
You can do it by using the css or need to check your code to find and remove the button. If you are using the plugin then please check for the hook you are using and edit that one.
With the CSS, you can easily hide the checkout button.
Use it like
.widget_sidebar .checkout_button {
display: none;
}
There are two ways you can achieve this.
The first method is to remove the button using the Woocommerce Hook. Add the below code in your functions.php file
function my_woocommerce_widget_shopping_cart_proceed_to_checkout()
{
return;
}
add_action( 'woocommerce_widget_shopping_cart_buttons',
'my_woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
Another method is by using the CSS to hide that particular button.
Add display: none to that specific button by identifying its class.
.woocommerce-mini-cart__buttons .checkout.wc-forward {display: none !important;}
If you are using a mini cart you can try this
add_action( 'woocommerce_widget_shopping_cart_buttons',
'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
If you are using some plugin then let me know.
You can hide the checkout button multiple ways
1) With Hook
function widget_checkoutbutton()
{
return;
}
add_action( 'woocommerce_widget_shopping_cart_buttons','widget_checkoutbutton', 20 );
2) With CSS
Identify the class name of checkout button and write display none with root class.

Hide add to cart button and add custom content after it in Woocommerce

I've added a 'Customize Now' button and few dropdowns after the 'add to cart' button using woocommerce_after_add_to_cart_button.
But now when I try to hide the 'add to cart' button (which I have to for a specific scenario my website need) using woocommerce_is_purchasable, the 'Customize Now' button and dropdowns are also hidden. Is there any proper order/sequence to do this?
Filter to add the Customize button and dropdowns:
add_action('woocommerce_after_add_to_cart_button', array($this, 'pn_get_calc_and_customize_btn'));
Filter to remove the add to cart button:
add_filter('woocommerce_is_purchasable', array($this, 'pn_hide_add_to_cart_button'), 10, 2);
As add-to-cart templates display condition is:
if ( ! $product->is_purchasable() ) {
return;
}
2 ways:
1) Use instead woocommerce_single_product_summary hook with a priority between 30 and 40:
add_action('woocommerce_single_product_summary', array($this, 'pn_get_calc_and_customize_btn'), 35 );
Then your function output code should be embedded in a custom <form> and you will need to add some more code to save the data in cart or elsewhere…
2) To remove cart button, use woocommerce_product_is_in_stock filter hook instead of woocommerce_is_purchasable so you will have to change a bit your hooked function code too...
add_filter('woocommerce_product_is_in_stock', array($this, 'pn_hide_add_to_cart_button'), 10, 2);
I have two suggestions here:
The first one will be to try to add the priority to your add_action() as well. As per documentation, the lower the number, the earlier the execution. I would try to add a greater priority to add_action() and try to force the woocommerce_after_add_to_cart_button to be executed after your filter. However, I don't know if removing the button also inhibits the filter (it might be).
Another suggestion I may have is to override the default template for the page (i don't know if you're editing the shop page or the single_product page) and have some if{}else{} login in there to show hide buttons based on the situation.
I don't know if either of these solutions is any good for you but this was just my tough and how I would tackle it.
Hope it helps in any way

Need help in editing a tab in Woocommerce product page

I am trying to change the name of a tab in product page of woocommerce to a different name.
I am trying to find which PHP file has that particular code but I am unable to do that. Have also used plugins like WhatTheFile (it said the product page is loaded from single-product.php, but I couldn't find the html to edit there) and String Locator and they couldn't help even. Please have a look at this video I made and you will better understand my problem.
https://www.dropbox.com/s/bruhb2n83lhfnp6/Code.mp4?dl=0
I am using G5Plus April theme
Thank you
you can add code like this in functions.php of your theme to customize the product description tab title. For more details, Link 1, Link 2
add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
function woo_customize_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
return $tabs;
}
Hope this will helps you.

Add link to Shopping Cart on Woocommerce's Checkout page

I've seen many tutorials dealing on how to customize woocommerce's checkout page by adding or removing fields.
But what I want is to place a link or button on the Woocommerce Checkout page saying "Return to Cart" (obviously linking to the cart page) but I want it placed just after the "Your Order" section, (the section where you review your order). I want it there because I want it along with a text saying something like "If you want to change your order return to Cart".
If I edit the actual checkout page and add the link there, it shows all the way to the bottom so maybe I have to add code to the theme's functions file? Any guidance will be greatly appreciated.
Thank you.
EDIT:
Ok, I've found a very crappy way of doing it.
I just added this line to the review-order.php file located in woocommerce/templates/checkout/ , right after the shop_table class:
<?php echo "<strong>If you'd like to change your order, go back to <a href='http://www.mysite.com/cart/'>My Cart</a></strong><br />"; ?>
This does the trick, but everytime I update woocommerce I will have to added it again.
Any suggestion of a more practical and intelligent way of doing it?
Create a child theme.
Put this in the child theme's functions.php
/**
* Add link back to cart after order review on Checkout
*/
add_action( 'woocommerce_review_order_before_payment', 'my_back_to_cart_link' );
function my_back_to_cart_link(){
//get the cart link
global $woocommerce;
$cartUrl = $woocommerce->cart->get_cart_url();
//the HTML markup to add
$backToCartLink="<p class='backtocart'><a class='button alt' href='".$cartUrl."'>".__('Edit Cart','wooint')."</a></p>";
echo $backToCartLink;
}
Well, if you created a child theme you could have put that line in your child's functions.php and then the only way an update would affect it is if they changed the coding.

Categories