My woocommerce sends out an as it is suppose to.
How ever the tax fields shows up with what seems to be an unclosed tag.
I have grepped thru the entire woocommerce code, but I cant find where the tags are generated.
this is how my tax field looks in the email.
Total: DKK 0.00 <small class="includes_tax"
This can only be the result of a customization that you have made on order totals, or that your theme or a plugin is making. By default there is no such behavior in Woocommerce. It seems in your case due to a plugin (or some customizations) that displays the currency symbol as a Code.
Now order totals rows in Woocommerce email notifications are generated using the WC_Order method get_order_item_totals()
Then you can make changes in it using the following code:
add_filter( 'woocommerce_get_order_item_totals', 'customize_order_line_totals', 1000, 3 );
function customize_order_line_totals( $total_rows, $order, $tax_display ){
// Only on emails notifications
if( ! is_wc_endpoint_url() || ! is_admin() ) {
// Remove any other html tags from gran total value
$total_rows['order_total']['value'] = strip_tags( wc_price( $order->get_total() ) );
}
return $total_rows;
}
Code goes in function.php file of your active child theme (or active theme). It should solve your problem.
But the best way should be to find out the guilty, instead of patching something wrong done by some customization somewhere.
Related
I found this post: Remove price from Woocommerce variable product dropdown menu, but it hides ALL variable prices. Instead I would like to hide the variable price if it is $0.00.
Can anyone help me with this?
Edit:
I didn't realize that the variation prices weren't part of WooCommerce. I am using WooCommerce Product Add-ons. I found this snippet that will target a specific product, but I don't know how to convert it to if !$0.00 condition. This post closer identifies my issue:
Hide displayed product prices from Woocommerce Product Add-ons Fields
Based on Hide displayed product prices from Woocommerce Product Add-ons Fields answer code, you can try to use something like:
add_filter( 'woocommerce_product_addons_option_price', 'filter_product_addons_option_price', 10, 4 );
function filter_product_addons_option_price( $price_html, $option, $i, $type ){
if( isset($option['price']) && ! ( $option['price'] > 0 ) ) {
$price_html = '';
}
return $price_html;
}
Code goes in functions.php file of the active child theme (or active theme). It could works.
I'm using Stylization of decimals as uppercase in WooCommerce frontend only answer code from my previous question.
Now I have a particular issue: I've noticed that my code is breaking the default WooCommerce decimals calculation rules, is there anything you can see in my code that would be breaking it?
As an example, with this code, a price entered before tax in the backend as 7,39669€ (which is the result of 8.95€/1.21) is wrongly being shown as 8.94€ instead of 8.95€. When I disable this custom code, WooCommerce rules work fine again.
I'd like to ensure that the code "calls" the default WooCommerce calculations, so that the code only changes the display of the decimals and that's all.
To avoid this problem, here I am using a different way to separate decimals from the price:
add_filter( 'formatted_woocommerce_price', 'ts_woo_decimal_price', 10, 5 );
function ts_woo_decimal_price( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {
// Not on backend
if ( ! is_admin() ) {
$price_data = explode($decimal_separator, $formatted_price);
return $price_data[0] . '<sup>' . $price_data[1] . '</sup>';
}
return $formatted_price;
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
Using WooCommerce 3.6.5 within the Avada theme.
We have one product with variations. The products with variation use WooCommerce Tabs in the presentation to give more information about the product. I need to retain this.
[I do not see WooCommerce Tabs as an option within my Wordpress/WooCommerce admin panel that I see on so many videos detailing how to change or use Tabs, or any plugin that looks like they manage this, so I am at a loss to how the tabs are being handled.]
I have a new simple product added to the site, but the simple product also gets the tabs prepopulated with information that is not relevant to the simple product, from the product with variations.
I have identified the Tabs as belonging to WooCommerce through using Firebug to reveal information on the Divs within the webpage.
I need to prevent the tabs being displayed on the one simple product and/or change the tabs presentation order, or number. Would be happy to limit this within PHP code.
Have found this page with what looks like useful information to limit the presentation of tabs -
https://docs.woocommerce.com/document/editing-product-data-tabs/
Section of code -
/**
* Remove product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
What bothers me is the implementation of this code.
What is the "98" element after 'woo_remove_product_tabs', ? and how can I limit this bit of code to only operate with the one simple product I have, rather than all the products and variations, or other simple products I may add in the future ?
Would appreciate some guidance.
First if you look to add_filter() function documentation, you will see that the third argument is related to the hook priority (in your case 98)…
To target simple products only you will use the WC_Product is_type() method and you will define your desired product Ids in the code below:
add_filter( 'woocommerce_product_tabs', 'removing_product_tabs', 98 );
function removing_product_tabs( $tabs ) {
// Get the global product object
global $product;
// HERE define your specific product Ids
$targeted_ids = array( 37, 56, 63 );
if( $product->is_type( 'simple' ) && in_array( $product->get_id(), $targeted_ids ) ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
}
return $tabs;
}
Code goes in functions.php file of your active child theme (active active theme). It should work.
In woocommerce, I am using the following to remove the shipping block in cart totals section bloc:
function disable_shipping_calc_on_cart( $show_shipping ) {
if( is_cart() ) {
return false;
}
return $show_shipping;
}
add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_cart', 99 );
But in that cart totals section bloc there are some other things like the cart Subtotal and Total.
I just need to keep only Total
Any help is welcome.
You seem to keep only the total on cart totals section. For that the only way is overriding woocommerce templates.
There is 2 steps:
You should read Template structure & Overriding templates via a theme to understand how you can override woocommerce templates via your active child theme (or active theme).
So you will have to create in you active theme folder (if it doesn't exist yet) a folder named "woocommerce" and a sub-sub folder "cart"…
You will have to copy from the wp-content/plugins/woocommerce/templates/cart/cart-totals.php to your active theme woocommerce/cart/cart-totals.php (if it not exist yet).
Editing cart-totals.phptemplate and removing code:
Since WooCommerce version 2.3.6 and up: You will have to remove the code from line 32 to 59 (You will keep only fees and taxes if they are any)
If you want to keep only the total amount you will remove the code from line 32 to line 87
Then save.
You will not need your function code anymore
Now your cart totals will be something like this:
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );
function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
}
Is this what you are looking for? Basically you asked to remove the subtotal.
I am trying to modify the page thanks to buy at WooCommerce, at least for the method of payment by bank check.
All I want to do is show a summary of the order and empty the cart, because currently shows me an empty page with the text that the cart has been emptied. Is there a hook that allows me to insert code on the page thanks for paying by bank check?
I found the 'woocommerce_thankyou' action but I do not know what to do with it, does anyone explain to me a little?
you can target cheque payment method using woocommerce_thankyou_cheque action hook, that will display a custom message on order received page for cheque payments:
add_action( 'woocommerce_thankyou_cheque', 'woocommerce_thankyou_cheque_payment', 10, 1 );
function woocommerce_thankyou_cheque_payment( $order_id ){
if( ! $order_id ) return;
// SET your message below
echo '<p>'.__( 'Thanks for paying by cheque message.', 'woocommerce' ).'</p>';
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and works.