hook-woocommerce

Adding a custom text under the X button that removes items from cart

…衆ロ難τιáo~ 提交于 2019-12-07 20:51:58
问题 With Wordpress and WooCommerce, I am trying to add a custom text "delete item" under the "x" in the shopping cart tthat removes items from cart. I tried to "inspect element" to find where this "x" text icon was located, but I am hitting a brick wall. Any suggestions on how I can find this, and amend the "x" button to include text underneath? Thanks. 回答1: add_filter('woocommerce_cart_item_remove_link', 'remove_icon_and_add_text', 10, 2); function remove_icon_and_add_text($string, $cart_item

Display order customer note in Woocommerce email notifications

橙三吉。 提交于 2019-12-07 20:48:43
问题 In Woocommerce, I am trying to get the customers additional order message: I am trying to display that customer message on the email notifications. But i don't know how to get this information in the php code. Here is my code in the functions.php file: add_action( 'woocommerce_email_after_order_table', 'ts_email_after_order_table', 10, 4 ); function ts_email_after_order_table( $item_id, $item, $order, $plain_text){ $notes=$order->customer_message; //did not work echo '<table cellspacing="0"

Auto completed status for all existing processing orders in WooCommerce

天涯浪子 提交于 2019-12-07 18:14:25
问题 I am using on WooCommerce this little peace of code from this answer to autocomplete paid processing orders: /** * AUTO COMPLETE PAID ORDERS IN WOOCOMMERCE */ add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_paid_order', 10, 1 ); function custom_woocommerce_auto_complete_paid_order( $order_id ) { if ( ! $order_id ) { return; } $order = wc_get_order( $order_id ); // No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods. if ( (

Different Messages Based on WooCommerce Page

一个人想着一个人 提交于 2019-12-06 16:54:39
I am trying to alter messages displayed when adding an a product to cart and/ or updating the cart by hooking in to the woocommerce_add_message . It's not showing anything at all and I'm wondering why. I've tried echo and I've tried return__( Here's the code: add_filter('woocommerce_add_message', 'change_cart_message', 10); function change_cart_message() { $ncst = WC()->cart->subtotal; if ( is_checkout() ) { echo 'Your new order subtotal is: '.$ncst.'. <a style="color: green;" href="#customer_details">Ready to checkout?</a>'; } elseif ( is_product() ) { echo 'Your new order subtotal is: '.

Sorting priority for specific Woocommerce checkout fields depending on country

爱⌒轻易说出口 提交于 2019-12-06 16:07:07
In Woocommerce, I need to set the default ordering priority (sorting) of three fields on the checkout page: The first change depends on the choice of the 'IT' country code: postcode - 'priority' => 91, The other two are free of conditions, I just need to set the default priority: billing_email - 'priority' => 30, billing_phone - 'priority' => 40, By editing the file directly, class-wc-countries.php core file as shown below, I get what I need. But clearly at each update of the plugin I lose the changes. Now I'm looking for a hook to get this done in a clean way. In class-wc-countries.php

Add custom fee to recurring total woocommerce subscription

落花浮王杯 提交于 2019-12-06 15:37:50
问题 function add_woocommerce_stripe_fee() { if ( ( is_admin() && ! defined( 'DOING_AJAX' ) ) || ! is_checkout() ) return; $chosen_gateway = WC()->session->chosen_payment_method; if ( 'stripe' == $chosen_gateway ) { $fee = (WC()->cart->cart_contents_total * .035) +0.35; WC()->cart->add_fee( 'Stripe Fee', $fee, false, '' ); } } add_action( 'woocommerce_cart_calculate_fees','add_woocommerce_stripe_fee' ); It is not adding for recurring cart total but works fine for normal product ( not working for

Add account email conditionally on Customer processing Order email notification in Woocommerce

此生再无相见时 提交于 2019-12-06 14:55:46
So this is more of my solution here but I wanted to open this up to see if the community could find a better alternative or potentially find use for this solve. Our client asked us for the following alteration to the email order receipts received on order creation: The receipts should go to the account holder and cc the billing email if it's different As we know Woocommerce by default sends the order receipt (Customer Processing) based on only the set billing_email on checkout so I started to look for a way to add on the tack on the account owner email to it as well. I did some digging and

Change Cart total using Hooks in Woocommerce 3.2+

对着背影说爱祢 提交于 2019-12-06 14:35:36
I want to add 300 to order total on woocommerce checkout page but woocommerce_calculate_totals hook doesn't do the job... If I use var_dump($total), I see the correct result - int(number), but the total amount in order table is not changing. add_action( 'woocommerce_calculate_totals', 'action_cart_calculate_totals', 10, 1 ); function action_cart_calculate_totals( $cart_object) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; if ( !WC()->cart->is_empty() ): $total = $cart_object->cart_contents_total += 300; var_dump($total); endif; } Since Woocommerce 3.2, the hook woocommerce_calculate

Display order customer note in Woocommerce email notifications

僤鯓⒐⒋嵵緔 提交于 2019-12-06 12:55:18
In Woocommerce, I am trying to get the customers additional order message: I am trying to display that customer message on the email notifications. But i don't know how to get this information in the php code. Here is my code in the functions.php file: add_action( 'woocommerce_email_after_order_table', 'ts_email_after_order_table', 10, 4 ); function ts_email_after_order_table( $item_id, $item, $order, $plain_text){ $notes=$order->customer_message; //did not work echo '<table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 1px solid #e5e5e5;" border="0"><tbody><tr>

WooCommerce hook after order is updated?

谁都会走 提交于 2019-12-06 10:40:47
Is there a hook I can use when I make a change to someone's order via the admin (such as their address, or a custom meta field)? I read this question but unfortunately woocommerce_process_shop_order_meta is fired before the order is saved, meaning I have no access to the newly updated data. What I need is to be able to use the new data that is saved to the order. UPDATE: An issue with using save_post_shop_order is that the meta is updated before this is hit, so I can't compare the previously saved meta value, for example: $metaArray = $_POST['meta']; foreach($metaArray as $meta => $key) {