orders

How to Show SKU with product title in Order received page and Email order

你。 提交于 2019-12-04 19:37:21
In functions.php add_action( 'woocommerce_add_order_item_meta', 'custom_add_item_sku', 10, 3 ); function custom_add_item_sku( $item_id, $values, $cart_item_key ) { $item_sku = get_post_meta( $values[ 'product_id' ], '_sku', true ); wc_add_order_item_meta( $item_id, 'SKU', $item_sku , false ); } But its showing SKU value below Product title but i want it like this SKU:123sd - Product Name Update 2018-04-01 - Changing of hook and Improved code. Use woocommerce_order_item_name filter hook instead. I have make some changes in your code: add_filter( 'woocommerce_order_item_name', 'sku_before_order

Add custom meta data after Payment confirmation in WooCommerce

纵然是瞬间 提交于 2019-12-04 19:23:59
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_post_meta( $order_id, 'My Field', 'test'); } Any help will be appreciated You should better use

Change Woocommerce Order Status based on Shipping Method

北城余情 提交于 2019-12-04 18:34:47
The idea here is that when an order comes in with an "express delivery" as Shipping Method, the order status is updated to On-Hold. As there I have some different "express delivery" Shipping Method rates I thought that by using stristr() to see if the word 'express' appears anywhere in the formatted shipping method title. But I seem to be missing something as I don't get anything. How can I check if the Order shipping method is an "express delivery" to be able to update the order status? Here is the code that I have: add_action( 'woocommerce_thankyou', 'express_orders_4865', 10, 1 ); function

Get custom order item metadata in Woocommerce 3

本秂侑毒 提交于 2019-12-04 18:30:32
I am using Woocommerce latest version 3.4.2. How can I get some order item metadata and assign them a custom value? I get meta data with a common array $item_product_data_array . I need to get a certain value - (Additional modification for the product). And assign custom sku. Example: I have coffe - sku 1001, in array - key [0] Product coffe have additional modification - sugar (meta data) Need found "Sugar" and assign him custom sku - 50005. [label] => Optionally select [value] => Array ( [0] => Cinnamon [1] => Sugar [2] => Mint ) That is, this additive should be in one cycle as a price or

Get order ids with status = 'Complete' in Magento

放肆的年华 提交于 2019-12-04 18:19:58
问题 I am working on getting order ids and other details for orders with status ='complete' in Magento. I am sure there is a way in magento where we can retrieve all orders with status as Complete. Since I am a new-bie to magento I am finding it hard to work this out. I would like to send the customers with order status as Complete an email and mark them once an email is sent. But thats the later part of it. Can any one tell me how in magento can you get all order id's with status as Complete ?

Woocommerce email notification recipient conditionally based on custom field

久未见 提交于 2019-12-04 18:11:37
I have a checkout form with a custom field. I would like to add an extra recipient to an order email based on the value in the custom field. The custom field is currently a drop down menu with only 3 options. Below is the code I was able to piece together with some googling however this does not appear to work. function sv_conditional_email_recipient( $recipient, $order ) { $custom_field = get_post_meta($orderid, 'custom_field', true); if ($custom_field == "Value 1") { $recipient .= ', email1@gmail.com'; } elseif ($custom_field == "Value 2") { $recipient .= ', email2@gmail.com'; } elseif (

Use Woocommerce functions in custom php files

你说的曾经没有我的故事 提交于 2019-12-04 17:47:13
I am a total beginner in programming with PHP. I wanted to create a PHP file in which the order_status from a predefined order (in my case 108) gets changed to completed. Therefore I need the woocommerce functions get_order($ID) and update_status but I do not know how to use them in my PHP. I hope you understand my problem. From Java I could imagine that I need to get an instance from a class or something like that? Here is the code I have so far: <?php $ord = new WC_Order(108); $ord->update_status('completed'); ?> When I open the page I receive the following error: Fatal error: Uncaught Error

Add a fee to an order programmatically in Woocommerce 3

自闭症网瘾萝莉.ら 提交于 2019-12-04 17:04:40
I'm creating Woocommerce totals 'on-the-fly' as my cart items are imported from another CMS. Currently I am having trouble setting a custom 'fee' for each order , then marking the order as 'on-hold': $order->set_date_created($creation_tsz); $order->set_address( $address, 'billing' ); $order->set_address( $address, 'shipping' ); $order->set_currency('GBP'); $order->add_fee('Imported Total', $imported_total_here); $order->set_fee(); $order->calculate_totals(); $order->update_status('on-hold'); Any track on this will be appreciated. The WC_Abstract_Legacy_Order method add_fee() is deprecated and

Send cancelled and failed order email to customer in Woocommerce 3

落花浮王杯 提交于 2019-12-04 16:19:25
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, 2 ); add_filter( 'woocommerce_email_recipient_failed_order', 'wc_cancelled_order_add_customer_email',

Add a custom placeholder to email subject in WooCommerce

一曲冷凌霜 提交于 2019-12-04 15:59:51
I have a Woocommerce shop and I wanted to add a delivery_date after I accept the payment. I create a custom field in the order section named delivery_date with a date value. Now I wanted to use this custom field as a placeholder in email notification subject, like: Your order is now {order_status}. Order details are shown below for your reference: deliverydate: {delivery_date} I think the placeholder don't work like this, I need to change something in the php but I don't know where. To add a custom active placeholder {delivery_date} in woocommerce email subject, you will use the following