I want to remove special word woocommerce products title
Example:
Products title: vidaXL Dining Chairs 2 pcs Solid Acacia Wood Sheesham
So, I want to remove vidaXL from WooCommerce website. This website still, 18000 products available so manually is not possible. If possible then please any WooCommerce functions.
I already tried so please someone help me.
add_filter( 'gettext', 'theme_change_field_names', 20, 3 );
function theme_change_field_names( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'vidaXL' :
$translated_text = __( '', 'theme_text_domain' );
break;
}
return $translated_text;
}
Related
I'm currently working with WordPress and WooCommerce for the first time. I have a management software and 2 different Customers tiers (one with extra discounts and one with regular price). I found a plugin that can import both of the prices in the fields "Regular price" and "Sale Price". The problem is, WooCommerce will always give the customers the discounted price, no matter the user role. I worked with some snippets and managed to display the regular price to Tier2 customers. However in the cart the price is still discounted. I tried using snippets to modify the cart prices, but it was useless (or maybe i'm burning out and can't figure out the solution). Plugins won't work for me, I watched and read all of them in the wp plugin store, and no one works well with my needs since i have almost 2000 products and most of them have different discounts percentage.
Please help me out!
Working Snippet:
$user = wp_get_current_user();
$allowed_roles = array( 'tier2');
if ( array_intersect( $allowed_roles, $user->roles ) || !is_user_logged_in()) {
add_filter('woocommerce_get_price_html', 'custom_price_html', 10, 2 );
function custom_price_html( $price, $product ) {
if ( $product->is_on_sale() && ! is_admin() ) {
$price = wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ) . $product->get_price_suffix();
}
return $price;
}
}
I tried searching on the net for plugins or similar solutions, nothing is working.
Is there a hook to change the Total title from the WooCommerce order received page's order overview? Please see the below image to understand better
Yes, you can use the gettext WordPress filter to "translate" (rename in your case) that string of text.
Your string is inside the thankyou.php WooCommerce template:
esc_html_e( 'Total:', 'woocommerce' );
Based on WooCommerce: How to Translate / Rename Any String tutorial, the right code should be the following:
add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 9999, 3 );
function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {
if ( ! is_admin() && 'woocommerce' === $domain ) {
switch ( $translated ) {
case 'Total:':
$translated = 'Whatever:';
break;
}
}
return $translated;
}
Hey I'm trying to change the weight unit text from kg to kiloGrams in additional information at product page but the code is working for Description string to change but not for working for kg text can't figure out why.
would be really great if anyone could suggest. Thanks.
add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {
if ( ! is_admin() && 'woocommerce' === $domain ) {
switch ( $translated) {
case 'g' :
$translated = 'grams';
break;
case 'Description' :
$translated = 'Product Specifications';
break;
// ETC
}
}
return $translated;
}
// To update the units in woocommerce from g to grams or another
update_option( 'woocommerce_weight_unit', 'grams' );
I use WooCommerce & WPML for my client. The website have different prices for different markets.
For example, the EU is a price and for Finland there is another price both in €.
I have included a separate version of currency called FI-EUR. Everything appears right and works just the way I want.
add_filter( 'woocommerce_currencies', 'finland_euro' );
function finland_euro( $currencies ) {
$currencies['FI-EUR'] = __( 'Finland Euro', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'FI-EUR': $currency_symbol = '€'; break;
}
return $currency_symbol;
}
But the problem arises when we use Stripe or Paypal. Since it does not support FI-EUR. How do I change FI-EUR to EUR for stripe?
I can not overwrite EUR as there is another price.
Thank you!
What i need to do:
I want to run some checks on a product before being added to the cart.
More exactly:
I want to compare the product i am about to add to the cart, with the ones already added, to see if there are some conflicts.
An example:
Let's say we have a product named "Both shoes", and a product "left shoe".
A user adds "left shoe" to the cart. Then he adds "both shoes". I want to print an error instead of adding the "both shoes": Sorry, but you can't add both shoes if you've added left shoe to the cart. If you want to buy "both shoes", please first remove "left shoe".
I've looked at class-wc-cart.php and i found an action hook at line 811, but it's too late! It's after the product has been added
"do_action( 'woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data );"
The add_to_cart method starts at line 705.
http://wcdocs.woothemes.com/apidocs/source-class-WC_Cart.html#705
How can my "product conflict manager" function be hooked before line 801, without hacking woocommerce?
Thank you!
A bit late, but I think you are looking for add to cart validation, which is filterable. Here's an over simplified version:
function so_validate_add_cart_item( $passed, $product_id, $quantity, $variation_id = '', $variations= '' ) {
// do your validation, if not met switch $passed to false
if ( 1 != 2 ){
$passed = false;
wc_add_notice( __( 'You can not do that', 'textdomain' ), 'error' );
}
return $passed;
}
add_filter( 'woocommerce_add_to_cart_validation', 'so_validate_add_cart_item', 10, 5 );