orders

Save WooCommerce order item custom fields sum as a new meta data

空扰寡人 提交于 2020-02-02 12:49:29
问题 When a particular product is ordered in this WooCommerce store, two meta values are added to the order. The two fields that store the meta values are located in wp_woocommerce_order_itemmeta The meta keys are : quantity assemblycost I want to create a new custom field programmatically when a new order is placed and set the value of this new field equal to quanity * assemblycost if the meta key assemblycost exists for the product that has been ordered. After some research I discovered that

Adding suffix and prefix to WooCommerce order number without using a plugin

*爱你&永不变心* 提交于 2020-02-02 11:57:33
问题 I want to add a suffix and a prefix to a Woo Commerce order number without using a plugin. I tried to use this hook which is not working: add_filter( 'woocommerce_order_number','my_woocommerce_order_number', 1, 2); function my_woocommerce_order_number( $oldnumber, $order ) { return 'VC'.$order->id; } How can I achieve this? 回答1: add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number', 1, 2); function change_woocommerce_order_number( $order_id, $order ) { $prefix = '#SAM-';

Avoid customer email notification for a specific product category in Woocommerce

痞子三分冷 提交于 2020-01-25 07:24:27
问题 In Woocommerce, I am trying to stop customer order email for a particular product category in woocommerce. What I have tried is: add_filter('woocommerce_email_recipient_customer_processing_order', 'wc_change_customer_new_order_email_recipient', 10, 3); function wc_change_customer_new_order_email_recipient( $recipient, $order ) { global $woocommerce; $items = $order->get_items(); $category_ids = array( 10 ); $flagHasProduct = false; foreach ( $items as $item ) { $product_id = $item['product_id

Avoid customer email notification for a specific product category in Woocommerce

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-25 07:24:06
问题 In Woocommerce, I am trying to stop customer order email for a particular product category in woocommerce. What I have tried is: add_filter('woocommerce_email_recipient_customer_processing_order', 'wc_change_customer_new_order_email_recipient', 10, 3); function wc_change_customer_new_order_email_recipient( $recipient, $order ) { global $woocommerce; $items = $order->get_items(); $category_ids = array( 10 ); $flagHasProduct = false; foreach ( $items as $item ) { $product_id = $item['product_id

Woocommerce - Admin Order Detail Page

邮差的信 提交于 2020-01-24 21:07:31
问题 I add one product for e.g “ABC” – price : $10 (including VAT 20%) So product net price = £8 and tax = £2 In frontend on product detail page i show product price including TAX.($10) When Customer purchase this product then in woocommerce order generate like this product price = $8 tax = $2 ------------------- Total = $10 But i want price in admin order detail page like product price : $10(including 20% VAT) Not want to show VAT separate. Thanks 回答1: Try this. Put it in your theme function.php

Woocommerce - Admin Order Detail Page

早过忘川 提交于 2020-01-24 21:05:29
问题 I add one product for e.g “ABC” – price : $10 (including VAT 20%) So product net price = £8 and tax = £2 In frontend on product detail page i show product price including TAX.($10) When Customer purchase this product then in woocommerce order generate like this product price = $8 tax = $2 ------------------- Total = $10 But i want price in admin order detail page like product price : $10(including 20% VAT) Not want to show VAT separate. Thanks 回答1: Try this. Put it in your theme function.php

Remove a dropdown select field filter in Woocommerce admin orders list

丶灬走出姿态 提交于 2020-01-24 01:50:10
问题 In WooCommerce version 3.0+, I would like to remove All shipping Countries filter on Woocommerce order panel. How to do that? any ideas ? Thanks 回答1: This selectors you want to remove are custom and certainly added by a third party plugin. You can try this to hide the drop-down selector field with a custom function hooked in admin_head action hook. You will need to replace the CSS ID #my_selector_id by the ID or the class of the selector you want to hide (using your browser code inspector to

Woocommerce: Get all orders for a product

跟風遠走 提交于 2020-01-22 20:05:07
问题 In the Woocommerce API I see a method wc_get_orders WooCommerce Order Functions In the mentioned args I do not see an argument in which I could provide a product ID or Object to limit order results only for that specific product. Is there a way I could filter orders only for specific products? I need to use this method since some arguments are necessary 回答1: Edited This function doesn't exist, but it can be built. So the function below will return an array of all orders IDs for a given

WooCommerce Subscriptions - Get related orders Ids for a specific subscription

半城伤御伤魂 提交于 2020-01-21 10:57:11
问题 Is there woocommerce function that will return me all related orders (at least the order ID) for the specific subscription that user has bough? I have found in this official documentation Subscription Function & Property Reference: WC_Subscription::get_related_orders( $return_fields, $order_type ); But this does not seem to be for specific subscription? When ever I try to run it I get a fatal error no mater what I pass in: Fatal error: Uncaught Error: Using $this when not in object context in

Woocommerce Add Fee Outside of the Cart

非 Y 不嫁゛ 提交于 2020-01-21 06:01:29
问题 I would like to add a fee to a woocommerce order. I have found many instances of this: $woocommerce->cart->add_fee() But I need to add a fee to an existing (processing or scheduled) order from within a function. can i simply call add_fee() For example, if i wanted to add a fee of $15 called "Option Adjustment" that is not taxable, could i simple do something like add_fee('Option Adjustment', 15, $taxable = false, $tax_class='') The problem, of course, is that add_fee outside of the cart has