I am looking for a way to add a section to my order emails in Woocommerce to show related products. I have already customized the php templates for my emails, but cannot seem to find the right code snippet to call the related products function.
I tried the solution in the thread without succes:
How to add related products or cross sells to order emails in WooCommerce
Any suggestions?
You can use this hook woocommerce_email_after_order_table to show text after order table.
add_action( 'woocommerce_email_after_order_table', 'add_order_email_instructions', 10, 2 );
function add_order_email_instructions( $order, $sent_to_admin ) {
if ( ! $sent_to_admin ) {
echo 'Custom HTml OR Custom Text';
}
}
Related
To reduce the number of redirects on my site, i added the cart page on the same page as the checkout. and used this code to do it:
function cart_on_checkout_page_only() {
if ( is_wc_endpoint_url( 'order-received' ) ) return;
// add woocomerce cart shortcode on checkout page
echo do_shortcode('[woocommerce_cart]');
}
// Cart and Checkout same page
add_action( 'woocommerce_before_checkout_form', 'cart_on_checkout_page_only', 5 );
The problem is in the layout specifically, on devices it is too far from the order items as the order total is at the bottom of the page near the checkout button. I got a lot of complaints because people are too lazy to scroll down to see the coupon application in the cart at the bottom of the page
so I made the following modification:
I copied the woocommerce plugin files woocommerce/template/cart/cat.php and cart-totals.php
and pasted it into my theme in themes/mytheme/template/cart/custom-cart.php
and adapted it in the code above:
function cart_on_checkout_page_only() {
if ( is_wc_endpoint_url( 'order-received' ) ) return;
// add custom cart template on checkout page
get_template_part('template/cart/custom-cart');
}
// Cart and Checkout same page
add_action( 'woocommerce_before_checkout_form', 'cart_on_checkout_page_only', 5 );
my code did the job, but I believe there should be a simpler and more elegant way to make this kind of change. it's possible to make more simpler?
by the way I'm using a child storefront theme.
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.
I've written some filters to disable plugin functionality of Customer Specific Pricing by WisdmLabs. These are the filters I've wrote
add_filter ( 'wdm_csp_calc_simple_prod_price', '__return_false' );
add_filter ( 'wdm_csp_show_total_price', '__return_false' );
add_filter ( 'wdm_csp_show_quantity_based_price', '__return_false' );
add_filter ( 'wdm_csp_apply_quantity_price_in_cart', '__return_false' );
However this applies it to the entire store but I just need to apply it to a single product. Could anyone help with with the code to apply these filters just for one product?
I designed a WooCommerce template for a customer. Now he wants to remove prices and visitors only add what they want to the list. So there will be no payment method. s:
- I can't change plugin or database. All data must remain how they are.
- I need to remove prices from all over the site. where ever they are. Cart, wishlist, single page & etc.
- I need to change payment method to something like submit list.
- at the end after submit list page there must be a contact info page.
please help.
You can hook into wc_price and remove the prices there
function my_filter_wc_price( $price ){
return '';
}
add_filter( 'wc_price', 'my_filter_wc_price' );
Then you can hook into parse_query and redirect the checkout page to the contact page.
function my_parse_query(){
if( is_page( wc_get_page_id( 'checkout' ) ) ){
wp_redirect( '/contact' );
exit;
}
}
add_action( 'parse_query', 'my_parse_query' );
That will stop people from being able purchasing things. Just hiding the price with CSS will not. They will still be able to craft URL's to add to cart, and find the cart / checkout pages.
since I found no other way I decided to do it width CSS and translation.
I removed all prices by display:none;
and I translated all the strings which are about shop and price.
I am currently trying to add new custom emails to the woocommerce emails list.
I have followed the instructions from this link : https://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
I use a custom action for this email (ch_deadline) which I trigger with this in my plugin:
add_action( 'ch_deadline_notification', array( $this, 'trigger' ) );
As I have seen in this post : WooCommerce - send custom email on custom order status change, I need to add it to the woocommerce email actions :
add_filter( 'woocommerce_email_actions', 'add_deadline_email_actions' ); // WC 2.3+
function add_deadline_email_actions( $email_actions ) {
$email_actions[] = 'ch_deadline';
return $email_actions;
}
In the front-end, it works well, it display my new email in the list.
Unfortunately the email has never been sent.
I have read a lot of post about this problem but none of the proposed solutions resolved the problem
I have even tried to add directly my action in $email_actions list in class-wc-emails.php
If you have any ideas, I'm more than interested !
Thanks !