orders

Adding Custom Meta Data from Products to Orders items in Woocommerce

房东的猫 提交于 2019-12-06 15:38:18
I'm trying to get the Custom Meta data of my woocommerce products to my Order Columns in my Woocommerce Admin but this code wont work on my function.php in Wordpress Theme. // Order Get Meta for PD Number add_action('woocommerce_add_order_item_meta','adding_custom_data_in_order_items_meta', 1, 3 ); function adding_custom_data_in_order_items_meta( $post_id, $cart_item_key ) { // The corresponding Product Id for the item: $product_id = $post_id[ 'product_id' ]; //$pd_number = $post_id['_pd_number']; //$pd_number = $_POST['_pd_number']; $pd_number = get_post_meta( $post_id[ 'product_id' ], '_pd

Replace a specific word for BACS payment method in Woocommerce order edit pages

对着背影说爱祢 提交于 2019-12-06 15:31:56
Am new to woocommerce, by using gettext hook am able to replace the text "paid" with "placed" but i want to display this text based on one condition i.e when customer pick wire transfer(bacs) as there was no payment received then only text needs to replace with placed I've attached an image. here you go First let add the Change Text function : function change_text($translated_text, $text, $domain) { switch ($translated_text) { case 'Paid on %1$s @ %2$s': $translated_text = __('Placed on %1$s @ %2$s', 'woocommerce'); break; } return $translated_text; } The Condition: Now let's create our

Hide a specific action button conditionally in Woocommerce admin Orders list

独自空忆成欢 提交于 2019-12-06 15:17:45
问题 I Would like to add some CSS to the order admin page to hide a custom order action button, but only if the order contains only downloadable products. This is the function I need to load conditionally: add_action( 'admin_head', 'hide_custom_order_status_dispatch_icon' ); function hide_custom_order_status_dispatch_icon() { echo '<style>.widefat .column-order_actions a.dispatch { display: none; }</style>'; } Is that possible? 回答1: With CSS it's not be possible . Instead you can hook in

Add the product description to WooCommerce email notifications

╄→гoц情女王★ 提交于 2019-12-06 13:43:55
How to add product description/content of single product page (not the short description) to WooCommerce new order email notification? I need to know specific written description of my products as most of them are almost same. As you are targeting a specific email notification, first we need to get the Email ID to target the "New Order" email notification. The only way is to get it before and to set the value in a global variable. Then in a custom function hooked in woocommerce_order_item_meta_end action hook, we display the product description exclusively for New Order email notification.

WooCommerce order status change from payment gateway

蓝咒 提交于 2019-12-06 12:54:46
I have integrated a payment gateway to accept online payments for my store running on woocommerce. Everything works fine but I noticed that woocommerce is changing the order status to wc-processing for all the online paid orders by default. As per my store's functionality I want all the online paid orders to be in wc-on-hold status initially. Is there any way to stop woocommerce changing the order status to wc-processing programatically? Mauro yes there is a way, but you need to modify the payment plugin or add your own code, you can read this to understand how payments work. Now, woocommerce

Add custom meta data after Payment confirmation in WooCommerce

痞子三分冷 提交于 2019-12-06 12:49:05
问题 I was looking around the web for a solution to add the response from the payment gateway I am using. I would like to add the verification code I get and some more data. I need to add this once the payment is complete. // Payment complete $order->payment_complete($payment_id); I did try this code but does not work for me: add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta'); function my_custom_checkout_field_update_order_meta( $order_id ) { update

Send cancelled and failed order email to customer in Woocommerce 3

一笑奈何 提交于 2019-12-06 12:11:14
问题 I need to send cancelled and failed order email to customers in Woocommerce 3.4+ . I'm constantly getting Fatal error: Uncaught Error: Call to a member function get_billing_email() on null in I've tried few function (like below) from stackoverflow with same result: function wc_cancelled_order_add_customer_email( $recipient, $order ) { return $recipient .= "," . $order->get_billing_email(); } add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10

Auto change order status from hold-on to processing in Woocommerce

耗尽温柔 提交于 2019-12-06 11:00:17
I would like to change every order from woocommerce with the status 'HOLD-ON' to 'PROCESSING' with php . I already tried to write a function in the functions.php file but I failed. How can I auto change order status from "hold-on" to "processing" in Woocommerce? To auto-process orders, you should try the following: add_action( 'woocommerce_thankyou', 'woocommerce_auto_processing_orders'); function woocommerce_auto_processing_orders( $order_id ) { if ( ! $order_id ) return; $order = wc_get_order( $order_id ); // If order is "on-hold" update status to "processing" if( $order->has_status( 'on

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) {

WooCommerce: Add/display Product or Variation custom field everywhere

风流意气都作罢 提交于 2019-12-06 10:29:34
Currently using WordPress 5.1.1 and WooCommerce 3.5.7. My WooCommerce store has around 500 products, made up of simple and variable products. Each product naturally has a SKU, but each product also has a unique ID code called 'Commodity Code'. I sell specific products to a specific industry. I have added the code for the Custom Fields for Simple and Variable product in my functions.php file, and this works great at the moment. My problem is, I have trying to get the 'Commodity Code' to appear under the product title in the Cart, Check Out, invoice and email. I have read various tutorials on