hook-woocommerce

Display product optional cost in Woocommerce in order details

流过昼夜 提交于 2019-12-23 10:08:39
问题 Based on "Add a checkbox on single product pages that adds an additional cost in Woocommerce" answer code, I am trying to add an "extra warranty" option to my products (checkbox in product page): /* * add warrenty */ // Backend: Additional pricing option custom field add_action( 'woocommerce_product_options_pricing', 'wc_cost_product_field' ); function wc_cost_product_field() { woocommerce_wp_text_input( array( 'id' => '_warrenty_price', 'class' => 'wc_input_price short', 'label' => __(

How can I populate meta fields of a Woocommerce manual order

陌路散爱 提交于 2019-12-23 05:47:07
问题 I have defined two custom fields for my Woocommerce orders. I used WooCommerce Admin Custom Order Fields extension to create these two fields. When I manually create an order (/wp-admin/post-new.php?post_type=shop_order), I can see those fields and I can successfully add data and save the order. I would, however, like to automatically populate one of those fields in the code. I'm trying to use the following code to do find out the meta key to that custom field so I can use update_post_meta()

Change product price dynamically woocommerce [duplicate]

老子叫甜甜 提交于 2019-12-23 04:49:24
问题 This question already has an answer here : Dynamic cart item pricing not working on orders in WooCommerce 3.0+ (1 answer) Closed 2 years ago . I am trying to add custom fee to product price in woocommerce dynamically. I have done this many times in past, but its not working right now. Here is my code. function calculate_eyehole_fee( $cart_object ) { global $isProcessed; if( !WC()->session->__isset( "reload_checkout" )) { $eyeHoleFee = 30.00; $ribbonFee = 20.00; // Get exchange rate details

WooCommerce variable products: Display the min price with a custom text for different prices

浪子不回头ぞ 提交于 2019-12-23 04:34:04
问题 I'm setting up a function for Woocommerce that display discount price and the regular price for variable product, this function add a " from to " text before the price range. The "WooCommerce variable products: keep only "min" price with a custom label" answer thread matches the best with what I am looking for and work like a charm! But when all variations in a variable product have the same prices, the " start from " should not be displayed. So I've made a simple try and add below the "if"

Set a unique validation error notice in Woocommerce My Account Addresses and Account Details

喜欢而已 提交于 2019-12-23 03:07:14
问题 Billing fields in Woocommerce checkout page and my account page shows individual error if the required fields are empty. Well, if all fields are empty, all errors for those empty fields will be shown like: - First name is a required field - Last name is a required field - Street address is a required field and so on… I want to display only one error if all the required fields are empty, like “ERROR: All fields are empty. Please fill in all required fields to place order.” Well I somehow

Add a WooCommerce Orders List Column and value

本小妞迷上赌 提交于 2019-12-23 02:42:44
问题 In woo commerce order page(Admin Side) I want to add Drop Shipping column in order list which I done through add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 ); function custom_shop_order_column($columns) { $reordered_columns = array(); // Inserting columns to a specific location foreach( $columns as $key => $column){ $reordered_columns[$key] = $column; if( $key == 'order_total' ){ $reordered_columns['drop_shipping'] = __( 'Drop Shipping','twentyseventeen'); } }

Sort products by most viewed

邮差的信 提交于 2019-12-23 01:04:29
问题 I'm using a plugin that already count product views and store it in a table called 'mwb_wpr_data'. The query to list the product views is: SELECT DISTINCT('productid') FROM 'mwb_wpr_data' WHERE 'action' = 'view' The productid field is a FK to Woocomerce products. How can I modify the Woocommerce default sorting, so it will display products by order of most views based in the table 'mwb_wpr_data'? Current code using the plugin Post View Counter: add_action( 'pre_get_posts', 'my_view_filter' );

WooCommerce Empty cart after payment with custom gateway API

心不动则不痛 提交于 2019-12-23 00:49:47
问题 I'm working on custom API for Merchant Safe Unipay (MSU) for woocommerce and need to change quantity after successful payment. Here is process: Customer collect articles in shopping bag When click on "Pay All" it is redirected to MSU where need to fill Credit Card info After payment, MSU return him back to website where PHP send emails and print message about payment. All works well but can't find hook where and how to mark all products from shopping card payed and change quantity. How can I

Change order total after checkout in Woocommerce

我的未来我决定 提交于 2019-12-22 22:23:30
问题 I cant seem to find which hook to use to change the total (or any variable of the cart) after user clicks checkout. So for example, user Submits the Checkout form and then I need to do some checks and change the total accordingly. How should I do that, which hook do I use? 回答1: This can be done in woocommerce_checkout_create_order action hook, where you will have to use CRUD getters and setters methods for WC_Abstract_Order and WC_Order classes... As cart object and cart session has not been

Change order total after checkout in Woocommerce

∥☆過路亽.° 提交于 2019-12-22 22:23:02
问题 I cant seem to find which hook to use to change the total (or any variable of the cart) after user clicks checkout. So for example, user Submits the Checkout form and then I need to do some checks and change the total accordingly. How should I do that, which hook do I use? 回答1: This can be done in woocommerce_checkout_create_order action hook, where you will have to use CRUD getters and setters methods for WC_Abstract_Order and WC_Order classes... As cart object and cart session has not been