orders

Get user total purchased items count in Woocmmmerce

限于喜欢 提交于 2020-01-13 04:52:28
问题 I'm trying to figure out a function which get current user total number of purchased items (not total sum but items) across as all placed orders. So far I have found this (which doesn't work) - but again this function should get total sum and not items. Been trying to edit it to work but no success so far. public function get_customer_total_order() { $customer_orders = get_posts( array( 'numberposts' => - 1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' =>

Display back Order Notes in Admin orders list on WooCommerce 3.3

主宰稳场 提交于 2020-01-12 10:18:32
问题 Is there any hooks or options to display order notes in WooCommerce order page in back end ? I have tried the following code and managed to add a column. function wc_new_order_column( $columns ) { $columns['my_column'] = 'My column'; return $columns; } add_filter( 'manage_edit-shop_order_columns', 'wc_new_order_column' ); I am stuck in adding order notes 回答1: The following will enable back the display of Order Notes in WooCommerce 3.3+ admin orders list: add_filter( 'manage_edit-shop_order

Sending only order number instead of item names to PayPal in Woocommerce

 ̄綄美尐妖づ 提交于 2020-01-11 04:06:04
问题 In PayPal standard gateway of Woocommerce, I want to make Woocommerce sends only " order number " as the only item in the cart, instead of the itemized product list. For that, I tried to edit the class which is responsible for making a PayPal request here: woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php I tried to edit get_order_item_names() function to return "invoice" . $order->get_order_number() as the name of the only item, but it wasn't successful since

Replace woocommerce_add_order_item_meta hook in Woocommerce 3.4

孤街浪徒 提交于 2020-01-09 03:53:21
问题 I have custom code use woocommerce_add_order_item_meta hook. But woocommerce 3.4.0 show error log: "woocommerce_add_order_item_meta is deprecated since version 3.0.0! Use woocommerce_new_order_item instead." How to fix it? Thank you very much. My code: // add data design to order function tshirt_order_meta_handler( $item_id, $values, $cart_item_key ) { if( WC()->session->__isset( $cart_item_key.'_designer' ) ) { wc_add_order_item_meta( $item_id, "custom_designer", WC()->session->get( $cart

Set back date paid on paid order statuses change in WooCommerce

跟風遠走 提交于 2020-01-05 07:16:08
问题 I WooCommerce, I'm using "Change admin payment status back to unpaid for pending order status in Woocommerce" answer code to reset the paid status of orders when the order status is manually changed in the backend to pending. So for example, it removes the following if the order status was change from "completed" to "pending": "Paid on April 2, 2019 @ 5:29 pm" Now my problem here is after the order status was set to "pending", I tried to set it again the status to "completed" but it failed to

Set back date paid on paid order statuses change in WooCommerce

主宰稳场 提交于 2020-01-05 07:16:05
问题 I WooCommerce, I'm using "Change admin payment status back to unpaid for pending order status in Woocommerce" answer code to reset the paid status of orders when the order status is manually changed in the backend to pending. So for example, it removes the following if the order status was change from "completed" to "pending": "Paid on April 2, 2019 @ 5:29 pm" Now my problem here is after the order status was set to "pending", I tried to set it again the status to "completed" but it failed to

Email notification to a particular address if a specific product is purchased in Woocommerce

耗尽温柔 提交于 2020-01-05 02:16:06
问题 I am using the woocommerce plugin in my Wordpress website. I am wondering how can I send an email notification to a specific address email if product A is purchased by customer. How to send an email notification to a specific address when a specific product is purchased in Woocommerce? 回答1: The code below will add a custom defined email recipient to New Email Notification When a specific defined product Id is found in order items: add_filter( 'woocommerce_email_recipient_new_order',

Add Custom checkout field to Order in WooCommerce

三世轮回 提交于 2020-01-03 03:59:25
问题 The WooCommerce 3.0 update has not been kind to me. I have added a custom required field to checkout for a domain name, and am having trouble figuring out how to get it to save now. This code adds the field properly still: add_action( 'woocommerce_after_order_notes', 'add_domain_checkout_field' ); function add_domain_checkout_field( $checkout ) { echo '<div id="add_domain_checkout_field"><h2>' . __('Domain') . '</h2>'; woocommerce_form_field( 'sitelink_domain', array( 'type' => 'text',

WooCommerce: Add/display Product or Variation custom field everywhere

醉酒当歌 提交于 2020-01-02 10:06:02
问题 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

Get all WooCommerce customers paid orders with a SQL query

China☆狼群 提交于 2020-01-02 08:38:17
问题 I need a query that returns me all the users with orders with payment approved. I'm having a hard time finding where in the db this is stored. I found only post_status 'wc-complete', but I don't think this is the right info. SELECT a.post_status, b.meta_value FROM wp_posts a, wp_postmeta b WHERE a.ID = b.post_id AND a.post_type = 'shop_order' AND a.post_status = 'wc-completed' 回答1: Using "completed" order status for paid orders is correct Here is a custom function with a SQL query, that will