orders

Display custom delivery choice on Woocommerce Order totals table

不问归期 提交于 2019-12-11 06:48:55
问题 Based on "Update fee dynamically based on radio buttons in Woocommerce checkout" answer code, I have been able add a custom dynamic fee applied on customer delivery choice (with custom delivery option choices) . Here is the working code that I have adapted for my needs: add_action( 'woocommerce_cart_calculate_fees', 'add_delivery_fee', 20, 1 ); function add_delivery_fee( $cart ) { $domain = 'woocommerce'; $NipostFST = '2000'; $NIPOSTSUB = '250'; if ( is_admin() && ! defined( 'DOING_AJAX' ) )

For specific products on WooCommerce orders with completed status, perform an action

十年热恋 提交于 2019-12-11 06:14:15
问题 IN WooCommerce, I would like to perform an action if at least one product from a list is bought and if the current order status for that product is completed. For instance I can only verify if the product is bought: global $woocommerce; $user_id = get_current_user_id(); $current_user= wp_get_current_user(); $product_list = array('11', '12', '13', '14', '15','16'); $text= false; foreach ($product_list as $value): if (wc_customer_bought_product( $customer_email, $user_id, $value) ) { $text =

Auto set Woocommerce product to draft status if order is completed

泄露秘密 提交于 2019-12-11 05:55:01
问题 In WooCommerce I would like to set products to draft status when Order is completed… So what I want is to make products to be sold 1 time and passed to draft when order get completed. Any idea? 回答1: Try the following code, that will set the products found in order items with a "draft" status only when order get "processing" or "completed" statuses (paid order statuses) : add_action( 'woocommerce_order_status_changed', 'action_order_status_changed', 10, 4 ); function action_order_status

WooCommerce - Check if user purchased a product in the past 60 days

守給你的承諾、 提交于 2019-12-11 05:35:11
问题 I am new to WooCommerce and wanted to check if a user has purchased a specific product (product id # 514) within the past 60 days. This is a product I let people purchase monthly, so it will reoccur a lot. I wanted to just see if they purchased a recent one (that I consider active) The way I was thinking of doing it now was: Get all orders from a user For each order, check if it occurred in the past 60 days and and get all products for this order For each product, see if the id is x While I'm

Get tax rate used in an order for one product and for shipping in WooCommerce

♀尐吖头ヾ 提交于 2019-12-11 05:26:17
问题 In woocomerce, how to get the tax rate used in an order for one product ? And the tax rate For shipping ? 回答1: You can get the tax data used for an item (product) through WC_Order_Item_Product object and methods: // Get the an occurrence of the WC_Order object (if needed, from a defined $order ID) $order = wc_get_order( $order_id ); // Iterating through WC_Order_Item_Product objects foreach( $order->get_items() as $item_id => $line_item ){ ## -- Get all protected data in an accessible array -

Append order and order items parameters in Order received callback URL

て烟熏妆下的殇ゞ 提交于 2019-12-11 05:13:25
问题 In Woocommerce, I'm trying to get parameters values from order received (thankyou) URL, in the code below: function override_return_url($return_url,$order){ //create empty array to store url parameters in $sku_list = array(); // retrive products in order foreach($order->get_items() as $key => $item) { $product = wc_get_product($item['product_id']); //get sku of each product and insert it in array $sku_list['product_'.$item['product_id'] . 'sku'] = $product->get_sku(); $lolo = "66"; $order_id

WooCommerce access orders that have products on sale

陌路散爱 提交于 2019-12-11 04:57:18
问题 In WooCommerce, I have this function that loops through all the orders and get the orders that have coupon discounts: $orders = wc_get_orders( array('numberposts' => -1) ); // Loop through each WC_Order Object foreach( $orders as $order ){ if ( sizeof($order->get_used_coupons()) > 0 ) { $order_data = $order->get_data(); // The Order data $data = 'Order Number: #' . $order->id . '<br>' .'Order Status: '. $order->status . '<br>' . 'Order Creation Date: ' . $order_date_created = $order_data[

Conditionally hiding et showing payment gateways

浪尽此生 提交于 2019-12-11 04:49:55
问题 In Woocommerce, I would like to hide "paypal" gateway on the "checkout" page before the order is created for the first time and just show "cash on delivery" gateway (labeled as Reserve ). On the other hand, on checkout/order-pay page when the order status is "pending" , hide the 'Reserve' gateway and show "paypal" . (this happens when we change the status of the order to "pending" manually and send the invoice to the customer with a payment link). I thought it should be done by checking order

Add a drop down list of cities on admin orders pages in Woocommerce

末鹿安然 提交于 2019-12-11 04:11:48
问题 I would like to add drop down list of cities to new order page in woocommerce, I know way to add this functionality to checkout page, but here I want to add this functionality to admin new order pages in Woocommerce. See example image for reference: 回答1: Use the following hooked function for admin new order (where you will set your array of cities) : add_filter( 'woocommerce_admin_billing_fields' , 'admin_billing_city_select_field' ); function admin_billing_city_select_field( $fields ) {

Get refunded orders and refunded order items details in Woocommerce 3

跟風遠走 提交于 2019-12-11 03:15:28
问题 I see when I look at an order it will show the specific item that was refunded if the whole order wasn't. Is there a way to find using the WC_Order_Item_Product if an item was refunded? Also, is there a way to get the discount amount that shows up below the item in the order view? I'm currently doing it manually but if there is a function for it already, I would rather use it. 回答1: To get the order refunds you you use some dedicated WC_Order methods like the following ones that have the Item