orders

Adding custom text after order total in Woocommerce orders and emails

拟墨画扇 提交于 2021-01-28 07:55:41
问题 I am using this to display a custom text for customers from specific countries on the cart and checkout page: add_filter( 'woocommerce_cart_totals_order_total_html', 'custom_total_message_html', 10, 1 ); function custom_total_message_html( $value ) { if( in_array( WC()->customer->get_shipping_country(), array('US', 'CA') ) ) { $value .= '<small>' . __('My text.', 'woocommerce') . '</small>'; } return $value; } This does however NOT add the custom text after the order totals in the plain order

How to automatically create an account if a product in the order belongs to a certain category in WooCommerce

↘锁芯ラ 提交于 2021-01-28 05:54:35
问题 I have a WooCommerce shop where customers checkout as guests. I now want to sell a couple of virtual products and in that case I want to auto create an account. So I have two working code snippets. One to check if a product in cart is within a specific category (online) One to auto create an account from guest checkout. But I can't figure out how to combine these two so they work together. Or is it a better solution for this? Any ideas? Here is the two code snippets I started with and then

Change WooCommerce order status based on approved status and specific order item

帅比萌擦擦* 提交于 2021-01-28 03:20:44
问题 I try to change a WooCommerce order status to "Processing" when the current status is "Approved" and the order includes a specific product ( id = 10). I have attempted the code below but it is not working. I am quite new to php and would appreciate any guidance! add_action('woocommerce_order_status_changed', 'ts_auto_complete_business_cards'); function ts_auto_complete_business_cards($order_id) { if ( ! $order_id ) { return; } global $product; $order = wc_get_order( $order_id ); if ($order-

Custom add to cart button, if the customer has bought previously the product

。_饼干妹妹 提交于 2021-01-27 20:32:59
问题 In WooCommerce, I need to know if there's any option to change the add to cart button, if the customer has bought previously the product. We're selling online courses via WooCommerce & Membership, so the idea is that if the customer hasn't bought the course, he has to see the "Shop now" button. But if he has bought the course, he should see a "View now" button, with a custom link for each product (course). How can I achieve this? Thanks. 回答1: Here is a fully functional and tested custom

Add the order total weight to WooCommerce new order email notification

大兔子大兔子 提交于 2021-01-27 17:43:52
问题 Is it possible to show the total weight for an order in the WooCommerce "New order" email notification (for admins)? 回答1: Here is that custom function hooked in woocommerce_email_after_order_table action hook, that will show on "New order" email notification the total weight add_action('woocommerce_email_after_order_table','show_total_weight', 10, 4); function show_total_weight( $order, $sent_to_admin, $plain_text, $email ){ if ( 'new_order' != $email->id ) return; $total_weight = 0; foreach(

WooCommerce Add item to Order

别等时光非礼了梦想. 提交于 2021-01-20 16:57:19
问题 I'm trying to add an item to an existent order but it's not working properly... Everytime I execute the code below it ads and empty item, any help? woocommerce_add_order_item($Novo_PostId, $item); $item is the var witch receives the item itself from another order I have, I've put a print_r($item) and it appears to be ok. 回答1: After you create your item with woocommerce_add_order_item you have to set the meta data with woocommerce_add_order_item_meta() , see: http://docs.woothemes.com/wc

How to retrieve Shipping Method of an Order in WooCommerce?

末鹿安然 提交于 2021-01-20 04:52:08
问题 I am developing an eCommerce website on Wordpress using WooCommerce. I want to retrieve and display the 'Shipping Method' (i.e. Delivery or Collection etc.), that the customer had selected at the time of checkout, on the Order Confirmation page (i.e. after payment). I am trying to do this using get_post_meta($post_id, $key, $single) function. I am unable to do so as I don't know the $key value. I tried the following code (within php tag): echo get_post_meta( $order_id, 'shipping_method', true

Save Order item custom field in Woocommerce Admin order pages

家住魔仙堡 提交于 2021-01-19 08:01:31
问题 I have add custom fields in back office order for each line products : (source: com-pac.ovh) My problem is that I don't know how to save this fields. Can you please help me? function cfwc_create_custom_field() { $args = array( 'id' => 'custom_text_field_title', 'label' => __( 'Custom Text Field Title', 'cfwc' ), 'class' => 'cfwc-custom-field', 'desc_tip' => true, 'description' => __( 'Enter the title of your custom text field.', 'ctwc' ), ); woocommerce_wp_text_input( $args ); } add_action(

Save Order item custom field in Woocommerce Admin order pages

送分小仙女□ 提交于 2021-01-19 08:00:10
问题 I have add custom fields in back office order for each line products : (source: com-pac.ovh) My problem is that I don't know how to save this fields. Can you please help me? function cfwc_create_custom_field() { $args = array( 'id' => 'custom_text_field_title', 'label' => __( 'Custom Text Field Title', 'cfwc' ), 'class' => 'cfwc-custom-field', 'desc_tip' => true, 'description' => __( 'Enter the title of your custom text field.', 'ctwc' ), ); woocommerce_wp_text_input( $args ); } add_action(

Save Order item custom field in Woocommerce Admin order pages

徘徊边缘 提交于 2021-01-19 07:56:43
问题 I have add custom fields in back office order for each line products : (source: com-pac.ovh) My problem is that I don't know how to save this fields. Can you please help me? function cfwc_create_custom_field() { $args = array( 'id' => 'custom_text_field_title', 'label' => __( 'Custom Text Field Title', 'cfwc' ), 'class' => 'cfwc-custom-field', 'desc_tip' => true, 'description' => __( 'Enter the title of your custom text field.', 'ctwc' ), ); woocommerce_wp_text_input( $args ); } add_action(