hook-woocommerce

Display custom order meta data value in email notifications WooCommerce

柔情痞子 提交于 2021-02-11 14:02:29
问题 Based on the following code Add a custom checkbox in WooCommerce checkout which value shows in admin edit order I tried to add my_field_name to order confirmation email. As I understand I have to use woocommerce_email_customer_details . So I came to this solution, unfortunately without the desired result. add_action('woocommerce_email_customer_details','woocommerce_email_order_invoice_number', 28, 4 ); function woocommerce_email_order_invoice_number( $order, $sent_to_admin, $plain_text,

A non well formed numeric value encountered while using wc_price WooCommerce hook

给你一囗甜甜゛ 提交于 2021-02-10 17:38:04
问题 I have a simple function that used to work that I got online somewhere a few years back. It allows me to manually change the currency conversion rate for EUR (€, Euro). Problem now is this: Notice: A non well formed numeric value encountered in /wp-content/themes/theme/functions.php on line 82 Whereof the notice refers to this line: $new_price = $price * $conversion_rate; This is what I need help fixing. This is the complete code: function manual_currency_conversion( $price ) { $conversion

Assign a percentage fee to WooCommerce payment methods based on user roles

笑着哭i 提交于 2021-02-10 05:46:12
问题 How do I expand this snippet to include 2 more payment gateways with different fees? The payment gateways I want to add are 'cardgategiropay' and 'cardgateideal' and the fees are 3% and 2% respectively . add_action('woocommerce_cart_calculate_fees', 'sm_credit_card_fee_role_gateway', 10, 1); function sm_credit_card_fee_role_gateway($cart){ if (is_admin() && !defined('DOING_AJAX')) return; if ( ! ( is_checkout() && ! is_wc_endpoint_url('order-pay') ) ) return; if (!is_user_logged_in()) return;

Add and save a text field in WooCommerce customer order detail pages

心已入冬 提交于 2021-02-10 04:41:32
问题 I have been able to add a custom text input field, in woocommerce's order details page, but I can't save the data submitted data. This is the code: add_action( 'woocommerce_order_details_before_order_table', 'add_custom_Field',10,2 ); function add_custom_Field( $order_id) { $user = wp_get_current_user(); $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id; ?> <form method="post"> <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">

Add and save a text field in WooCommerce customer order detail pages

时光毁灭记忆、已成空白 提交于 2021-02-10 04:40:47
问题 I have been able to add a custom text input field, in woocommerce's order details page, but I can't save the data submitted data. This is the code: add_action( 'woocommerce_order_details_before_order_table', 'add_custom_Field',10,2 ); function add_custom_Field( $order_id) { $user = wp_get_current_user(); $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id; ?> <form method="post"> <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">

Refresh the page after product remove from cart Woocommerce

瘦欲@ 提交于 2021-02-08 09:24:25
问题 I am facing this issue in woocommerce. When product us removed from the cart, then update cart button disabled. And after the refresh page is working fine. I am trying this hook: woocommerce_cart_item_removed But its not working return nothing. 回答1: In the latest versions of Woocommerce there is a JavaScript callback trigger available as described in this commit: /** * Update the .cart_totals div with a string of html. * * @param {String} html_str The HTML string with which to replace the div

Refresh the page after product remove from cart Woocommerce

心不动则不痛 提交于 2021-02-08 09:23:06
问题 I am facing this issue in woocommerce. When product us removed from the cart, then update cart button disabled. And after the refresh page is working fine. I am trying this hook: woocommerce_cart_item_removed But its not working return nothing. 回答1: In the latest versions of Woocommerce there is a JavaScript callback trigger available as described in this commit: /** * Update the .cart_totals div with a string of html. * * @param {String} html_str The HTML string with which to replace the div

Move coupon field after checkout payment in Woocommerce?

前提是你 提交于 2021-02-08 09:16:57
问题 I want to move the coupon file after the checkout payment. This is what I have tried all ready: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form'); add_action( 'woocommerce_after_checkout_form', 'woocommerce_checkout_coupon_form' ); Now is currently after the checkout form. Thanks! 回答1: You should try this: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_review_order_before_payment',

Move coupon field after checkout payment in Woocommerce?

自古美人都是妖i 提交于 2021-02-08 09:16:49
问题 I want to move the coupon file after the checkout payment. This is what I have tried all ready: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form'); add_action( 'woocommerce_after_checkout_form', 'woocommerce_checkout_coupon_form' ); Now is currently after the checkout form. Thanks! 回答1: You should try this: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_review_order_before_payment',

Change user role based on WooCommerce yearly orders count

旧时模样 提交于 2021-02-08 09:14:06
问题 I'm trying to implement a feature where customers receive a new user role after a certain amount of orders have been made, but all those orders must have been made within the same year. I was able to assign the user role based on nth number of orders but can't seem to go beyond to where the date needs to be taken into consideration, can someone point me in the right direction or point out what I might be missing. This is what I have tried so far. function change_user_role_on_order_status